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

Commit dccda32

Browse files
authored
ci: use script outputs (#157)
* set output file * ci: update
1 parent c257c46 commit dccda32

File tree

7 files changed

+21
-10
lines changed

7 files changed

+21
-10
lines changed

.actions/assistant.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
_PATH_HERE = os.path.dirname(__file__)
1919
_PATH_ROOT = os.path.dirname(_PATH_HERE)
2020
PATH_REQ_DEFAULT = os.path.join(_PATH_ROOT, "requirements", "default.txt")
21+
PATH_SCRIPT_RENDER = os.path.join(_PATH_HERE, "_ipynb-render.sh")
22+
PATH_SCRIPT_TEST = os.path.join(_PATH_HERE, "_ipynb-test.sh")
2123
REPO_NAME = "lightning-tutorials"
2224
COLAB_REPO_LINK = "https://colab.research.google.com/github/PytorchLightning"
2325
BRANCH_DEFAULT = "main"
@@ -293,11 +295,12 @@ def _bash_download_data(folder: str) -> List[str]:
293295
return cmd
294296

295297
@staticmethod
296-
def bash_render(folder: str) -> str:
298+
def bash_render(folder: str, output_file: str = PATH_SCRIPT_RENDER) -> Optional[str]:
297299
"""Prepare bash script for running rendering of a particular notebook.
298300
299301
Args:
300302
folder: name/path to a folder with notebook files
303+
output_file: if defined, stream the commands to the file
301304
302305
Returns:
303306
string with nash script content
@@ -332,14 +335,18 @@ def bash_render(folder: str) -> str:
332335
cmd += [f"cp {thumb_file} {pub_thumb}", f"git add {pub_thumb}"]
333336
# add the generated notebook to version
334337
cmd.append(f"git add {pub_ipynb}")
335-
return os.linesep.join(cmd)
338+
if not output_file:
339+
return os.linesep.join(cmd)
340+
with open(output_file, "w") as fp:
341+
fp.write(os.linesep.join(cmd))
336342

337343
@staticmethod
338-
def bash_test(folder: str) -> str:
344+
def bash_test(folder: str, output_file: str = PATH_SCRIPT_TEST) -> Optional[str]:
339345
"""Prepare bash script for running tests of a particular notebook.
340346
341347
Args:
342348
folder: name/path to a folder with notebook files
349+
output_file: if defined, stream the commands to the file
343350
344351
Returns:
345352
string with nash script content
@@ -369,7 +376,10 @@ def bash_test(folder: str) -> str:
369376
warn("Invalid notebook's accelerator for this device. So no tests will be run!!!", RuntimeWarning)
370377
# deactivate and clean local environment
371378
cmd += ["deactivate", f"rm -rf {os.path.join(folder, 'venv')}"]
372-
return os.linesep.join(cmd)
379+
if not output_file:
380+
return os.linesep.join(cmd)
381+
with open(output_file, "w") as fp:
382+
fp.write(os.linesep.join(cmd))
373383

374384
@staticmethod
375385
def convert_ipynb(folder: str) -> None:

.azure/ipynb-publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ jobs:
105105
mkdir $(PATH_DATASETS)
106106
# render the actual notebooks
107107
while IFS= read -r line; do
108-
python .actions/assistant.py bash-render $line > .actions/_ipynb-render.sh
108+
python .actions/assistant.py bash-render $line
109109
cat .actions/_ipynb-render.sh
110110
bash .actions/_ipynb-render.sh
111111
done <<< $(cat changed-folders.txt)

.azure/ipynb-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ jobs:
7979
- bash: |
8080
set -e
8181
while IFS= read -r line; do
82-
python .actions/assistant.py bash-test $line > .actions/_ipynb-test.sh
82+
python .actions/assistant.py bash-test $line
8383
cat .actions/_ipynb-test.sh
8484
bash .actions/_ipynb-test.sh
8585
done <<< $(cat changed-folders.txt)

.github/workflows/ci_docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ jobs:
7373
run: |
7474
while IFS= read -r line; do
7575
python .actions/assistant.py convert-ipynb $line
76-
python .actions/assistant.py bash-render $line > .actions/_ipynb-render.sh
76+
python .actions/assistant.py bash-render $line
7777
cat .actions/_ipynb-render.sh
7878
bash .actions/_ipynb-render.sh
7979
done <<< $(cat changed-folders.txt)

.github/workflows/ci_testing.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,9 @@ jobs:
7474
KAGGLE_USERNAME: ${{ secrets.KAGGLE_USERNAME }}
7575
KAGGLE_KEY: ${{ secrets.KAGGLE_KEY }}
7676
run: |
77+
set -e
7778
while IFS= read -r line; do
78-
python .actions/assistant.py bash-test $line > .actions/_ipynb-test.sh
79+
python .actions/assistant.py bash-test $line
7980
cat .actions/_ipynb-test.sh
8081
bash .actions/_ipynb-test.sh
8182
done <<< $(cat changed-folders.txt)

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ ipynb: init ${IPYNB}
1616
%.ipynb: %/.meta.y*ml
1717
@echo $<
1818
python .actions/assistant.py augment-script $(shell dirname $<)
19-
python .actions/assistant.py bash-render $(shell dirname $<) > .actions/_ipynb-render.sh
19+
python .actions/assistant.py bash-render $(shell dirname $<)
2020
bash .actions/_ipynb-render.sh
2121

2222
docs: clean

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: 7
6+
build: 8
77
description: |
88
This is a template to show how to contribute a tutorial.
99
requirements:

0 commit comments

Comments
 (0)