Skip to content

Commit fa2e1c7

Browse files
authored
New deployment steps (#123)
Copy images (outputs of cells in notebooks) into deployment, in the expected file structure.
1 parent ed6b6b2 commit fa2e1c7

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

.github/workflows/testdeploy.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ jobs:
2828
env:
2929
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3030
run: |
31-
mkdir public
32-
python deployment/installtutorials.py --dest public
31+
mkdir -p public/tutorials
32+
python deployment/installtutorials.py --dest public/tutorials
3333
3434
- name: List tutorials
3535
run: |
36-
tree public
36+
tree public/tutorials

deployment/installtutorials.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ def parse_args() -> argparse.Namespace:
3434

3535
def process_repo(repo, destination_directory):
3636
"""Process a tutorial repository to copy its rendered tutorial(s) into `destination_directory`."""
37+
os.makedirs(destination_directory, exist_ok=True)
38+
3739
repo_name = repo["full_name"]
3840
if not repo_name.split("/")[1].startswith("tutorial--"):
3941
return
@@ -53,6 +55,7 @@ def process_repo(repo, destination_directory):
5355
return
5456

5557
repo = Path(tmp)
58+
# os.system(f'tree {repo}')
5659
tutorials = glob.glob(f"{repo}/_sources/*.ipynb")
5760
for t in tutorials:
5861
tname = os.path.splitext(os.path.basename(t))[0]
@@ -67,9 +70,14 @@ def process_repo(repo, destination_directory):
6770
print(f"More than 1 tutorial found; also copying index file {index}")
6871
shutil.copy(index, destination_directory)
6972
# copy images (plots) in notebook for faster page loading
70-
try:
71-
shutil.copy(f"{repo}/_images/*.png", f"{destination_directory}/nboutput")
72-
except FileNotFoundError:
73+
images = glob.glob(f"{repo}/_images/*.png")
74+
if len(images) > 0:
75+
print("Copying notebook cell output images")
76+
image_dir = f"{destination_directory}/nboutput"
77+
os.makedirs(image_dir, exist_ok=True)
78+
for i in images:
79+
shutil.copy(i, image_dir)
80+
else:
7381
print("No notebook cell output images found to copy")
7482

7583

0 commit comments

Comments
 (0)