From 07ebec329817b9ed59e9bb9e967198814245f3d3 Mon Sep 17 00:00:00 2001 From: jirka Date: Fri, 19 Jul 2024 16:17:31 +0200 Subject: [PATCH 01/16] ci/test: use bare `ipython` instead of `nbval` --- .actions/assistant.py | 8 +++++--- .azure/ipynb-tests.yml | 2 +- .github/workflows/{ci_test-acts.yml => ci_internal.yml} | 0 README.md | 2 +- _requirements/devel.txt | 2 +- course_UvA-DL/01-introduction-to-pytorch/.meta.yml | 1 + .../07-deep-energy-based-generative-models/.meta.yml | 2 +- 7 files changed, 10 insertions(+), 7 deletions(-) rename .github/workflows/{ci_test-acts.yml => ci_internal.yml} (100%) diff --git a/.actions/assistant.py b/.actions/assistant.py index 8439680f8..397f0afe8 100644 --- a/.actions/assistant.py +++ b/.actions/assistant.py @@ -113,7 +113,7 @@ def get_running_cuda_version() -> str: return "" -def get_running_torch_version(): +def get_running_torch_version() -> str: """Extract the version of actual PyTorch for this runtime.""" try: import torch @@ -379,7 +379,7 @@ def bash_test(folder: str, output_file: str = PATH_SCRIPT_TEST) -> Optional[str] cmd.append(f"meta_file=$(python .actions/assistant.py update-env-details {folder} --base_path .)") # show created meta config cmd += ["echo $meta_file", "cat $meta_file"] - cmd.append(f"python -m pytest {ipynb_file} -v --nbval --nbval-cell-timeout=300") + cmd.append(f"jupyter nbconvert --execute {ipynb_file}") else: pub_ipynb = os.path.join(DIR_NOTEBOOKS, f"{folder}.ipynb") pub_meta = pub_ipynb.replace(".ipynb", ".yaml") @@ -707,8 +707,10 @@ def update_env_details(folder: str, base_path: str = DIR_NOTEBOOKS) -> str: Args: folder: path to the folder - base_path: + base_path: base path with notebooks + Returns: + path the updated YAML file """ meta = AssistantCLI._load_meta(folder) # default is COU runtime diff --git a/.azure/ipynb-tests.yml b/.azure/ipynb-tests.yml index 61863bb4b..f32fe4d7a 100644 --- a/.azure/ipynb-tests.yml +++ b/.azure/ipynb-tests.yml @@ -35,7 +35,7 @@ jobs: - bash: echo '$(mtrx.dirs)' | python -m json.tool displayName: "Show matrix" - - job: nbval + - job: ipython dependsOn: check_diff strategy: matrix: $[ dependencies.check_diff.outputs['mtrx.dirs'] ] diff --git a/.github/workflows/ci_test-acts.yml b/.github/workflows/ci_internal.yml similarity index 100% rename from .github/workflows/ci_test-acts.yml rename to .github/workflows/ci_internal.yml diff --git a/README.md b/README.md index 5d8baa460..b8efa3d19 100644 --- a/README.md +++ b/README.md @@ -91,7 +91,7 @@ On the back side of publishing workflow you can find in principle these three st # 1) convert script to notebooks jupytext --set-formats ipynb,py:percent notebook.py -# 2) testing the created notebook +# 2) [OPTIONAL] testing the created notebook pytest -v notebook.ipynb --nbval # 3) generating notebooks outputs diff --git a/_requirements/devel.txt b/_requirements/devel.txt index e0ad0dce6..cff867415 100644 --- a/_requirements/devel.txt +++ b/_requirements/devel.txt @@ -2,5 +2,5 @@ virtualenv>=20.10 jupytext>=1.10, <1.15 # converting pytest>=6.0, <7.0 # testing with own fork with extended cell timeout -https://github.com/Borda/nbval/archive/refs/heads/timeout-limit.zip +# https://github.com/Borda/nbval/archive/refs/heads/timeout-limit.zip papermill>=2.3.4, <2.5.0 # render diff --git a/course_UvA-DL/01-introduction-to-pytorch/.meta.yml b/course_UvA-DL/01-introduction-to-pytorch/.meta.yml index 479f30e90..03dad1cc4 100644 --- a/course_UvA-DL/01-introduction-to-pytorch/.meta.yml +++ b/course_UvA-DL/01-introduction-to-pytorch/.meta.yml @@ -3,6 +3,7 @@ author: Phillip Lippe created: 2021-08-27 updated: 2023-03-14 license: CC BY-SA +build: 1 description: | This tutorial will give a short introduction to PyTorch basics, and get you setup for writing your own neural networks. This notebook is part of a lecture series on Deep Learning at the University of Amsterdam. diff --git a/course_UvA-DL/07-deep-energy-based-generative-models/.meta.yml b/course_UvA-DL/07-deep-energy-based-generative-models/.meta.yml index d3511f6ca..09267982d 100644 --- a/course_UvA-DL/07-deep-energy-based-generative-models/.meta.yml +++ b/course_UvA-DL/07-deep-energy-based-generative-models/.meta.yml @@ -3,7 +3,7 @@ author: Phillip Lippe created: 2021-07-12 updated: 2023-03-14 license: CC BY-SA -build: 0 +build: 1 tags: - Image description: | From fa46c6ac027a028d8b5293de439c5d5fade5d4e0 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 19 Jul 2024 14:19:22 +0000 Subject: [PATCH 02/16] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .actions/assistant.py | 1 + 1 file changed, 1 insertion(+) diff --git a/.actions/assistant.py b/.actions/assistant.py index 397f0afe8..b46bec67b 100644 --- a/.actions/assistant.py +++ b/.actions/assistant.py @@ -711,6 +711,7 @@ def update_env_details(folder: str, base_path: str = DIR_NOTEBOOKS) -> str: Returns: path the updated YAML file + """ meta = AssistantCLI._load_meta(folder) # default is COU runtime From dc33ff526f2802e57ef9bbf7920047bc7b8cb0fd Mon Sep 17 00:00:00 2001 From: jirka Date: Fri, 19 Jul 2024 16:25:12 +0200 Subject: [PATCH 03/16] jupyter --- .actions/assistant.py | 2 +- .azure/ipynb-tests.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.actions/assistant.py b/.actions/assistant.py index 397f0afe8..41565be53 100644 --- a/.actions/assistant.py +++ b/.actions/assistant.py @@ -379,7 +379,7 @@ def bash_test(folder: str, output_file: str = PATH_SCRIPT_TEST) -> Optional[str] cmd.append(f"meta_file=$(python .actions/assistant.py update-env-details {folder} --base_path .)") # show created meta config cmd += ["echo $meta_file", "cat $meta_file"] - cmd.append(f"jupyter nbconvert --execute {ipynb_file}") + cmd.append(f"jupyter execute {ipynb_file}") else: pub_ipynb = os.path.join(DIR_NOTEBOOKS, f"{folder}.ipynb") pub_meta = pub_ipynb.replace(".ipynb", ".yaml") diff --git a/.azure/ipynb-tests.yml b/.azure/ipynb-tests.yml index f32fe4d7a..db726579b 100644 --- a/.azure/ipynb-tests.yml +++ b/.azure/ipynb-tests.yml @@ -96,4 +96,4 @@ jobs: env: KAGGLE_USERNAME: $(KAGGLE_USERNAME) KAGGLE_KEY: $(KAGGLE_KEY) - displayName: "PyTest notebook" + displayName: "Jupyter notebook" From 67fc0027596702b205b429d1d2ab1f6625e321a8 Mon Sep 17 00:00:00 2001 From: jirka Date: Fri, 19 Jul 2024 16:31:56 +0200 Subject: [PATCH 04/16] numpy --- _requirements/default.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/_requirements/default.txt b/_requirements/default.txt index 3d3d8bfb2..99397e2d7 100644 --- a/_requirements/default.txt +++ b/_requirements/default.txt @@ -2,6 +2,7 @@ setuptools>=68.0.0, <69.1.0 matplotlib>=3.0.0, <3.9.0 ipython[notebook]>=8.0.0, <8.17.0 urllib3 # for ipython +numpy # some PT have it missing by default torch>=1.8.1, <2.1.0 pytorch-lightning>=1.4, <2.1.0 torchmetrics>=0.7, <1.3 From 647d36b4c5c8d171f90ae66a2345d32ac4100fd2 Mon Sep 17 00:00:00 2001 From: jirka Date: Fri, 19 Jul 2024 16:37:28 +0200 Subject: [PATCH 05/16] rename --- .azure/{ipynb-tests.yml => ipynb-validate.yml} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename .azure/{ipynb-tests.yml => ipynb-validate.yml} (98%) diff --git a/.azure/ipynb-tests.yml b/.azure/ipynb-validate.yml similarity index 98% rename from .azure/ipynb-tests.yml rename to .azure/ipynb-validate.yml index db726579b..949815a3c 100644 --- a/.azure/ipynb-tests.yml +++ b/.azure/ipynb-validate.yml @@ -96,4 +96,4 @@ jobs: env: KAGGLE_USERNAME: $(KAGGLE_USERNAME) KAGGLE_KEY: $(KAGGLE_KEY) - displayName: "Jupyter notebook" + displayName: "Execute notebook" From 3d15476de6e51e9463e35c885f4d3a6d1c825742 Mon Sep 17 00:00:00 2001 From: jirka Date: Fri, 19 Jul 2024 17:03:02 +0200 Subject: [PATCH 06/16] origin/main HEAD --- .azure/ipynb-validate.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.azure/ipynb-validate.yml b/.azure/ipynb-validate.yml index 949815a3c..798cc36cb 100644 --- a/.azure/ipynb-validate.yml +++ b/.azure/ipynb-validate.yml @@ -19,9 +19,11 @@ jobs: displayName: "Install dependencies" - bash: | - head=$(git rev-parse origin/main) - printf "Head: $head\n" - git diff --name-only $head --output=target-diff.txt + # head=$(git rev-parse origin/main) + # printf "Head: $head\n" # this shall be commit hash + # git diff --name-only $head --output=target-diff.txt + git diff --name-only origin/main HEAD --output=target-diff.txt + cat target-diff.txt python .actions/assistant.py group-folders --fpath_gitdiff=target-diff.txt printf "Changed folders:\n" cat changed-folders.txt From 03d7f532f41adb049d0fb74ab36903c25c2c4b35 Mon Sep 17 00:00:00 2001 From: jirka Date: Fri, 19 Jul 2024 17:06:35 +0200 Subject: [PATCH 07/16] git fetch --all --- .azure/ipynb-validate.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.azure/ipynb-validate.yml b/.azure/ipynb-validate.yml index 798cc36cb..aca27d909 100644 --- a/.azure/ipynb-validate.yml +++ b/.azure/ipynb-validate.yml @@ -19,6 +19,7 @@ jobs: displayName: "Install dependencies" - bash: | + git fetch --all # head=$(git rev-parse origin/main) # printf "Head: $head\n" # this shall be commit hash # git diff --name-only $head --output=target-diff.txt From 0d1c0df8f2ba848e88af31c5c9c2e77fae12aff9 Mon Sep 17 00:00:00 2001 From: jirka Date: Fri, 19 Jul 2024 17:11:25 +0200 Subject: [PATCH 08/16] numpy <2.0 --- _requirements/default.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_requirements/default.txt b/_requirements/default.txt index 99397e2d7..3ea49e720 100644 --- a/_requirements/default.txt +++ b/_requirements/default.txt @@ -2,7 +2,7 @@ setuptools>=68.0.0, <69.1.0 matplotlib>=3.0.0, <3.9.0 ipython[notebook]>=8.0.0, <8.17.0 urllib3 # for ipython -numpy # some PT have it missing by default +numpy <2.0 # needed for older Torch torch>=1.8.1, <2.1.0 pytorch-lightning>=1.4, <2.1.0 torchmetrics>=0.7, <1.3 From 18ad674f0ea768cfad6313804cdee5c66a440362 Mon Sep 17 00:00:00 2001 From: jirka Date: Fri, 19 Jul 2024 17:17:59 +0200 Subject: [PATCH 09/16] format --- .actions/assistant.py | 8 +++++++- .azure/ipynb-validate.yml | 2 +- pyproject.toml | 1 - 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.actions/assistant.py b/.actions/assistant.py index c098f58c1..75d96b76c 100644 --- a/.actions/assistant.py +++ b/.actions/assistant.py @@ -322,7 +322,13 @@ def bash_render(folder: str, output_file: str = PATH_SCRIPT_RENDER) -> Optional[ # dry run does not execute the notebooks just takes them as they are cmd.append(f"cp {ipynb_file} {pub_ipynb}") # copy and add meta config - cmd += [f"cp {meta_file} {pub_meta}", f"cat {pub_meta}", f"git add {pub_meta}"] + cmd += [ + f"cp {meta_file} {pub_meta}", + 'echo "#====== START OF YAML FILE ======#"', + f"cat {pub_meta}", + 'echo "#======= END OF YAML FILE =======#"', + f"git add {pub_meta}", + ] else: pip_req, pip_args = AssistantCLI._parse_requirements(folder) cmd += [f"pip install {pip_req} --quiet {pip_args}", "pip list"] diff --git a/.azure/ipynb-validate.yml b/.azure/ipynb-validate.yml index aca27d909..d0dc2dd47 100644 --- a/.azure/ipynb-validate.yml +++ b/.azure/ipynb-validate.yml @@ -19,7 +19,7 @@ jobs: displayName: "Install dependencies" - bash: | - git fetch --all + git fetch --all # some issues with missing main :/ # head=$(git rev-parse origin/main) # printf "Head: $head\n" # this shall be commit hash # git diff --name-only $head --output=target-diff.txt diff --git a/pyproject.toml b/pyproject.toml index 56d0c2b6e..a0e64ce97 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -85,7 +85,6 @@ ignore = [ # TODO: we shall format all long comments as it comes from text cells "E501", # Line too long ] -ignore-init-module-imports = true [tool.ruff.lint.per-file-ignores] "setup.py" = ["D100", "SIM115"] From 1763092fc4cc71e6f974fecb0a265eaeef1ca681 Mon Sep 17 00:00:00 2001 From: jirka Date: Fri, 19 Jul 2024 17:22:10 +0200 Subject: [PATCH 10/16] PL --- ...{Introduction_to_PyTorch.py => notebook.py} | 0 .../.meta.yml | 2 +- .../{Deep_Energy_Models.py => notebook.py} | 18 +++++++++--------- 3 files changed, 10 insertions(+), 10 deletions(-) rename course_UvA-DL/01-introduction-to-pytorch/{Introduction_to_PyTorch.py => notebook.py} (100%) rename course_UvA-DL/07-deep-energy-based-generative-models/{Deep_Energy_Models.py => notebook.py} (99%) diff --git a/course_UvA-DL/01-introduction-to-pytorch/Introduction_to_PyTorch.py b/course_UvA-DL/01-introduction-to-pytorch/notebook.py similarity index 100% rename from course_UvA-DL/01-introduction-to-pytorch/Introduction_to_PyTorch.py rename to course_UvA-DL/01-introduction-to-pytorch/notebook.py diff --git a/course_UvA-DL/07-deep-energy-based-generative-models/.meta.yml b/course_UvA-DL/07-deep-energy-based-generative-models/.meta.yml index 09267982d..8cbbad49e 100644 --- a/course_UvA-DL/07-deep-energy-based-generative-models/.meta.yml +++ b/course_UvA-DL/07-deep-energy-based-generative-models/.meta.yml @@ -22,7 +22,7 @@ requirements: - torchvision - matplotlib - tensorboard - - lightning>=2.0.0 + - pytorch_lightning>=2.0.0 accelerator: - CPU - GPU diff --git a/course_UvA-DL/07-deep-energy-based-generative-models/Deep_Energy_Models.py b/course_UvA-DL/07-deep-energy-based-generative-models/notebook.py similarity index 99% rename from course_UvA-DL/07-deep-energy-based-generative-models/Deep_Energy_Models.py rename to course_UvA-DL/07-deep-energy-based-generative-models/notebook.py index f4e6d8c77..9a7b9de09 100644 --- a/course_UvA-DL/07-deep-energy-based-generative-models/Deep_Energy_Models.py +++ b/course_UvA-DL/07-deep-energy-based-generative-models/notebook.py @@ -9,9 +9,6 @@ import urllib.request from urllib.error import HTTPError -# PyTorch Lightning -import lightning as L - # Plotting import matplotlib import matplotlib.pyplot as plt @@ -20,6 +17,9 @@ import matplotlib_inline.backend_inline import numpy as np +# PyTorch Lightning +import pytorch_lightning as pl + # PyTorch import torch import torch.nn as nn @@ -28,7 +28,7 @@ # Torchvision import torchvision -from lightning.pytorch.callbacks import Callback, LearningRateMonitor, ModelCheckpoint +from pytorch_lightning.callbacks import Callback, LearningRateMonitor, ModelCheckpoint from torchvision import transforms from torchvision.datasets import MNIST @@ -41,7 +41,7 @@ CHECKPOINT_PATH = os.environ.get("PATH_CHECKPOINT", "saved_models/tutorial8") # Setting the seed -L.seed_everything(42) +pl.seed_everything(42) # Ensure that all operations are deterministic on GPU (if used) for reproducibility torch.backends.cudnn.deterministic = True @@ -465,7 +465,7 @@ def generate_samples(model, inp_imgs, steps=60, step_size=10, return_img_per_ste # %% -class DeepEnergyModel(L.LightningModule): +class DeepEnergyModel(pl.LightningModule): def __init__(self, img_shape, batch_size, alpha=0.1, lr=1e-4, beta1=0.0, **CNN_args): super().__init__() self.save_hyperparameters() @@ -640,7 +640,7 @@ def on_epoch_end(self, trainer, pl_module): # %% def train_model(**kwargs): # Create a PyTorch Lightning trainer with the generation callback - trainer = L.Trainer( + trainer = pl.Trainer( default_root_dir=os.path.join(CHECKPOINT_PATH, "MNIST"), accelerator="auto", devices=1, @@ -660,7 +660,7 @@ def train_model(**kwargs): print("Found pretrained model, loading...") model = DeepEnergyModel.load_from_checkpoint(pretrained_filename) else: - L.seed_everything(42) + pl.seed_everything(42) model = DeepEnergyModel(**kwargs) trainer.fit(model, train_loader, test_loader) model = DeepEnergyModel.load_from_checkpoint(trainer.checkpoint_callback.best_model_path) @@ -709,7 +709,7 @@ def train_model(**kwargs): # %% model.to(device) -L.seed_everything(43) +pl.seed_everything(43) callback = GenerateCallback(batch_size=4, vis_steps=8, num_steps=256) imgs_per_step = callback.generate_imgs(model) imgs_per_step = imgs_per_step.cpu() From 570c889eb63a0b57b0b15997534feabbc26aa7df Mon Sep 17 00:00:00 2001 From: jirka Date: Fri, 19 Jul 2024 17:26:54 +0200 Subject: [PATCH 11/16] pytorch-lightning --- course_UvA-DL/07-deep-energy-based-generative-models/.meta.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/course_UvA-DL/07-deep-energy-based-generative-models/.meta.yml b/course_UvA-DL/07-deep-energy-based-generative-models/.meta.yml index 8cbbad49e..c86b83169 100644 --- a/course_UvA-DL/07-deep-energy-based-generative-models/.meta.yml +++ b/course_UvA-DL/07-deep-energy-based-generative-models/.meta.yml @@ -22,7 +22,7 @@ requirements: - torchvision - matplotlib - tensorboard - - pytorch_lightning>=2.0.0 + - pytorch-lightning>=2.0.0 accelerator: - CPU - GPU From 0cc0cc4792e89f77f055f9e530564bc4e04f4f6f Mon Sep 17 00:00:00 2001 From: jirka Date: Fri, 19 Jul 2024 18:18:32 +0200 Subject: [PATCH 12/16] --inplace --- .actions/assistant.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/.actions/assistant.py b/.actions/assistant.py index 75d96b76c..95c05bdc3 100644 --- a/.actions/assistant.py +++ b/.actions/assistant.py @@ -341,7 +341,13 @@ def bash_render(folder: str, output_file: str = PATH_SCRIPT_RENDER) -> Optional[ # Export the actual packages used in runtime cmd.append(f"meta_file=$(python .actions/assistant.py update-env-details {folder})") # copy and add to version the enriched meta config - cmd += ["echo $meta_file", "cat $meta_file", "git add $meta_file"] + cmd += [ + "echo $meta_file", + 'echo "#====== START OF YAML FILE ======#"', + "cat $meta_file", + 'echo "#======= END OF YAML FILE =======#"', + "git add $meta_file", + ] # if thumb image is linked to the notebook, copy and version it too if thumb_file: cmd += [f"cp {thumb_file} {pub_thumb}", f"git add {pub_thumb}"] @@ -384,8 +390,13 @@ def bash_test(folder: str, output_file: str = PATH_SCRIPT_TEST) -> Optional[str] # Export the actual packages used in runtime cmd.append(f"meta_file=$(python .actions/assistant.py update-env-details {folder} --base_path .)") # show created meta config - cmd += ["echo $meta_file", "cat $meta_file"] - cmd.append(f"jupyter execute {ipynb_file}") + cmd += [ + "echo $meta_file", + 'echo "#====== START OF YAML FILE ======#"', + "cat $meta_file", + 'echo "#======= END OF YAML FILE =======#"', + ] + cmd.append(f"jupyter execute {ipynb_file} --inplace") else: pub_ipynb = os.path.join(DIR_NOTEBOOKS, f"{folder}.ipynb") pub_meta = pub_ipynb.replace(".ipynb", ".yaml") @@ -393,7 +404,9 @@ def bash_test(folder: str, output_file: str = PATH_SCRIPT_TEST) -> Optional[str] cmd += [ f"mkdir -p {os.path.dirname(pub_meta)}", f"cp {meta_file} {pub_meta}", + 'echo "#====== START OF YAML FILE ======#"', f"cat {pub_meta}", + 'echo "#======= END OF YAML FILE =======#"', f"git add {pub_meta}", ] warn("Invalid notebook's accelerator for this device. So no tests will be run!!!", RuntimeWarning) From 403c769ea5d9a073439764220f94d40311d8c3fa Mon Sep 17 00:00:00 2001 From: jirka Date: Fri, 19 Jul 2024 18:25:56 +0200 Subject: [PATCH 13/16] virtualenv --- .actions/assistant.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/.actions/assistant.py b/.actions/assistant.py index 95c05bdc3..4e979ab4e 100644 --- a/.actions/assistant.py +++ b/.actions/assistant.py @@ -359,7 +359,7 @@ def bash_render(folder: str, output_file: str = PATH_SCRIPT_RENDER) -> Optional[ fopen.write(os.linesep.join(cmd)) @staticmethod - def bash_test(folder: str, output_file: str = PATH_SCRIPT_TEST) -> Optional[str]: + def bash_test(folder: str, output_file: str = PATH_SCRIPT_TEST, virtualenv: bool = False) -> Optional[str]: """Prepare bash script for running tests of a particular notebook. Args: @@ -376,11 +376,12 @@ def bash_test(folder: str, output_file: str = PATH_SCRIPT_TEST) -> Optional[str] # prepare isolated environment with inheriting the global packages path_venv = os.path.join(folder, "venv") - cmd += [ - f"python -m virtualenv --system-site-packages {path_venv}", - f"source {os.path.join(path_venv, 'bin', 'activate')}", - "pip --version", - ] + if virtualenv: + cmd += [ + f"python -m virtualenv --system-site-packages {path_venv}", + f"source {os.path.join(path_venv, 'bin', 'activate')}", + "pip --version", + ] cmd.append(f"# available: {AssistantCLI.DEVICE_ACCELERATOR}") if AssistantCLI._valid_accelerator(folder): @@ -411,7 +412,8 @@ def bash_test(folder: str, output_file: str = PATH_SCRIPT_TEST) -> Optional[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')}"] + if virtualenv: + cmd += ["deactivate", f"rm -rf {os.path.join(folder, 'venv')}"] if not output_file: return os.linesep.join(cmd) with open(output_file, "w") as fopen: From a35969e901f05d2e6553394c83d3d339fed78de1 Mon Sep 17 00:00:00 2001 From: jirka Date: Fri, 19 Jul 2024 18:35:25 +0200 Subject: [PATCH 14/16] format --- .../07-deep-energy-based-generative-models/notebook.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/course_UvA-DL/07-deep-energy-based-generative-models/notebook.py b/course_UvA-DL/07-deep-energy-based-generative-models/notebook.py index 9a7b9de09..7df72cbbe 100644 --- a/course_UvA-DL/07-deep-energy-based-generative-models/notebook.py +++ b/course_UvA-DL/07-deep-energy-based-generative-models/notebook.py @@ -770,7 +770,7 @@ def train_model(**kwargs): rand_imgs = torch.rand((128,) + model.hparams.img_shape).to(model.device) rand_imgs = rand_imgs * 2 - 1.0 rand_out = model.cnn(rand_imgs).mean() - print(f"Average score for random images: {rand_out.item():4.2f}") + print(f"Average score for random images: {rand_out.item()}") # %% [markdown] # As we hoped, the model assigns very low probability to those noisy images. @@ -803,8 +803,8 @@ def compare_images(img1, img2): plt.xticks([(img1.shape[2] + 2) * (0.5 + j) for j in range(2)], labels=["Original image", "Transformed image"]) plt.yticks([]) plt.show() - print(f"Score original image: {score1:4.2f}") - print(f"Score transformed image: {score2:4.2f}") + print(f"Score original image: {score1}") + print(f"Score transformed image: {score2}") # %% [markdown] From caf6d32aab4bea749660bdd18be22c7e549fddc6 Mon Sep 17 00:00:00 2001 From: Jirka Borovec <6035284+Borda@users.noreply.github.com> Date: Fri, 19 Jul 2024 18:45:57 +0200 Subject: [PATCH 15/16] Apply suggestions from code review --- .actions/assistant.py | 1 + 1 file changed, 1 insertion(+) diff --git a/.actions/assistant.py b/.actions/assistant.py index 4e979ab4e..32e8a3b6f 100644 --- a/.actions/assistant.py +++ b/.actions/assistant.py @@ -397,6 +397,7 @@ def bash_test(folder: str, output_file: str = PATH_SCRIPT_TEST, virtualenv: bool "cat $meta_file", 'echo "#======= END OF YAML FILE =======#"', ] + # use standard jupyter's executable via CMD cmd.append(f"jupyter execute {ipynb_file} --inplace") else: pub_ipynb = os.path.join(DIR_NOTEBOOKS, f"{folder}.ipynb") From 54196f307b0b14c0c7cf98978a10161e89e74fff Mon Sep 17 00:00:00 2001 From: jirka Date: Fri, 19 Jul 2024 18:46:47 +0200 Subject: [PATCH 16/16] badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b8efa3d19..a5ee506fa 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # PytorchLightning Tutorials -[![CI internal](https://github.com/Lightning-AI/tutorials/actions/workflows/ci_test-acts.yml/badge.svg?event=push)](https://github.com/Lightning-AI/tutorials/actions/workflows/ci_test-acts.yml) +[![CI internal](https://github.com/Lightning-AI/tutorials/actions/workflows/ci_internal.yml/badge.svg?event=push)](https://github.com/Lightning-AI/tutorials/actions/workflows/ci_internal.yml) [![Build Status](https://dev.azure.com/Lightning-AI/Tutorials/_apis/build/status/Lightning-AI.tutorials%20%5Bpublish%5D?branchName=main)](https://dev.azure.com/Lightning-AI/Tutorials/_build/latest?definitionId=29&branchName=main) [![codecov](https://codecov.io/gh/Lightning-AI/tutorials/branch/main/graph/badge.svg?token=C6T3XOOR56)](https://codecov.io/gh/Lightning-AI/tutorials) [![Deploy Docs](https://github.com/Lightning-AI/tutorials/actions/workflows/docs-deploy.yml/badge.svg)](https://github.com/Lightning-AI/tutorials/actions/workflows/docs-deploy.yml)