Skip to content
This repository was archived by the owner on Aug 28, 2025. It is now read-only.

Commit 3982f1c

Browse files
authored
CI/CD: store runtime requirements (#151)
* store runtime requirements * cat meta * ci docs * convert-ipynb
1 parent 18256c4 commit 3982f1c

File tree

7 files changed

+18
-12
lines changed

7 files changed

+18
-12
lines changed

.actions/assistant.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,6 @@ def bash_render(folder: str) -> str:
308308
ipynb_file, meta_file, thumb_file = AssistantCLI._valid_folder(folder, ext=".ipynb")
309309
pub_ipynb = os.path.join(DIR_NOTEBOOKS, f"{folder}.ipynb")
310310
pub_dir = os.path.dirname(pub_ipynb)
311-
pub_meta = os.path.join(DIR_NOTEBOOKS, f"{folder}.yaml")
312311
thumb_ext = os.path.splitext(thumb_file)[-1] if thumb_file else "."
313312
pub_thumb = os.path.join(DIR_NOTEBOOKS, f"{folder}{thumb_ext}") if thumb_file else ""
314313
cmd.append(f"mkdir -p {pub_dir}")
@@ -325,9 +324,9 @@ def bash_render(folder: str) -> str:
325324
warn("Invalid notebook's accelerator for this device. So no outputs will be generated.", RuntimeWarning)
326325
cmd.append(f"cp {ipynb_file} {pub_ipynb}")
327326
# Export the actual packages used in runtime
328-
cmd.append(f"python .actions/assistant.py update-env-details {folder}")
327+
cmd.append(f"meta_file=$(python .actions/assistant.py update-env-details {folder})")
329328
# copy and add to version the enriched meta config
330-
cmd += [f"cp {meta_file} {pub_meta}", f"git add {pub_meta}"]
329+
cmd += ["echo $meta_file", "cat $meta_file", "git add $meta_file"]
331330
# if thumb image is linked to the notebook, copy and version it too
332331
if thumb_file:
333332
cmd += [f"cp {thumb_file} {pub_thumb}", f"git add {pub_thumb}"]
@@ -358,6 +357,10 @@ def bash_test(folder: str) -> str:
358357
# and install specific packages
359358
pip_req, pip_args = AssistantCLI._parse_requirements(folder)
360359
cmd += [f"pip install {pip_req} {pip_args}", "pip list"]
360+
# Export the actual packages used in runtime
361+
cmd.append(f"meta_file=$(python .actions/assistant.py update-env-details {folder} --base_path .)")
362+
# show created meta config
363+
cmd += ["echo $meta_file", "cat $meta_file"]
361364

362365
cmd.append(f"# available: {AssistantCLI.DEVICE_ACCELERATOR}")
363366
if AssistantCLI._valid_accelerator(folder):
@@ -369,7 +372,7 @@ def bash_test(folder: str) -> str:
369372
return os.linesep.join(cmd)
370373

371374
@staticmethod
372-
def augment_script(folder: str) -> None:
375+
def convert_ipynb(folder: str) -> None:
373376
"""Add template header and footer to the python base script.
374377
375378
Args:
@@ -609,7 +612,7 @@ def copy_notebooks(
609612
ipynb_content.append(os.path.join("notebooks", sub_ipynb))
610613

611614
@staticmethod
612-
def update_env_details(folder: str) -> None:
615+
def update_env_details(folder: str, base_path: str = DIR_NOTEBOOKS) -> str:
613616
"""Export the actual packages used in runtime.
614617
615618
Args:
@@ -636,8 +639,9 @@ def _parse_package_name(pkg: str, keys: str = " <=>[]@", egg_name: str = "#egg="
636639
meta["environment"] = [env[r] for r in require]
637640
meta["published"] = datetime.now().isoformat()
638641

639-
fmeta = os.path.join(DIR_NOTEBOOKS, folder) + ".yaml"
642+
fmeta = os.path.join(base_path, folder) + ".yaml"
640643
yaml.safe_dump(meta, stream=open(fmeta, "w"), sort_keys=False)
644+
return fmeta
641645

642646
@staticmethod
643647
def list_dirs(folder: str = "", include_file_ext: str = "") -> str:

.actions/test_cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def _path_in_dir(fname: str, folder: str = _PATH_ROOT) -> str:
2121
("bash_render", [_PATH_DIR_SIMPLE]),
2222
("bash_test", [_PATH_DIR_SIMPLE]),
2323
("group_folders", [_path_in_dir("master-diff.txt"), _path_in_dir("dirs-b1.txt"), _path_in_dir("dirs-b2.txt")]),
24-
("augment_script", [_PATH_DIR_SIMPLE]),
24+
("convert_ipynb", [_PATH_DIR_SIMPLE]),
2525
("copy_notebooks", [_PATH_ROOT]),
2626
("update_env_details", [_PATH_DIR_SIMPLE]),
2727
],

.azure/ipynb-publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ jobs:
8787
8888
- bash: |
8989
while IFS= read -r line; do
90-
python .actions/assistant.py augment-script $line
90+
python .actions/assistant.py convert-ipynb $line
9191
done <<< $(cat changed-folders.txt)
9292
condition: gt(variables['changed.folders'], 0)
9393
displayName: 'Generate notebook'

.azure/ipynb-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ jobs:
6363
6464
- bash: |
6565
while IFS= read -r line; do
66-
python .actions/assistant.py augment-script $line
66+
python .actions/assistant.py convert-ipynb $line
6767
done <<< $(cat changed-folders.txt)
6868
condition: gt(variables['changed.folders'], 0)
6969
displayName: 'Generate notebook'

.github/workflows/ci_docs.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
name: validate Docs
22

33
on: # Trigger the workflow on push or pull request
4+
push:
5+
branches: [main]
46
pull_request: {}
57
schedule:
68
# At the end of every day
@@ -70,7 +72,7 @@ jobs:
7072
if: steps.changed.outputs.dirs != 0
7173
run: |
7274
while IFS= read -r line; do
73-
python .actions/assistant.py augment-script $line
75+
python .actions/assistant.py convert-ipynb $line
7476
python .actions/assistant.py bash-render $line > .actions/_ipynb-render.sh
7577
cat .actions/_ipynb-render.sh
7678
bash .actions/_ipynb-render.sh

.github/workflows/ci_testing.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ jobs:
6464
if: steps.changed.outputs.dirs != 0
6565
run: |
6666
while IFS= read -r line; do
67-
python .actions/assistant.py augment-script $line
67+
python .actions/assistant.py convert-ipynb $line
6868
done <<< $(cat changed-folders.txt)
6969
shell: bash
7070

templates/simple/.meta.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ author: PL team
33
created: 2021-06-15
44
updated: 2021-06-17
55
license: CC
6-
build: 6
6+
build: 7
77
description: |
88
This is a template to show how to contribute a tutorial.
99
requirements:

0 commit comments

Comments
 (0)