Skip to content

Commit

Permalink
mv demo nbs into src folder and add fn for cloning to current dir
Browse files Browse the repository at this point in the history
Signed-off-by: Kevin <[email protected]>
  • Loading branch information
KPostOffice committed Jul 26, 2024
1 parent ecf04c3 commit 38f2a75
Show file tree
Hide file tree
Showing 27 changed files with 30 additions and 2 deletions.
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
File renamed without changes.
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)

0 comments on commit 38f2a75

Please sign in to comment.