Skip to content

Commit 796840b

Browse files
Refactor: simplify scripts (#119)
* simplify CLI * drop CI/pep8 * fix vars * bash render * bash generate * bash test * prune Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 5dd7b1c commit 796840b

14 files changed

+210
-275
lines changed

.actions/assistant.py

+184-108
Large diffs are not rendered by default.

.actions/ipynb-generate.sh

-17
This file was deleted.

.actions/ipynb-render.sh

-76
This file was deleted.

.actions/ipynb-test.sh

-43
This file was deleted.

.azure-pipelines/ipynb-publish.yml

+4-2
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,17 @@ jobs:
9090
9191
- bash: |
9292
while IFS= read -r line; do
93-
bash .actions/ipynb-generate.sh $line
93+
python .actions/assistant.py augment-script $line
9494
done <<< $(cat changed-folders.txt)
9595
condition: gt(variables['changed.folders'], 0)
9696
displayName: 'Generate notebook'
9797
9898
- bash: |
9999
# render the actual notebooks
100100
while IFS= read -r line; do
101-
bash .actions/ipynb-render.sh $line
101+
python .actions/assistant.py bash-render $line > .actions/_ipynb-render.sh
102+
cat .actions/_ipynb-render.sh
103+
bash .actions/_ipynb-render.sh
102104
done <<< $(cat changed-folders.txt)
103105
git status
104106
git commit -m "publish [GPU]: $(COMMIT_HASH)"

.azure-pipelines/ipynb-tests.yml

+4-2
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,16 @@ jobs:
7272

7373
- bash: |
7474
while IFS= read -r line; do
75-
bash .actions/ipynb-generate.sh $line
75+
python .actions/assistant.py augment-script $line
7676
done <<< $(cat changed-folders.txt)
7777
condition: gt(variables['changed.folders'], 0)
7878
displayName: 'Generate notebook'
7979
8080
- bash: |
8181
while IFS= read -r line; do
82-
bash .actions/ipynb-test.sh $line
82+
python .actions/assistant.py bash-test $line > .actions/_ipynb-test.sh
83+
cat .actions/_ipynb-test.sh
84+
bash .actions/_ipynb-test.sh
8385
done <<< $(cat changed-folders.txt)
8486
condition: and(succeeded(), gt(variables['changed.folders'], 0))
8587
displayName: 'PyTest notebook'

.github/workflows/ci_code-format.yml

-14
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,6 @@ on: # Trigger the workflow on push or pull request, but only for the main branc
1010
pull_request: {}
1111

1212
jobs:
13-
pep8-check-flake8:
14-
runs-on: ubuntu-20.04
15-
steps:
16-
- uses: actions/checkout@master
17-
- uses: actions/setup-python@v2
18-
with:
19-
python-version: 3.7
20-
- name: Install dependencies
21-
run: pip install flake8 && pip list
22-
shell: bash
23-
- name: PEP8
24-
run: |
25-
flake8 .
26-
2713
pre-commit-check:
2814
runs-on: ubuntu-latest
2915
steps:

.github/workflows/ci_docs.yml

+4-2
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,10 @@ jobs:
6060
if: steps.changed.outputs.dirs != 0
6161
run: |
6262
while IFS= read -r line; do
63-
bash .actions/ipynb-generate.sh $line
64-
bash .actions/ipynb-render.sh $line
63+
python .actions/assistant.py augment-script $line
64+
python .actions/assistant.py bash-render $line > .actions/_ipynb-render.sh
65+
cat .actions/_ipynb-render.sh
66+
bash .actions/_ipynb-render.sh
6567
done <<< $(cat changed-folders.txt)
6668
env:
6769
DRY_RUN: 1

.github/workflows/ci_testing.yml

+4-2
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,16 @@ jobs:
7070
if: steps.changed.outputs.dirs != 0
7171
run: |
7272
while IFS= read -r line; do
73-
bash .actions/ipynb-generate.sh $line
73+
python .actions/assistant.py augment-script $line
7474
done <<< $(cat changed-folders.txt)
7575
shell: bash
7676

7777
- name: PyTest notebook
7878
if: success() && steps.changed.outputs.dirs != 0
7979
run: |
8080
while IFS= read -r line; do
81-
bash .actions/ipynb-test.sh $line
81+
python .actions/assistant.py bash-test $line > .actions/_ipynb-test.sh
82+
cat .actions/_ipynb-test.sh
83+
bash .actions/_ipynb-test.sh
8284
done <<< $(cat changed-folders.txt)
8385
shell: bash

.pre-commit-config.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ repos:
6060
- mdformat-black
6161
- mdformat_frontmatter
6262

63-
# - repo: https://github.com/PyCQA/flake8
64-
# rev: 3.9.2
65-
# hooks:
66-
# - id: flake8
63+
- repo: https://github.com/PyCQA/flake8
64+
rev: 3.9.2
65+
hooks:
66+
- id: flake8

Makefile

+3-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ ipynb: init ${IPYNB}
1515

1616
%.ipynb: %/.meta.y*ml
1717
@echo $<
18-
bash .actions/ipynb-generate.sh $(shell dirname $<)
19-
bash .actions/ipynb-render.sh $(shell dirname $<)
18+
python .actions/assistant.py augment-script $(shell dirname $<)
19+
python .actions/assistant.py bash-render $(shell dirname $<) > .actions/_ipynb-render.sh
20+
bash .actions/_ipynb-render.sh
2021

2122
docs: clean
2223
pip install --quiet -r docs/requirements.txt

docs/source/conf.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
sys.path.insert(0, os.path.abspath(_PATH_ROOT))
2121
sys.path.append(os.path.join(_PATH_ROOT, ".actions"))
2222

23-
from helpers import HelperCLI # noqa: E402
23+
from assistant import AssistantCLI # noqa: E402
2424

2525
# -- Project information -----------------------------------------------------
2626

@@ -42,7 +42,7 @@
4242

4343
# -- Project documents -------------------------------------------------------
4444

45-
HelperCLI.copy_notebooks(_PATH_ROOT, _PATH_HERE)
45+
AssistantCLI.copy_notebooks(_PATH_ROOT, _PATH_HERE)
4646

4747
# with open(os.path.join(_PATH_HERE, 'ipynb_content.rst'), 'w') as fp:
4848
# fp.write(os.linesep.join(ipynb_content))

sample-template/.meta.yml

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

sample-template/.thumb.png

19.8 KB
Loading

0 commit comments

Comments
 (0)