From efa3b19853295e085af05dfa52142fa19349209c Mon Sep 17 00:00:00 2001 From: Jeff Jennings Date: Tue, 24 Jun 2025 00:05:37 -0400 Subject: [PATCH 1/2] copy images --- deployment/installtutorials.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/deployment/installtutorials.py b/deployment/installtutorials.py index f38a6c1..99810d4 100644 --- a/deployment/installtutorials.py +++ b/deployment/installtutorials.py @@ -34,6 +34,8 @@ def parse_args() -> argparse.Namespace: def process_repo(repo, destination_directory): """Process a tutorial repository to copy its rendered tutorial(s) into `destination_directory`.""" + os.makedirs(destination_directory, exist_ok=True) + repo_name = repo["full_name"] if not repo_name.split("/")[1].startswith("tutorial--"): return @@ -53,6 +55,7 @@ def process_repo(repo, destination_directory): return repo = Path(tmp) + # os.system(f'tree {repo}') tutorials = glob.glob(f"{repo}/_sources/*.ipynb") for t in tutorials: tname = os.path.splitext(os.path.basename(t))[0] @@ -67,9 +70,14 @@ def process_repo(repo, destination_directory): print(f"More than 1 tutorial found; also copying index file {index}") shutil.copy(index, destination_directory) # copy images (plots) in notebook for faster page loading - try: - shutil.copy(f"{repo}/_images/*.png", f"{destination_directory}/nboutput") - except FileNotFoundError: + images = glob.glob(f"{repo}/_images/*.png") + if len(images) > 0: + print("Copying notebook cell output images") + image_dir = f"{destination_directory}/nboutput" + os.makedirs(image_dir, exist_ok=True) + for i in images: + shutil.copy(i, image_dir) + else: print("No notebook cell output images found to copy") From 1bdc06d9d0bc247395c3fff5548b00b4c8771501 Mon Sep 17 00:00:00 2001 From: Jeff Jennings Date: Tue, 24 Jun 2025 00:05:57 -0400 Subject: [PATCH 2/2] match dir in test deploy --- .github/workflows/testdeploy.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/testdeploy.yaml b/.github/workflows/testdeploy.yaml index 12c24e8..fc9c015 100644 --- a/.github/workflows/testdeploy.yaml +++ b/.github/workflows/testdeploy.yaml @@ -28,9 +28,9 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - mkdir public - python deployment/installtutorials.py --dest public + mkdir -p public/tutorials + python deployment/installtutorials.py --dest public/tutorials - name: List tutorials run: | - tree public + tree public/tutorials