diff --git a/README.md b/README.md index 31177840c..3b3c8b145 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/src/codeflare_sdk/__init__.py b/src/codeflare_sdk/__init__.py index 358ff4f2e..0390a3d2f 100644 --- a/src/codeflare_sdk/__init__.py +++ b/src/codeflare_sdk/__init__.py @@ -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 diff --git a/demo-notebooks/additional-demos/hf_interactive.ipynb b/src/codeflare_sdk/demo-notebooks/additional-demos/hf_interactive.ipynb similarity index 100% rename from demo-notebooks/additional-demos/hf_interactive.ipynb rename to src/codeflare_sdk/demo-notebooks/additional-demos/hf_interactive.ipynb diff --git a/demo-notebooks/additional-demos/local_interactive.ipynb b/src/codeflare_sdk/demo-notebooks/additional-demos/local_interactive.ipynb similarity index 100% rename from demo-notebooks/additional-demos/local_interactive.ipynb rename to src/codeflare_sdk/demo-notebooks/additional-demos/local_interactive.ipynb diff --git a/demo-notebooks/additional-demos/ray_job_client.ipynb b/src/codeflare_sdk/demo-notebooks/additional-demos/ray_job_client.ipynb similarity index 100% rename from demo-notebooks/additional-demos/ray_job_client.ipynb rename to src/codeflare_sdk/demo-notebooks/additional-demos/ray_job_client.ipynb diff --git a/demo-notebooks/guided-demos/0_basic_ray.ipynb b/src/codeflare_sdk/demo-notebooks/guided-demos/0_basic_ray.ipynb similarity index 100% rename from demo-notebooks/guided-demos/0_basic_ray.ipynb rename to src/codeflare_sdk/demo-notebooks/guided-demos/0_basic_ray.ipynb diff --git a/demo-notebooks/guided-demos/1_cluster_job_client.ipynb b/src/codeflare_sdk/demo-notebooks/guided-demos/1_cluster_job_client.ipynb similarity index 100% rename from demo-notebooks/guided-demos/1_cluster_job_client.ipynb rename to src/codeflare_sdk/demo-notebooks/guided-demos/1_cluster_job_client.ipynb diff --git a/demo-notebooks/guided-demos/2_basic_interactive.ipynb b/src/codeflare_sdk/demo-notebooks/guided-demos/2_basic_interactive.ipynb similarity index 100% rename from demo-notebooks/guided-demos/2_basic_interactive.ipynb rename to src/codeflare_sdk/demo-notebooks/guided-demos/2_basic_interactive.ipynb diff --git a/demo-notebooks/guided-demos/download_mnist_datasets.py b/src/codeflare_sdk/demo-notebooks/guided-demos/download_mnist_datasets.py similarity index 100% rename from demo-notebooks/guided-demos/download_mnist_datasets.py rename to src/codeflare_sdk/demo-notebooks/guided-demos/download_mnist_datasets.py diff --git a/demo-notebooks/guided-demos/mnist.py b/src/codeflare_sdk/demo-notebooks/guided-demos/mnist.py similarity index 100% rename from demo-notebooks/guided-demos/mnist.py rename to src/codeflare_sdk/demo-notebooks/guided-demos/mnist.py diff --git a/demo-notebooks/guided-demos/mnist_disconnected.py b/src/codeflare_sdk/demo-notebooks/guided-demos/mnist_disconnected.py similarity index 100% rename from demo-notebooks/guided-demos/mnist_disconnected.py rename to src/codeflare_sdk/demo-notebooks/guided-demos/mnist_disconnected.py diff --git a/demo-notebooks/guided-demos/mnist_fashion.py b/src/codeflare_sdk/demo-notebooks/guided-demos/mnist_fashion.py similarity index 100% rename from demo-notebooks/guided-demos/mnist_fashion.py rename to src/codeflare_sdk/demo-notebooks/guided-demos/mnist_fashion.py diff --git a/demo-notebooks/guided-demos/notebook-ex-outputs/0_basic_ray.ipynb b/src/codeflare_sdk/demo-notebooks/guided-demos/notebook-ex-outputs/0_basic_ray.ipynb similarity index 100% rename from demo-notebooks/guided-demos/notebook-ex-outputs/0_basic_ray.ipynb rename to src/codeflare_sdk/demo-notebooks/guided-demos/notebook-ex-outputs/0_basic_ray.ipynb diff --git a/demo-notebooks/guided-demos/notebook-ex-outputs/1_cluster_job_client.ipynb b/src/codeflare_sdk/demo-notebooks/guided-demos/notebook-ex-outputs/1_cluster_job_client.ipynb similarity index 100% rename from demo-notebooks/guided-demos/notebook-ex-outputs/1_cluster_job_client.ipynb rename to src/codeflare_sdk/demo-notebooks/guided-demos/notebook-ex-outputs/1_cluster_job_client.ipynb diff --git a/demo-notebooks/guided-demos/notebook-ex-outputs/2_basic_interactive.ipynb b/src/codeflare_sdk/demo-notebooks/guided-demos/notebook-ex-outputs/2_basic_interactive.ipynb similarity index 100% rename from demo-notebooks/guided-demos/notebook-ex-outputs/2_basic_interactive.ipynb rename to src/codeflare_sdk/demo-notebooks/guided-demos/notebook-ex-outputs/2_basic_interactive.ipynb diff --git a/demo-notebooks/guided-demos/notebook-ex-outputs/interactivetest.yaml b/src/codeflare_sdk/demo-notebooks/guided-demos/notebook-ex-outputs/interactivetest.yaml similarity index 100% rename from demo-notebooks/guided-demos/notebook-ex-outputs/interactivetest.yaml rename to src/codeflare_sdk/demo-notebooks/guided-demos/notebook-ex-outputs/interactivetest.yaml diff --git a/demo-notebooks/guided-demos/notebook-ex-outputs/jobtest.yaml b/src/codeflare_sdk/demo-notebooks/guided-demos/notebook-ex-outputs/jobtest.yaml similarity index 100% rename from demo-notebooks/guided-demos/notebook-ex-outputs/jobtest.yaml rename to src/codeflare_sdk/demo-notebooks/guided-demos/notebook-ex-outputs/jobtest.yaml diff --git a/demo-notebooks/guided-demos/notebook-ex-outputs/mnist.py b/src/codeflare_sdk/demo-notebooks/guided-demos/notebook-ex-outputs/mnist.py similarity index 100% rename from demo-notebooks/guided-demos/notebook-ex-outputs/mnist.py rename to src/codeflare_sdk/demo-notebooks/guided-demos/notebook-ex-outputs/mnist.py diff --git a/demo-notebooks/guided-demos/notebook-ex-outputs/raytest.yaml b/src/codeflare_sdk/demo-notebooks/guided-demos/notebook-ex-outputs/raytest.yaml similarity index 100% rename from demo-notebooks/guided-demos/notebook-ex-outputs/raytest.yaml rename to src/codeflare_sdk/demo-notebooks/guided-demos/notebook-ex-outputs/raytest.yaml diff --git a/demo-notebooks/guided-demos/notebook-ex-outputs/requirements.txt b/src/codeflare_sdk/demo-notebooks/guided-demos/notebook-ex-outputs/requirements.txt similarity index 100% rename from demo-notebooks/guided-demos/notebook-ex-outputs/requirements.txt rename to src/codeflare_sdk/demo-notebooks/guided-demos/notebook-ex-outputs/requirements.txt diff --git a/demo-notebooks/guided-demos/preview_nbs/0_basic_ray.ipynb b/src/codeflare_sdk/demo-notebooks/guided-demos/preview_nbs/0_basic_ray.ipynb similarity index 100% rename from demo-notebooks/guided-demos/preview_nbs/0_basic_ray.ipynb rename to src/codeflare_sdk/demo-notebooks/guided-demos/preview_nbs/0_basic_ray.ipynb diff --git a/demo-notebooks/guided-demos/preview_nbs/1_cluster_job_client.ipynb b/src/codeflare_sdk/demo-notebooks/guided-demos/preview_nbs/1_cluster_job_client.ipynb similarity index 100% rename from demo-notebooks/guided-demos/preview_nbs/1_cluster_job_client.ipynb rename to src/codeflare_sdk/demo-notebooks/guided-demos/preview_nbs/1_cluster_job_client.ipynb diff --git a/demo-notebooks/guided-demos/preview_nbs/2_basic_interactive.ipynb b/src/codeflare_sdk/demo-notebooks/guided-demos/preview_nbs/2_basic_interactive.ipynb similarity index 100% rename from demo-notebooks/guided-demos/preview_nbs/2_basic_interactive.ipynb rename to src/codeflare_sdk/demo-notebooks/guided-demos/preview_nbs/2_basic_interactive.ipynb diff --git a/demo-notebooks/guided-demos/preview_nbs/mnist.py b/src/codeflare_sdk/demo-notebooks/guided-demos/preview_nbs/mnist.py similarity index 100% rename from demo-notebooks/guided-demos/preview_nbs/mnist.py rename to src/codeflare_sdk/demo-notebooks/guided-demos/preview_nbs/mnist.py diff --git a/demo-notebooks/guided-demos/preview_nbs/requirements.txt b/src/codeflare_sdk/demo-notebooks/guided-demos/preview_nbs/requirements.txt similarity index 100% rename from demo-notebooks/guided-demos/preview_nbs/requirements.txt rename to src/codeflare_sdk/demo-notebooks/guided-demos/preview_nbs/requirements.txt diff --git a/demo-notebooks/guided-demos/requirements.txt b/src/codeflare_sdk/demo-notebooks/guided-demos/requirements.txt similarity index 100% rename from demo-notebooks/guided-demos/requirements.txt rename to src/codeflare_sdk/demo-notebooks/guided-demos/requirements.txt diff --git a/src/codeflare_sdk/utils/demos.py b/src/codeflare_sdk/utils/demos.py new file mode 100644 index 000000000..2571a23dd --- /dev/null +++ b/src/codeflare_sdk/utils/demos.py @@ -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)