Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notebook run script #541

Merged
merged 5 commits into from
Jul 19, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
- name: Notebook check
run: |
pip install notebook>=5.2.2
python Otherfiles/notebook_check.py
python Otherfiles/notebook_run.py
if: matrix.python-version == env.TEST_PYTHON_VERSION && matrix.os == env.TEST_OS
- name: Other tests
run: |
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- `__trapezoidal_numeric_integral__` function updated
- Diagrams updated
- Document modified
- Document build system updated
- `AUTHORS.md` updated
- `README.md` modified
- Test system modified
Expand Down
4 changes: 2 additions & 2 deletions Otherfiles/RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

# PyCM Release Instructions

**Last Update: 2024-07-02**
**Last Update: 2024-07-19**

1. Create the `release` branch under `dev`
2. Update all version tags
Expand All @@ -18,7 +18,7 @@
4. Update `.github/ISSUE_TEMPLATE/bug_report.yml`
1. Add new version tag to `PyCM version` dropbox options
5. Update Document
1. Run `Otherfiles/doc_run.bat`
1. Run `Otherfiles/notebook_run.py`
6. Create a PR from `release` to `dev`
1. Title: `Version x.x` (Example: `Version 0.1`)
2. Tag all related issues
Expand Down
17 changes: 0 additions & 17 deletions Otherfiles/doc_run.bat

This file was deleted.

34 changes: 0 additions & 34 deletions Otherfiles/notebook_check.py

This file was deleted.

48 changes: 48 additions & 0 deletions Otherfiles/notebook_run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# -*- coding: utf-8 -*-
"""Notebook-run script."""
import os
import shutil
import pycm
import nbformat
from nbconvert.preprocessors import ExecutePreprocessor
from art import tprint

NOTEBOOKS_LIST = [
"Document",
"Distance",
"Example1",
"Example2",
"Example3",
"Example4",
"Example5",
"Example6",
"Example7",
"Example8"]

COPY_DICT = {os.path.join("Document", "Document_files", "cm1.csv"): os.path.join("Otherfiles", "test.csv"),
os.path.join("Document", "Document_files", "cm1.html"): os.path.join("Otherfiles", "test.html"),
os.path.join("Document", "Document_files", "cm1.obj"): os.path.join("Otherfiles", "test.obj"),
os.path.join("Document", "Document_files", "cm1.pycm"): os.path.join("Otherfiles", "test.pycm"),
os.path.join("Document", "Document_files", "cp.comp"): os.path.join("Otherfiles", "test.comp"),
}

EXTENSION = ".ipynb"

if __name__ == "__main__":
tprint("PYCM", "bulbhead")
tprint("v{0}".format(pycm.__version__), "bulbhead")
tprint("Notebook Run", "amc3line")
print("Processing ...")
for index, notebook in enumerate(NOTEBOOKS_LIST):
ep = ExecutePreprocessor(timeout=6000, kernel_name='python3')
path = os.path.join("Document", notebook)
with open(path + EXTENSION, "r", encoding="utf-8") as f:
nb = nbformat.read(f, as_version=4)
ep.preprocess(nb, {'metadata': {'path': 'Document/'}})
with open(path + EXTENSION, 'w', encoding='utf-8') as f:
nbformat.write(nb, f)
print("\t{0}.{1} [OK]".format(str(index + 1), notebook))
print("\nCopying ...")
for index, item in enumerate(sorted(COPY_DICT)):
shutil.copy(item, COPY_DICT[item])
print("\t{0}.{1} --> {2} [OK]".format(index + 1, item, COPY_DICT[item]))
Loading