Skip to content

Commit f3b8f5d

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

26 files changed

+28
-0
lines changed

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 clone_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 clone_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 clone_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)