Skip to content

mv demo nbs into src folder and add fn for cloning to current dir #605

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ An intuitive, easy-to-use python interface for batch resource requesting, access

For guided demos and basics walkthroughs, check out the following links:

- Guided demo notebooks available [here](https://github.com/project-codeflare/codeflare-sdk/tree/main/demo-notebooks/guided-demos), and copies of the notebooks with [expected output](https://github.com/project-codeflare/codeflare-sdk/tree/main/demo-notebooks/guided-demos/notebook-ex-outputs) also available
- Note that these notebooks will work with the latest `codeflare-sdk` PyPI release. For testing and experimentation with `main` branch, please use the [preview notebooks](https://github.com/project-codeflare/codeflare-sdk/tree/main/demo-notebooks/guided-demos/preview_nbs)
- Guided demo notebooks available [here](https://github.com/project-codeflare/codeflare-sdk/tree/main/src/demo-notebooks/guided-demos), and copies of the notebooks with [expected output](https://github.com/project-codeflare/codeflare-sdk/tree/main/src/demo-notebooks/guided-demos/notebook-ex-outputs) also available
- these demos can be copied into your current working directory when using the `codeflare-sdk` by using the `codeflare_sdk.copy_demo_nbs()` function
- Additionally, we have a [video walkthrough](https://www.youtube.com/watch?v=U76iIfd9EmE) of these basic demos from June, 2023

Full documentation can be found [here](https://project-codeflare.github.io/codeflare-sdk/detailed-documentation)
Expand Down
1 change: 1 addition & 0 deletions src/codeflare_sdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from .job import RayJobClient

from .utils import generate_cert
from .utils.demos import copy_demo_nbs

from importlib.metadata import version, PackageNotFoundError

Expand Down
27 changes: 27 additions & 0 deletions src/codeflare_sdk/utils/demos.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import pathlib
import shutil

package_dir = pathlib.Path(__file__).parent.parent.resolve()
demo_dir = f"{package_dir}/demo-notebooks"


def copy_demo_nbs(dir: str = "./demo-notebooks", overwrite: bool = False):
"""
Copy the demo notebooks from the package to the current working directory

overwrite=True will overwrite any files that exactly match files written by copy_demo_nbs in the target directory.
Any files that exist in the directory that don't match these values will remain untouched.

Args:
dir (str): The directory to copy the demo notebooks to. Defaults to "./demo-notebooks". overwrite (bool):
overwrite (bool): Whether to overwrite files in the directory if it already exists. Defaults to False.
Raises:
FileExistsError: If the directory already exists.
"""
# does dir exist already?
if overwrite is False and pathlib.Path(dir).exists():
raise FileExistsError(
f"Directory {dir} already exists. Please remove it or provide a different location."
)

shutil.copytree(demo_dir, dir, dirs_exist_ok=True)