Skip to content

Commit 62ce155

Browse files
mv demo nbs into src folder and add fn for cloning to current dir
Signed-off-by: Kevin <[email protected]>
1 parent ecf04c3 commit 62ce155

27 files changed

+30
-2
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ An intuitive, easy-to-use python interface for batch resource requesting, access
77

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

10-
- 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
11-
- 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)
10+
- 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
11+
- these demos can be copied into your current working directory when using the `codeflare-sdk` by using the `codeflare_sdk.copy_demo_nbs()` function
1212
- Additionally, we have a [video walkthrough](https://www.youtube.com/watch?v=U76iIfd9EmE) of these basic demos from June, 2023
1313

1414
Full documentation can be found [here](https://project-codeflare.github.io/codeflare-sdk/detailed-documentation)

src/codeflare_sdk/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from .job import RayJobClient
2020

2121
from .utils import generate_cert
22+
from .utils.demos import copy_demo_nbs
2223

2324
from importlib.metadata import version, PackageNotFoundError
2425

src/codeflare_sdk/utils/demos.py

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import pathlib
2+
import shutil
3+
4+
package_dir = pathlib.Path(__file__).parent.parent.resolve()
5+
demo_dir = f"{package_dir}/demo-notebooks"
6+
7+
8+
def copy_demo_nbs(dir: str = "./demo-notebooks", overwrite: bool = False):
9+
"""
10+
Copy the demo notebooks from the package to the current working directory
11+
12+
overwrite=True will overwrite any files that exactly match files written by copy_demo_nbs in the target directory.
13+
Any files that exist in the directory that don't match these values will remain untouched.
14+
15+
Args:
16+
dir (str): The directory to copy the demo notebooks to. Defaults to "./demo-notebooks". overwrite (bool):
17+
overwrite (bool): Whether to overwrite files in the directory if it already exists. Defaults to False.
18+
Raises:
19+
FileExistsError: If the directory already exists.
20+
"""
21+
# does dir exist already?
22+
if overwrite is False and pathlib.Path(dir).exists():
23+
raise FileExistsError(
24+
f"Directory {dir} already exists. Please remove it or provide a different location."
25+
)
26+
27+
shutil.copytree(demo_dir, dir, dirs_exist_ok=True)

0 commit comments

Comments
 (0)