Skip to content
This repository was archived by the owner on Aug 28, 2025. It is now read-only.
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
18 changes: 14 additions & 4 deletions .actions/assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
_PATH_HERE = os.path.dirname(__file__)
_PATH_ROOT = os.path.dirname(_PATH_HERE)
PATH_REQ_DEFAULT = os.path.join(_PATH_ROOT, "requirements", "default.txt")
PATH_SCRIPT_RENDER = os.path.join(_PATH_HERE, "_ipynb-render.sh")
PATH_SCRIPT_TEST = os.path.join(_PATH_HERE, "_ipynb-test.sh")
REPO_NAME = "lightning-tutorials"
COLAB_REPO_LINK = "https://colab.research.google.com/github/PytorchLightning"
BRANCH_DEFAULT = "main"
Expand Down Expand Up @@ -293,11 +295,12 @@ def _bash_download_data(folder: str) -> List[str]:
return cmd

@staticmethod
def bash_render(folder: str) -> str:
def bash_render(folder: str, output_file: str = PATH_SCRIPT_RENDER) -> Optional[str]:
"""Prepare bash script for running rendering of a particular notebook.

Args:
folder: name/path to a folder with notebook files
output_file: if defined, stream the commands to the file

Returns:
string with nash script content
Expand Down Expand Up @@ -332,14 +335,18 @@ def bash_render(folder: str) -> str:
cmd += [f"cp {thumb_file} {pub_thumb}", f"git add {pub_thumb}"]
# add the generated notebook to version
cmd.append(f"git add {pub_ipynb}")
return os.linesep.join(cmd)
if not output_file:
return os.linesep.join(cmd)
with open(output_file, "w") as fp:
fp.write(os.linesep.join(cmd))

@staticmethod
def bash_test(folder: str) -> str:
def bash_test(folder: str, output_file: str = PATH_SCRIPT_TEST) -> Optional[str]:
"""Prepare bash script for running tests of a particular notebook.

Args:
folder: name/path to a folder with notebook files
output_file: if defined, stream the commands to the file

Returns:
string with nash script content
Expand Down Expand Up @@ -369,7 +376,10 @@ def bash_test(folder: str) -> str:
warn("Invalid notebook's accelerator for this device. So no tests will be run!!!", RuntimeWarning)
# deactivate and clean local environment
cmd += ["deactivate", f"rm -rf {os.path.join(folder, 'venv')}"]
return os.linesep.join(cmd)
if not output_file:
return os.linesep.join(cmd)
with open(output_file, "w") as fp:
fp.write(os.linesep.join(cmd))

@staticmethod
def convert_ipynb(folder: str) -> None:
Expand Down
2 changes: 1 addition & 1 deletion .azure/ipynb-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ jobs:
mkdir $(PATH_DATASETS)
# render the actual notebooks
while IFS= read -r line; do
python .actions/assistant.py bash-render $line > .actions/_ipynb-render.sh
python .actions/assistant.py bash-render $line
cat .actions/_ipynb-render.sh
bash .actions/_ipynb-render.sh
done <<< $(cat changed-folders.txt)
Expand Down
2 changes: 1 addition & 1 deletion .azure/ipynb-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ jobs:
- bash: |
set -e
while IFS= read -r line; do
python .actions/assistant.py bash-test $line > .actions/_ipynb-test.sh
python .actions/assistant.py bash-test $line
cat .actions/_ipynb-test.sh
bash .actions/_ipynb-test.sh
done <<< $(cat changed-folders.txt)
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ jobs:
run: |
while IFS= read -r line; do
python .actions/assistant.py convert-ipynb $line
python .actions/assistant.py bash-render $line > .actions/_ipynb-render.sh
python .actions/assistant.py bash-render $line
cat .actions/_ipynb-render.sh
bash .actions/_ipynb-render.sh
done <<< $(cat changed-folders.txt)
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/ci_testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,9 @@ jobs:
KAGGLE_USERNAME: ${{ secrets.KAGGLE_USERNAME }}
KAGGLE_KEY: ${{ secrets.KAGGLE_KEY }}
run: |
set -e
while IFS= read -r line; do
python .actions/assistant.py bash-test $line > .actions/_ipynb-test.sh
python .actions/assistant.py bash-test $line
cat .actions/_ipynb-test.sh
bash .actions/_ipynb-test.sh
done <<< $(cat changed-folders.txt)
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ ipynb: init ${IPYNB}
%.ipynb: %/.meta.y*ml
@echo $<
python .actions/assistant.py augment-script $(shell dirname $<)
python .actions/assistant.py bash-render $(shell dirname $<) > .actions/_ipynb-render.sh
python .actions/assistant.py bash-render $(shell dirname $<)
bash .actions/_ipynb-render.sh

docs: clean
Expand Down
2 changes: 1 addition & 1 deletion templates/simple/.meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ author: PL team
created: 2021-06-15
updated: 2021-06-17
license: CC
build: 7
build: 8
description: |
This is a template to show how to contribute a tutorial.
requirements:
Expand Down