661. Copies the corresponding tutorials/*/brev/docker-compose.yml file
772. Modifies it by setting the default-jupyter-url to the syllabus file path
883. Outputs the modified file to tutorials/*/notebooks/syllabi/{syllabus-name}__docker_compose.yml
9- 4. Creates a syllabi.md file linking to all syllabi and their docker-compose files
109"""
1110
1211import re
1312from pathlib import Path
14- from typing import List , Tuple
1513
1614
1715def extract_working_dir (content : str ) -> str :
@@ -54,34 +52,6 @@ def modify_docker_compose(content: str, jupyter_url: str) -> str:
5452 return modified
5553
5654
57- def generate_syllabi_markdown (tutorial_name : str , syllabi_info : List [Tuple [str , str ]]) -> str :
58- """
59- Generate a markdown file content listing all syllabi and their docker-compose files.
60-
61- Args:
62- tutorial_name: Name of the tutorial
63- syllabi_info: List of tuples (syllabus_filename, docker_compose_filename)
64-
65- Returns:
66- Generated markdown content
67- """
68- lines = [
69- f"# { tutorial_name .replace ('-' , ' ' ).title ()} - Syllabi\n " ,
70- "\n This directory contains different syllabi for this tutorial. Each syllabus is described in a notebook and has an associated Docker Compose configuration file that can be used to create a Brev Launchable.\n " ,
71- "\n ## Available Syllabi\n "
72- ]
73-
74- for syllabus_file , docker_compose_file in sorted (syllabi_info ):
75- # Create a human-readable title from the filename
76- title = syllabus_file .replace ('.ipynb' , '' ).replace ('_' , ' ' ).replace (' ' , ' - ' )
77-
78- lines .append (f"\n ### { title } \n " )
79- lines .append (f"- **Notebook**: [{ syllabus_file } ]({ syllabus_file } )\n " )
80- lines .append (f"- **Docker Compose**: [{ docker_compose_file } ]({ docker_compose_file } )\n " )
81-
82- return '' .join (lines )
83-
84-
8555def main ():
8656 """Main processing function."""
8757 # Find all tutorials directories
@@ -121,9 +91,6 @@ def main():
12191 print (f"⚠️ Warning: Could not extract working-dir from { docker_compose_src } " )
12292 continue
12393
124- # Track syllabi info for generating the markdown file
125- syllabi_info = []
126-
12794 # Process each syllabus file
12895 for syllabus_file in syllabi_dir .glob ('*.ipynb' ):
12996 # JupyterLab requires the "lab/tree/" prefix to open notebooks
@@ -139,24 +106,12 @@ def main():
139106 # Write modified docker-compose file next to the syllabus file
140107 # Pattern: /path/to/X.ipynb -> /path/to/X__docker_compose.yml
141108 syllabus_name = syllabus_file .stem # Filename without extension
142- docker_compose_filename = f"{ syllabus_name } __docker_compose.yml"
143- output_file = syllabi_dir / docker_compose_filename
109+ output_file = syllabi_dir / f"{ syllabus_name } __docker_compose.yml"
144110 with open (output_file , 'w' ) as f :
145111 f .write (modified_content )
146112
147- # Track this syllabus for the markdown file
148- syllabi_info .append ((syllabus_file .name , docker_compose_filename ))
149-
150113 processed_count += 1
151114
152- # Generate syllabi.md file if there are any syllabi
153- if syllabi_info :
154- markdown_content = generate_syllabi_markdown (tutorial_name , syllabi_info )
155- markdown_file = syllabi_dir / 'syllabi.md'
156- with open (markdown_file , 'w' ) as f :
157- f .write (markdown_content )
158- print (f" 📝 Generated: syllabi.md" )
159-
160115 print (f"\n ✅ Successfully processed { processed_count } syllabi files" )
161116
162117 return 0
0 commit comments