Skip to content

New deployment steps #123

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/testdeploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
14 changes: 11 additions & 3 deletions deployment/installtutorials.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]
Expand All @@ -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")


Expand Down
Loading