From 633176ebf629d152875098b8f03cf7f4530af73e Mon Sep 17 00:00:00 2001 From: Fabio Seel Date: Mon, 7 Oct 2024 17:42:02 +0200 Subject: [PATCH 01/49] feat: add ci pipeline [experimental] --- .github/workflows/pylint.yml | 18 ++++++++++++++++++ resources/retinal-rl.def | 3 +++ 2 files changed, 21 insertions(+) create mode 100644 .github/workflows/pylint.yml diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml new file mode 100644 index 0000000..c4e9c21 --- /dev/null +++ b/.github/workflows/pylint.yml @@ -0,0 +1,18 @@ +name: Pylint + +on: [push, pull_request] + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: eWaterCycle/setup-apptainer@v2 + with: + apptainer-version: 1.3.0 + + - name: Build Singularity container + run: apptainer build retinal-rl.sif resources/retinal-rl.def + + - name: Run Pylint + run: singularity exec retinal-rl.sif pylint $(git diff --name-only origin/master origin/feat-ci-pipeline -- '*.py') diff --git a/resources/retinal-rl.def b/resources/retinal-rl.def index 6aef984..71ca034 100644 --- a/resources/retinal-rl.def +++ b/resources/retinal-rl.def @@ -59,3 +59,6 @@ From: nvidia/cuda:11.7.1-runtime-ubuntu22.04 # retinal-rl Extra pip3 install gymnasium==0.28.1 torch==1.13.1 vizdoom==1.2.0 torchvision==0.14.1 matplotlib opentsne pygame pycairo git+https://github.com/pytorch/captum.git torchscan num2words hiyapyco omgifol git+https://github.com/alex404/sample-factory.git@fix-vtrace dpcpp-cpp-rt seaborn hydra-core networkx + + # install CI related dependencies + pip3 install pylint From 6208c69ea20f70151e0fc4867347815ac52deed4 Mon Sep 17 00:00:00 2001 From: Fabio Seel Date: Tue, 8 Oct 2024 11:00:32 +0200 Subject: [PATCH 02/49] fix: fixed pycairo version in singularity def file --- resources/retinal-rl.def | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/retinal-rl.def b/resources/retinal-rl.def index 71ca034..4f6ddf7 100644 --- a/resources/retinal-rl.def +++ b/resources/retinal-rl.def @@ -58,7 +58,7 @@ From: nvidia/cuda:11.7.1-runtime-ubuntu22.04 # retinal-rl Extra - pip3 install gymnasium==0.28.1 torch==1.13.1 vizdoom==1.2.0 torchvision==0.14.1 matplotlib opentsne pygame pycairo git+https://github.com/pytorch/captum.git torchscan num2words hiyapyco omgifol git+https://github.com/alex404/sample-factory.git@fix-vtrace dpcpp-cpp-rt seaborn hydra-core networkx + pip3 install gymnasium==0.28.1 torch==1.13.1 vizdoom==1.2.0 torchvision==0.14.1 matplotlib opentsne pygame pycairo==1.26.1 git+https://github.com/pytorch/captum.git torchscan num2words hiyapyco omgifol git+https://github.com/alex404/sample-factory.git@fix-vtrace dpcpp-cpp-rt seaborn hydra-core networkx # install CI related dependencies pip3 install pylint From d4840d8a2a06657fb3cade8b22099219e79b9ddb Mon Sep 17 00:00:00 2001 From: Fabio Seel Date: Tue, 8 Oct 2024 15:44:38 +0200 Subject: [PATCH 03/49] perf: reduce size of singularity container --- resources/retinal-rl.def | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/resources/retinal-rl.def b/resources/retinal-rl.def index 4f6ddf7..c6be54a 100644 --- a/resources/retinal-rl.def +++ b/resources/retinal-rl.def @@ -58,7 +58,10 @@ From: nvidia/cuda:11.7.1-runtime-ubuntu22.04 # retinal-rl Extra - pip3 install gymnasium==0.28.1 torch==1.13.1 vizdoom==1.2.0 torchvision==0.14.1 matplotlib opentsne pygame pycairo==1.26.1 git+https://github.com/pytorch/captum.git torchscan num2words hiyapyco omgifol git+https://github.com/alex404/sample-factory.git@fix-vtrace dpcpp-cpp-rt seaborn hydra-core networkx - - # install CI related dependencies - pip3 install pylint + pip3 install --no-cache-dir gymnasium==0.28.1 torch==1.13.1 vizdoom==1.2.0 torchvision==0.14.1 matplotlib opentsne pygame pycairo==1.26.1 git+https://github.com/pytorch/captum.git torchscan num2words hiyapyco omgifol git+https://github.com/alex404/sample-factory.git@fix-vtrace dpcpp-cpp-rt seaborn hydra-core networkx pylint + + # Clean up for smaller container size + rm acc159linux-x64.zip + apt clean + rm -rf /var/lib/apt/lists/* + rm -rf /root/.cache/pip \ No newline at end of file From b57fbc15d2196215505fa011a993eeecdcb582a5 Mon Sep 17 00:00:00 2001 From: Fabio Seel Date: Tue, 8 Oct 2024 15:58:34 +0200 Subject: [PATCH 04/49] fix: replace container build with pull --- .github/workflows/pylint.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index c4e9c21..cb20372 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -11,8 +11,8 @@ jobs: with: apptainer-version: 1.3.0 - - name: Build Singularity container - run: apptainer build retinal-rl.sif resources/retinal-rl.def + - name: Pulling Singularity container + run: singularity pull retinal-rl.sif library://fabioseel/retinal-rl/default - name: Run Pylint run: singularity exec retinal-rl.sif pylint $(git diff --name-only origin/master origin/feat-ci-pipeline -- '*.py') From 50940c751ffa2cafc329e3388acc4a2cd6abf961 Mon Sep 17 00:00:00 2001 From: Fabio Seel Date: Tue, 8 Oct 2024 17:25:04 +0200 Subject: [PATCH 05/49] fix(?): move singularity image to github / ghcr.io --- .github/workflows/pylint.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index cb20372..d3b7579 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -12,7 +12,7 @@ jobs: apptainer-version: 1.3.0 - name: Pulling Singularity container - run: singularity pull retinal-rl.sif library://fabioseel/retinal-rl/default + run: singularity pull oras://ghcr.io/berenslab/retinal-rl:singularity-latest - name: Run Pylint - run: singularity exec retinal-rl.sif pylint $(git diff --name-only origin/master origin/feat-ci-pipeline -- '*.py') + run: singularity exec retinal-rl_singularity-image-latest.sif pylint $(git diff --name-only origin/master origin/feat-ci-pipeline -- '*.py') From 1e2c6fa0eb5c8123d58e4bfcbc136b62d3147fea Mon Sep 17 00:00:00 2001 From: Fabio Seel Date: Tue, 8 Oct 2024 17:32:51 +0200 Subject: [PATCH 06/49] fix(?): add auto login credentials to workflow --- .github/workflows/pylint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index d3b7579..5f79a69 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -12,7 +12,7 @@ jobs: apptainer-version: 1.3.0 - name: Pulling Singularity container - run: singularity pull oras://ghcr.io/berenslab/retinal-rl:singularity-latest + run: singularity remote login --username ${{ github.actor }} --password ${{ secrets.GITHUB_TOKEN }} ghcr.io; singularity pull oras://ghcr.io/berenslab/retinal-rl:singularity-latest - name: Run Pylint run: singularity exec retinal-rl_singularity-image-latest.sif pylint $(git diff --name-only origin/master origin/feat-ci-pipeline -- '*.py') From c5e133d0a746d3db69597e198fd5b3170e6c4f9b Mon Sep 17 00:00:00 2001 From: Fabio Seel Date: Tue, 8 Oct 2024 17:34:37 +0200 Subject: [PATCH 07/49] fix(?): try fixing the auto login --- .github/workflows/pylint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index 5f79a69..475d26b 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -12,7 +12,7 @@ jobs: apptainer-version: 1.3.0 - name: Pulling Singularity container - run: singularity remote login --username ${{ github.actor }} --password ${{ secrets.GITHUB_TOKEN }} ghcr.io; singularity pull oras://ghcr.io/berenslab/retinal-rl:singularity-latest + run: singularity registry login --username ${{ github.actor }} --password ${{ secrets.GITHUB_TOKEN }} oras://ghcr.io; singularity pull oras://ghcr.io/berenslab/retinal-rl:singularity-latest - name: Run Pylint run: singularity exec retinal-rl_singularity-image-latest.sif pylint $(git diff --name-only origin/master origin/feat-ci-pipeline -- '*.py') From 0fe89829957a1a9b5046e08a658bb62af4e5b84d Mon Sep 17 00:00:00 2001 From: Fabio Seel Date: Tue, 8 Oct 2024 17:38:25 +0200 Subject: [PATCH 08/49] fix(?): typo in package name for singularity container in workflow --- .github/workflows/pylint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index 475d26b..3b30f4a 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -12,7 +12,7 @@ jobs: apptainer-version: 1.3.0 - name: Pulling Singularity container - run: singularity registry login --username ${{ github.actor }} --password ${{ secrets.GITHUB_TOKEN }} oras://ghcr.io; singularity pull oras://ghcr.io/berenslab/retinal-rl:singularity-latest + run: singularity registry login --username ${{ github.actor }} --password ${{ secrets.GITHUB_TOKEN }} oras://ghcr.io; singularity pull oras://ghcr.io/berenslab/retinal-rl:singularity-image-latest - name: Run Pylint run: singularity exec retinal-rl_singularity-image-latest.sif pylint $(git diff --name-only origin/master origin/feat-ci-pipeline -- '*.py') From e592feb55b2849cb3ca8a910eb0060e38a8cff6e Mon Sep 17 00:00:00 2001 From: Fabio Seel Date: Wed, 9 Oct 2024 09:58:24 +0200 Subject: [PATCH 09/49] fix(?): pylint to all files instead of just changed (for now) --- .github/workflows/pylint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index 3b30f4a..ec2548d 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -15,4 +15,4 @@ jobs: run: singularity registry login --username ${{ github.actor }} --password ${{ secrets.GITHUB_TOKEN }} oras://ghcr.io; singularity pull oras://ghcr.io/berenslab/retinal-rl:singularity-image-latest - name: Run Pylint - run: singularity exec retinal-rl_singularity-image-latest.sif pylint $(git diff --name-only origin/master origin/feat-ci-pipeline -- '*.py') + run: singularity exec retinal-rl_singularity-image-latest.sif pylint . #$(git diff --name-only origin/master origin/feat-ci-pipeline -- '*.py') From f7f9b49ba2d7da6085a95bf6a07625adf6bcaa42 Mon Sep 17 00:00:00 2001 From: Fabio Seel Date: Wed, 9 Oct 2024 10:58:18 +0200 Subject: [PATCH 10/49] chore: try bumping checkout action version to v4 --- .github/workflows/pylint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index ec2548d..c63f94c 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -6,7 +6,7 @@ jobs: lint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: eWaterCycle/setup-apptainer@v2 with: apptainer-version: 1.3.0 From 550e0a197f78560f9ffdea607a4142a2b4d0e2f5 Mon Sep 17 00:00:00 2001 From: Fabio Seel Date: Wed, 9 Oct 2024 14:46:28 +0200 Subject: [PATCH 11/49] fix: update example cfgs --- ...assifier.yaml => shallow-autoencoder.yaml} | 20 ++++---- ...r10-large.yaml => cifar10-decontrast.yaml} | 6 +-- .../user/experiment/cifar10-class-recon.yaml | 29 ++++++------ .../user/optimizer/class-recon.yaml | 46 ------------------- .../user/optimizer/recon-weight.yaml | 45 ++++++++++++++++++ 5 files changed, 70 insertions(+), 76 deletions(-) rename resources/config_templates/user/brain/{retinal-classifier.yaml => shallow-autoencoder.yaml} (88%) rename resources/config_templates/user/dataset/{cifar10-large.yaml => cifar10-decontrast.yaml} (77%) delete mode 100644 resources/config_templates/user/optimizer/class-recon.yaml create mode 100644 resources/config_templates/user/optimizer/recon-weight.yaml diff --git a/resources/config_templates/user/brain/retinal-classifier.yaml b/resources/config_templates/user/brain/shallow-autoencoder.yaml similarity index 88% rename from resources/config_templates/user/brain/retinal-classifier.yaml rename to resources/config_templates/user/brain/shallow-autoencoder.yaml index 1d65923..3cf4fc7 100644 --- a/resources/config_templates/user/brain/retinal-classifier.yaml +++ b/resources/config_templates/user/brain/shallow-autoencoder.yaml @@ -24,8 +24,8 @@ circuits: _target_: retinal_rl.models.circuits.convolutional.ConvolutionalEncoder num_layers: 2 num_channels: [16,32] # Two layers with 16 and 32 channels - kernel_size: ${kernel_size} - stride: ${stride} + kernel_size: 8 + stride: 2 act_name: ${activation} layer_names: ["bipolar", "retinal_ganglion"] # Names inspired by retinal cell types @@ -34,8 +34,8 @@ circuits: _target_: retinal_rl.models.circuits.convolutional.ConvolutionalEncoder num_layers: 1 num_channels: 64 - kernel_size: ${kernel_size} - stride: ${stride} + kernel_size: 5 + stride: 1 act_name: ${activation} layer_names: ["lgn"] # Lateral Geniculate Nucleus @@ -44,8 +44,8 @@ circuits: _target_: retinal_rl.models.circuits.convolutional.ConvolutionalEncoder num_layers: 1 num_channels: 64 - kernel_size: ${kernel_size} - stride: ${stride} + kernel_size: 8 + stride: 2 act_name: ${activation} layer_names: ["v1"] # Primary Visual Cortex @@ -53,9 +53,9 @@ circuits: pfc: _target_: retinal_rl.models.circuits.fully_connected.FullyConnectedEncoder output_shape: - - ${latent_size} # Size of the latent representation + - 128 # Size of the latent representation hidden_units: - - ${hidden_units} # Number of hidden units + - 64 # Number of hidden units act_name: ${activation} # Decoder: for reconstructing the input from the latent representation @@ -63,8 +63,8 @@ circuits: _target_: retinal_rl.models.circuits.convolutional.ConvolutionalDecoder num_layers: 3 num_channels: [32,16,3] # For a symmetric encoder, this should be the reverse of the num_channels in the CNN layers up to the point of decoding (in this case, the thalamus) - kernel_size: ${kernel_size} - stride: ${stride} + kernel_size: [5,8,8] + stride: [1,2,2] act_name: ${activation} # Classifier: for categorizing the input into classes diff --git a/resources/config_templates/user/dataset/cifar10-large.yaml b/resources/config_templates/user/dataset/cifar10-decontrast.yaml similarity index 77% rename from resources/config_templates/user/dataset/cifar10-large.yaml rename to resources/config_templates/user/dataset/cifar10-decontrast.yaml index 645607d..5e0624b 100644 --- a/resources/config_templates/user/dataset/cifar10-large.yaml +++ b/resources/config_templates/user/dataset/cifar10-decontrast.yaml @@ -11,11 +11,9 @@ imageset: image_rescale_range: [1, 5] noise_transforms: - _target_: retinal_rl.datasets.transforms.ShotNoiseTransform - lambda_range: [0.8, 1.2] + lambda_range: [0.5, 1.5] - _target_: retinal_rl.datasets.transforms.ContrastTransform - contrast_range: [0.5, 1.5] + contrast_range: [0.01, 1.2] apply_normalization: true - # normalization_mean: [0.4914, 0.4822, 0.4465] - # normalization_std: [0.2023, 0.1994, 0.2010] fixed_transformation: false multiplier: 1 diff --git a/resources/config_templates/user/experiment/cifar10-class-recon.yaml b/resources/config_templates/user/experiment/cifar10-class-recon.yaml index fcc26de..3c1720c 100644 --- a/resources/config_templates/user/experiment/cifar10-class-recon.yaml +++ b/resources/config_templates/user/experiment/cifar10-class-recon.yaml @@ -1,25 +1,22 @@ -# This is the main entry point for users to specify their config parameters, and -# should be freely copied and edited. - -# Defaults for the various subconfigs. Can be overriden from the commandline -# with e.g. experiment/brain=new_brain, where new_brain.yaml lives in the brain -# subdirectory +# @package _global_ defaults: - _self_ - - sweep: kernel-size - - dataset: cifar10-large - - brain: retinal-classifier - - optimizer: class-recon + - override /dataset: cifar10-decontrast + - override /brain: shallow-autoencoder + - override /optimizer: recon-weight -# This *must* match the experiment file name -name: cifar10-class-recon +# This is the main entry point for control of a retinal-rl experiment. Variables +# created here will be top-level, and defaults can be set for the various parts +# of an experiment (NB: do not add comments above the defaults list or it will +# break the config system.) framework: classification # This is a free list of parameters that can be interpolated by the subconfigs # in sweep, dataset, brain, and optimizer. A major use for this is interpolating # values in the subconfigs, and then looping over them in a sweep. -latent_size: 128 -hidden_units: 64 activation: "elu" -kernel_size: 8 -stride: 2 +activation_sparsity: 0.0001 +weight_decay: 0.0001 +sparse_objective: retinal_rl.models.objective.L1Sparsity +recon_weight_retina: 1 +recon_weight_thalamus: 0.99 \ No newline at end of file diff --git a/resources/config_templates/user/optimizer/class-recon.yaml b/resources/config_templates/user/optimizer/class-recon.yaml deleted file mode 100644 index cdf8fc8..0000000 --- a/resources/config_templates/user/optimizer/class-recon.yaml +++ /dev/null @@ -1,46 +0,0 @@ -# BrainOptimizer config. Each top level defines a particular optimizer. Circuits -# should appear in at most one optimizer. -recon: - optimizer: # torch.optim Class and parameters - _target_: torch.optim.Adam - lr: 0.0003 - min_epoch: 0 # Epoch to start optimizer - max_epoch: 100 # Epoch to stop optimizer - objectives: # Weighted optimizer objectives as defined in retinal-rl - - _target_: retinal_rl.models.objective.ReconstructionObjective - weight: 1 - - _target_: retinal_rl.models.objective.L1Sparsity - weight: 0.001 - target_responses: - - retina - target_circuits: # Circuit parameters to optimize with this optimizer. We train the retina and the decoder exclusively to maximize reconstruction - - retina - - decoder -mixed: - optimizer: - _target_: torch.optim.Adam - lr: 0.0003 - min_epoch: 0 - max_epoch: 100 - objectives: - - _target_: retinal_rl.models.objective.ReconstructionObjective - weight: 0.99 - - _target_: retinal_rl.classification.objective.ClassificationObjective - weight: 0.01 - target_circuits: # The thalamus is somewhat sensitive to task objectives - - thalamus -class: - optimizer: - _target_: torch.optim.Adam - lr: 0.0003 - min_epoch: 0 - max_epoch: 100 - objectives: - - _target_: retinal_rl.classification.objective.ClassificationObjective - weight: 1 - - _target_: retinal_rl.classification.objective.PercentCorrect - weight: 0 - target_circuits: # Visual cortex and downstream layers are driven by the task - - visual_cortex - - pfc - - classifier diff --git a/resources/config_templates/user/optimizer/recon-weight.yaml b/resources/config_templates/user/optimizer/recon-weight.yaml new file mode 100644 index 0000000..83bc7e4 --- /dev/null +++ b/resources/config_templates/user/optimizer/recon-weight.yaml @@ -0,0 +1,45 @@ +optimizer: # torch.optim Class and parameters + _target_: torch.optim.Adam + lr: 0.0003 + +goal: + recon: + min_epoch: 0 # Epoch to start optimizer + max_epoch: 100 # Epoch to stop optimizer + losses: # Weighted optimizer losses as defined in retinal-rl + - _target_: retinal_rl.models.loss.ReconstructionLoss + weight: ${recon_weight_retina} + - _target_: retinal_rl.classification.loss.ClassificationLoss + weight: ${eval:'1-${recon_weight_retina}'} + target_circuits: # Circuit parameters to optimize with this optimizer. We train the retina and the decoder exclusively to maximize reconstruction + - retina + decode: + min_epoch: 0 # Epoch to start optimizer + max_epoch: 100 # Epoch to stop optimizer + losses: # Weighted optimizer losses as defined in retinal-rl + - _target_: retinal_rl.models.loss.ReconstructionLoss + weight: 1 + target_circuits: # Circuit parameters to optimize with this optimizer. We train the retina and the decoder exclusively to maximize reconstruction + - decoder + mixed: + min_epoch: 0 + max_epoch: 100 + losses: + - _target_: retinal_rl.models.loss.ReconstructionLoss + weight: ${recon_weight_thalamus} + - _target_: retinal_rl.classification.loss.ClassificationLoss + weight: ${eval:'1-${recon_weight_thalamus}'} + target_circuits: # The thalamus is somewhat sensitive to task losses + - thalamus + class: + min_epoch: 0 + max_epoch: 100 + losses: + - _target_: retinal_rl.classification.loss.ClassificationLoss + weight: 1 + - _target_: retinal_rl.classification.loss.PercentCorrect + weight: 0 + target_circuits: # Visual cortex and downstream layers are driven by the task + - visual_cortex + - pfc + - classifier From 45ae1550d766574d5303448d48a70f56d93362e9 Mon Sep 17 00:00:00 2001 From: Fabio Seel Date: Wed, 9 Oct 2024 14:48:05 +0200 Subject: [PATCH 12/49] fix: make pylint not fail the pipeline (WIP) --- .github/workflows/{pylint.yml => code_check.yml} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename .github/workflows/{pylint.yml => code_check.yml} (81%) diff --git a/.github/workflows/pylint.yml b/.github/workflows/code_check.yml similarity index 81% rename from .github/workflows/pylint.yml rename to .github/workflows/code_check.yml index c63f94c..4b4648c 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/code_check.yml @@ -1,4 +1,4 @@ -name: Pylint +name: Code Checking on: [push, pull_request] @@ -15,4 +15,4 @@ jobs: run: singularity registry login --username ${{ github.actor }} --password ${{ secrets.GITHUB_TOKEN }} oras://ghcr.io; singularity pull oras://ghcr.io/berenslab/retinal-rl:singularity-image-latest - name: Run Pylint - run: singularity exec retinal-rl_singularity-image-latest.sif pylint . #$(git diff --name-only origin/master origin/feat-ci-pipeline -- '*.py') + run: singularity exec retinal-rl_singularity-image-latest.sif pylint --exit-zero . #$(git diff --name-only origin/master origin/feat-ci-pipeline -- '*.py') From 2180265853176008e723393567484831cba588e3 Mon Sep 17 00:00:00 2001 From: Fabio Seel Date: Wed, 9 Oct 2024 14:48:24 +0200 Subject: [PATCH 13/49] feat: add workflow to check if cfgs can be read --- .github/workflows/config_scan.yaml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 .github/workflows/config_scan.yaml diff --git a/.github/workflows/config_scan.yaml b/.github/workflows/config_scan.yaml new file mode 100644 index 0000000..ada1c47 --- /dev/null +++ b/.github/workflows/config_scan.yaml @@ -0,0 +1,21 @@ +name: Scan Configs + +on: [push, pull_request] + +jobs: + scan: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: eWaterCycle/setup-apptainer@v2 + with: + apptainer-version: 1.3.0 + + - name: Pulling Singularity container + run: singularity registry login --username ${{ github.actor }} --password ${{ secrets.GITHUB_TOKEN }} oras://ghcr.io; singularity pull oras://ghcr.io/berenslab/retinal-rl:singularity-image-latest + + - name: Copy configs from resources directory + run: cp -r resources/config_templates/user/* config/user/ + + - name: Scan classification config + run: singularity exec retinal-rl_singularity-image-latest.sif python main.py -m +experiment=cifar10-class-recon command=scan \ No newline at end of file From f2870ff6c8c4d19be766f5011c5f19539f9ed867 Mon Sep 17 00:00:00 2001 From: Fabio Seel Date: Wed, 9 Oct 2024 14:51:42 +0200 Subject: [PATCH 14/49] fix: paths in config scan workflow --- .github/workflows/config_scan.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/config_scan.yaml b/.github/workflows/config_scan.yaml index ada1c47..20c11c6 100644 --- a/.github/workflows/config_scan.yaml +++ b/.github/workflows/config_scan.yaml @@ -15,7 +15,7 @@ jobs: run: singularity registry login --username ${{ github.actor }} --password ${{ secrets.GITHUB_TOKEN }} oras://ghcr.io; singularity pull oras://ghcr.io/berenslab/retinal-rl:singularity-image-latest - name: Copy configs from resources directory - run: cp -r resources/config_templates/user/* config/user/ + run: cp -r resources/config_templates/* config/ - name: Scan classification config run: singularity exec retinal-rl_singularity-image-latest.sif python main.py -m +experiment=cifar10-class-recon command=scan \ No newline at end of file From 2da3900f30fb8f2d4faeec1c1d5098f35ecc62ce Mon Sep 17 00:00:00 2001 From: Fabio Seel Date: Wed, 9 Oct 2024 15:05:13 +0200 Subject: [PATCH 15/49] fix: make config scan run without cuda / gpu --- .github/workflows/config_scan.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/config_scan.yaml b/.github/workflows/config_scan.yaml index 20c11c6..85fd3d0 100644 --- a/.github/workflows/config_scan.yaml +++ b/.github/workflows/config_scan.yaml @@ -18,4 +18,4 @@ jobs: run: cp -r resources/config_templates/* config/ - name: Scan classification config - run: singularity exec retinal-rl_singularity-image-latest.sif python main.py -m +experiment=cifar10-class-recon command=scan \ No newline at end of file + run: singularity exec retinal-rl_singularity-image-latest.sif python main.py -m +experiment=cifar10-class-recon command=scan system.device=cpu \ No newline at end of file From 84cc1fa74a916d93db1cb0b53f80c9d3bd9b6c49 Mon Sep 17 00:00:00 2001 From: Fabio Seel Date: Wed, 9 Oct 2024 15:38:50 +0200 Subject: [PATCH 16/49] feat: add workflow to test whether singularity container can be build --- .../{config_scan.yaml => config_scan.yml} | 0 .github/workflows/container_build.yml | 15 +++++++++++++++ 2 files changed, 15 insertions(+) rename .github/workflows/{config_scan.yaml => config_scan.yml} (100%) create mode 100644 .github/workflows/container_build.yml diff --git a/.github/workflows/config_scan.yaml b/.github/workflows/config_scan.yml similarity index 100% rename from .github/workflows/config_scan.yaml rename to .github/workflows/config_scan.yml diff --git a/.github/workflows/container_build.yml b/.github/workflows/container_build.yml new file mode 100644 index 0000000..3f57bd0 --- /dev/null +++ b/.github/workflows/container_build.yml @@ -0,0 +1,15 @@ +name: Build Singularity Container + +on: [push, pull_request] + +jobs: + singularity-build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: eWaterCycle/setup-apptainer@v2 + with: + apptainer-version: 1.3.0 + + - name: Build Singularity container + run: apptainer build retinal-rl.sif resources/retinal-rl.def \ No newline at end of file From 361702a453872c3eeac6df19579b1a20bc0e2457 Mon Sep 17 00:00:00 2001 From: Fabio Seel Date: Wed, 9 Oct 2024 16:38:04 +0200 Subject: [PATCH 17/49] feat: container build with automatical upload to ghcr --- .github/workflows/container_build.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/container_build.yml b/.github/workflows/container_build.yml index 3f57bd0..2d7cb65 100644 --- a/.github/workflows/container_build.yml +++ b/.github/workflows/container_build.yml @@ -6,10 +6,16 @@ jobs: singularity-build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: eWaterCycle/setup-apptainer@v2 with: apptainer-version: 1.3.0 - name: Build Singularity container - run: apptainer build retinal-rl.sif resources/retinal-rl.def \ No newline at end of file + run: apptainer build retinal-rl.sif resources/retinal-rl.def + + - name: Scan classification config / ensure minimal functionality + run: singularity exec retinal-rl_singularity-image-latest.sif python main.py -m +experiment=cifar10-class-recon command=scan system.device=cpu + + - name: Push to ghcr.io + run: singularity registry login --username ${{ github.actor }} --password ${{ secrets.GITHUB_TOKEN }} oras://ghcr.io; singularity push retinal-rl.sif oras://ghcr.io/berenslab/retinal-rl:singularity-image-latest \ No newline at end of file From 5c53f589015a817f7ad4705492f57cf9e6b503bf Mon Sep 17 00:00:00 2001 From: Fabio Seel Date: Wed, 9 Oct 2024 16:49:59 +0200 Subject: [PATCH 18/49] fix: name of created sif file for scan --- .github/workflows/container_build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/container_build.yml b/.github/workflows/container_build.yml index 2d7cb65..ae10ca7 100644 --- a/.github/workflows/container_build.yml +++ b/.github/workflows/container_build.yml @@ -15,7 +15,7 @@ jobs: run: apptainer build retinal-rl.sif resources/retinal-rl.def - name: Scan classification config / ensure minimal functionality - run: singularity exec retinal-rl_singularity-image-latest.sif python main.py -m +experiment=cifar10-class-recon command=scan system.device=cpu + run: singularity exec retinal-rl.sif python main.py -m +experiment=cifar10-class-recon command=scan system.device=cpu - name: Push to ghcr.io run: singularity registry login --username ${{ github.actor }} --password ${{ secrets.GITHUB_TOKEN }} oras://ghcr.io; singularity push retinal-rl.sif oras://ghcr.io/berenslab/retinal-rl:singularity-image-latest \ No newline at end of file From e9d52ec6b084010f8f60f6a211b3a05d32645401 Mon Sep 17 00:00:00 2001 From: Fabio Seel Date: Thu, 10 Oct 2024 11:08:26 +0200 Subject: [PATCH 19/49] fix/refactor: build and push now should run, nicify multiline comments, test reusable workflows --- .github/workflows/code_check.yml | 4 +++- .github/workflows/config_scan.yml | 22 +++++--------------- .github/workflows/container_build.yml | 8 ++++++-- .github/workflows/singularity_pull.yml | 28 ++++++++++++++++++++++++++ 4 files changed, 42 insertions(+), 20 deletions(-) create mode 100644 .github/workflows/singularity_pull.yml diff --git a/.github/workflows/code_check.yml b/.github/workflows/code_check.yml index 4b4648c..8f92a8a 100644 --- a/.github/workflows/code_check.yml +++ b/.github/workflows/code_check.yml @@ -12,7 +12,9 @@ jobs: apptainer-version: 1.3.0 - name: Pulling Singularity container - run: singularity registry login --username ${{ github.actor }} --password ${{ secrets.GITHUB_TOKEN }} oras://ghcr.io; singularity pull oras://ghcr.io/berenslab/retinal-rl:singularity-image-latest + run: | + singularity registry login --username ${{ github.actor }} --password ${{ secrets.GITHUB_TOKEN }} oras://ghcr.io + singularity pull oras://ghcr.io/berenslab/retinal-rl:singularity-image-latest - name: Run Pylint run: singularity exec retinal-rl_singularity-image-latest.sif pylint --exit-zero . #$(git diff --name-only origin/master origin/feat-ci-pipeline -- '*.py') diff --git a/.github/workflows/config_scan.yml b/.github/workflows/config_scan.yml index 85fd3d0..82b08d2 100644 --- a/.github/workflows/config_scan.yml +++ b/.github/workflows/config_scan.yml @@ -1,21 +1,9 @@ name: Scan Configs - on: [push, pull_request] - jobs: scan: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: eWaterCycle/setup-apptainer@v2 - with: - apptainer-version: 1.3.0 - - - name: Pulling Singularity container - run: singularity registry login --username ${{ github.actor }} --password ${{ secrets.GITHUB_TOKEN }} oras://ghcr.io; singularity pull oras://ghcr.io/berenslab/retinal-rl:singularity-image-latest - - - name: Copy configs from resources directory - run: cp -r resources/config_templates/* config/ - - - name: Scan classification config - run: singularity exec retinal-rl_singularity-image-latest.sif python main.py -m +experiment=cifar10-class-recon command=scan system.device=cpu \ No newline at end of file + uses: ./.github/workflows/singularity_pull.yml + with: + singularity_image: oras://ghcr.io/berenslab/retinal-rl:singularity-image-latest + secrets: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/container_build.yml b/.github/workflows/container_build.yml index ae10ca7..94d9690 100644 --- a/.github/workflows/container_build.yml +++ b/.github/workflows/container_build.yml @@ -15,7 +15,11 @@ jobs: run: apptainer build retinal-rl.sif resources/retinal-rl.def - name: Scan classification config / ensure minimal functionality - run: singularity exec retinal-rl.sif python main.py -m +experiment=cifar10-class-recon command=scan system.device=cpu + run: | + cp -r resources/config_templates/* config/ + singularity exec retinal-rl.sif python main.py -m +experiment=cifar10-class-recon command=scan system.device=cpu - name: Push to ghcr.io - run: singularity registry login --username ${{ github.actor }} --password ${{ secrets.GITHUB_TOKEN }} oras://ghcr.io; singularity push retinal-rl.sif oras://ghcr.io/berenslab/retinal-rl:singularity-image-latest \ No newline at end of file + run: | + singularity registry login --username ${{ github.actor }} --password ${{ secrets.GITHUB_TOKEN }} oras://ghcr.io + singularity push retinal-rl.sif oras://ghcr.io/berenslab/retinal-rl:singularity-image-latest \ No newline at end of file diff --git a/.github/workflows/singularity_pull.yml b/.github/workflows/singularity_pull.yml new file mode 100644 index 0000000..ef9ec28 --- /dev/null +++ b/.github/workflows/singularity_pull.yml @@ -0,0 +1,28 @@ +name: Reusable Pull and Scan + +on: + workflow_call: + inputs: + singularity_image: + required: true + type: string + secrets: + GITHUB_TOKEN: + required: true + +jobs: + reusable_job: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: eWaterCycle/setup-apptainer@v2 + with: + apptainer-version: 1.3.0 + - name: Login to ghcr + run: singularity registry login --username ${{ github.actor }} --password ${{ secrets.GITHUB_TOKEN }} oras://ghcr.io + - name: Pull Image + run: singularity pull ${{ inputs.singularity_image }} + - name: Scan classification config + run: | + cp -r resources/config_templates/* config/ + singularity exec $(basename ${{ inputs.singularity_image }}) python main.py -m +experiment=cifar10-class-recon command=scan system.device=cpu \ No newline at end of file From 5d5985032c34c80e71014bac4e83f257b44b73c4 Mon Sep 17 00:00:00 2001 From: Fabio Seel Date: Thu, 10 Oct 2024 11:10:53 +0200 Subject: [PATCH 20/49] fix(?): reusable workflow --- .github/workflows/config_scan.yml | 4 +--- .github/workflows/singularity_pull.yml | 3 --- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/config_scan.yml b/.github/workflows/config_scan.yml index 82b08d2..0002276 100644 --- a/.github/workflows/config_scan.yml +++ b/.github/workflows/config_scan.yml @@ -4,6 +4,4 @@ jobs: scan: uses: ./.github/workflows/singularity_pull.yml with: - singularity_image: oras://ghcr.io/berenslab/retinal-rl:singularity-image-latest - secrets: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + singularity_image: oras://ghcr.io/berenslab/retinal-rl:singularity-image-latest \ No newline at end of file diff --git a/.github/workflows/singularity_pull.yml b/.github/workflows/singularity_pull.yml index ef9ec28..bdbe05c 100644 --- a/.github/workflows/singularity_pull.yml +++ b/.github/workflows/singularity_pull.yml @@ -6,9 +6,6 @@ on: singularity_image: required: true type: string - secrets: - GITHUB_TOKEN: - required: true jobs: reusable_job: From 8d848c26d8345de68d2631b378775c861dbf687f Mon Sep 17 00:00:00 2001 From: Fabio Seel Date: Thu, 10 Oct 2024 11:26:41 +0200 Subject: [PATCH 21/49] fix(?):automatic referencing of sif file in reusable job --- .github/workflows/singularity_pull.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/singularity_pull.yml b/.github/workflows/singularity_pull.yml index bdbe05c..cc04b48 100644 --- a/.github/workflows/singularity_pull.yml +++ b/.github/workflows/singularity_pull.yml @@ -22,4 +22,6 @@ jobs: - name: Scan classification config run: | cp -r resources/config_templates/* config/ - singularity exec $(basename ${{ inputs.singularity_image }}) python main.py -m +experiment=cifar10-class-recon command=scan system.device=cpu \ No newline at end of file + IMAGE_NAME=$(basename ${{ inputs.singularity_image }}) + SIF_FILE="${IMAGE_NAME/:/_}.sif" + singularity exec $SIF_FILE python main.py -m +experiment=cifar10-class-recon command=scan system.device=cpu \ No newline at end of file From 453d8e3ba0703e69de61969ea80f5881e23e2540 Mon Sep 17 00:00:00 2001 From: Fabio Seel Date: Thu, 10 Oct 2024 11:57:03 +0200 Subject: [PATCH 22/49] feat: run build action once a month or when def file has changed --- .github/workflows/container_build.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/container_build.yml b/.github/workflows/container_build.yml index 94d9690..07760db 100644 --- a/.github/workflows/container_build.yml +++ b/.github/workflows/container_build.yml @@ -1,6 +1,11 @@ name: Build Singularity Container -on: [push, pull_request] +on: + schedule: + - cron: '0 2 1 * *' + push: + paths: + - 'resources/retinal-rl.def' jobs: singularity-build: From 3352e36dda2943545246e4be796d51168a5c0b3a Mon Sep 17 00:00:00 2001 From: Fabio Seel Date: Thu, 10 Oct 2024 12:01:05 +0200 Subject: [PATCH 23/49] refactor: adjust when code check and scan are run --- .github/workflows/code_check.yml | 8 +++++++- .github/workflows/config_scan.yml | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/code_check.yml b/.github/workflows/code_check.yml index 8f92a8a..ef2ab01 100644 --- a/.github/workflows/code_check.yml +++ b/.github/workflows/code_check.yml @@ -1,6 +1,12 @@ name: Code Checking -on: [push, pull_request] +on: + push: + paths: + - '**/*.py' + pull_request: + branches: + - main jobs: lint: diff --git a/.github/workflows/config_scan.yml b/.github/workflows/config_scan.yml index 0002276..fb3df25 100644 --- a/.github/workflows/config_scan.yml +++ b/.github/workflows/config_scan.yml @@ -1,5 +1,5 @@ name: Scan Configs -on: [push, pull_request] +on: [pull_request,workflow_dispatch] jobs: scan: uses: ./.github/workflows/singularity_pull.yml From 45b1928f7932f7051d538a2db744eebb91d10c88 Mon Sep 17 00:00:00 2001 From: Fabio Seel Date: Thu, 10 Oct 2024 13:54:31 +0200 Subject: [PATCH 24/49] feat: run pylint on changed py files (compared to master) --- .github/workflows/code_check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/code_check.yml b/.github/workflows/code_check.yml index ef2ab01..f06711f 100644 --- a/.github/workflows/code_check.yml +++ b/.github/workflows/code_check.yml @@ -23,4 +23,4 @@ jobs: singularity pull oras://ghcr.io/berenslab/retinal-rl:singularity-image-latest - name: Run Pylint - run: singularity exec retinal-rl_singularity-image-latest.sif pylint --exit-zero . #$(git diff --name-only origin/master origin/feat-ci-pipeline -- '*.py') + run: singularity exec retinal-rl_singularity-image-latest.sif pylint $(git diff --name-only origin/master HEAD -- '*.py') From b26d636fa1a06ce3afb85168f99f8d259d3e12c2 Mon Sep 17 00:00:00 2001 From: Fabio Seel Date: Thu, 10 Oct 2024 14:09:35 +0200 Subject: [PATCH 25/49] refactor: reusable action for initial setup --- .github/workflows/code_check.yml | 14 ++++++++------ .github/workflows/config_scan.yml | 16 +++++++++++++--- .../{singularity_pull.yml => setup.yml} | 12 ++++-------- 3 files changed, 25 insertions(+), 17 deletions(-) rename .github/workflows/{singularity_pull.yml => setup.yml} (57%) diff --git a/.github/workflows/code_check.yml b/.github/workflows/code_check.yml index f06711f..ceb2b34 100644 --- a/.github/workflows/code_check.yml +++ b/.github/workflows/code_check.yml @@ -8,6 +8,10 @@ on: branches: - main +env: + singularity_image: oras://ghcr.io/berenslab/retinal-rl:singularity-image-latest + sif_file: retinal-rl_singularity-image-latest.sif + jobs: lint: runs-on: ubuntu-latest @@ -16,11 +20,9 @@ jobs: - uses: eWaterCycle/setup-apptainer@v2 with: apptainer-version: 1.3.0 - - - name: Pulling Singularity container - run: | - singularity registry login --username ${{ github.actor }} --password ${{ secrets.GITHUB_TOKEN }} oras://ghcr.io - singularity pull oras://ghcr.io/berenslab/retinal-rl:singularity-image-latest + - uses: ./.github/workflows/setup.yml + with: + singularity_image: ${{ env.singularity_image }} - name: Run Pylint - run: singularity exec retinal-rl_singularity-image-latest.sif pylint $(git diff --name-only origin/master HEAD -- '*.py') + run: singularity exec ${{ env.sif_file }} pylint $(git diff --name-only origin/master HEAD -- '*.py') diff --git a/.github/workflows/config_scan.yml b/.github/workflows/config_scan.yml index fb3df25..9764101 100644 --- a/.github/workflows/config_scan.yml +++ b/.github/workflows/config_scan.yml @@ -1,7 +1,17 @@ name: Scan Configs on: [pull_request,workflow_dispatch] + +env: + singularity_image: oras://ghcr.io/berenslab/retinal-rl:singularity-image-latest + sif_file: retinal-rl_singularity-image-latest.sif + jobs: scan: - uses: ./.github/workflows/singularity_pull.yml - with: - singularity_image: oras://ghcr.io/berenslab/retinal-rl:singularity-image-latest \ No newline at end of file + runs-on: ubuntu-latest + steps: + - uses: ./.github/workflows/setup.yml + with: + singularity_image: ${{ env.singularity_image }} + + - name: Scan classification config + run: singularity exec ${{ env.sif_file }} python main.py -m +experiment=cifar10-class-recon command=scan system.device=cpu \ No newline at end of file diff --git a/.github/workflows/singularity_pull.yml b/.github/workflows/setup.yml similarity index 57% rename from .github/workflows/singularity_pull.yml rename to .github/workflows/setup.yml index cc04b48..d387e3e 100644 --- a/.github/workflows/singularity_pull.yml +++ b/.github/workflows/setup.yml @@ -1,4 +1,4 @@ -name: Reusable Pull and Scan +name: Pull Singularity container & Setup Repository on: workflow_call: @@ -8,7 +8,7 @@ on: type: string jobs: - reusable_job: + setup: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -19,9 +19,5 @@ jobs: run: singularity registry login --username ${{ github.actor }} --password ${{ secrets.GITHUB_TOKEN }} oras://ghcr.io - name: Pull Image run: singularity pull ${{ inputs.singularity_image }} - - name: Scan classification config - run: | - cp -r resources/config_templates/* config/ - IMAGE_NAME=$(basename ${{ inputs.singularity_image }}) - SIF_FILE="${IMAGE_NAME/:/_}.sif" - singularity exec $SIF_FILE python main.py -m +experiment=cifar10-class-recon command=scan system.device=cpu \ No newline at end of file + - name: Copy Configs + run: cp -r resources/config_templates/* config/ \ No newline at end of file From 1d65f0ec7c770e06444d775cf9cecfe94fd1ce39 Mon Sep 17 00:00:00 2001 From: Fabio Seel Date: Thu, 10 Oct 2024 14:10:37 +0200 Subject: [PATCH 26/49] fix: pylint complains in compile scenario of doom_creator --- ...ompile-scenario.py => compile_scenario.py} | 34 +++++++++++++++++-- 1 file changed, 31 insertions(+), 3 deletions(-) rename doom_creator/{compile-scenario.py => compile_scenario.py} (77%) diff --git a/doom_creator/compile-scenario.py b/doom_creator/compile_scenario.py similarity index 77% rename from doom_creator/compile-scenario.py rename to doom_creator/compile_scenario.py index d6450ea..395531c 100644 --- a/doom_creator/compile-scenario.py +++ b/doom_creator/compile_scenario.py @@ -1,3 +1,15 @@ +"""Scenario Compiler for Retinal-RL + +This module provides a utility to construct scenarios for the retinal-rl project. +It merges YAML files from a specified directory into a scenario specification and +subsequently compiles the scenario defined through those yaml files. + +Usage: + python -m exec.compile-scenario [options] [yaml_files...] + +Example: + python -m exec.compile-scenario gathering apples""" + import argparse import os import sys @@ -11,6 +23,13 @@ def make_parser(): + """ + Create and configure an argument parser for the scenario compiler. + Check the parsers description and arguments help for further information. + + Returns: + argparse.ArgumentParser: Configured argument parser for the scenario compiler. + """ # Initialize parser Directories() parser = argparse.ArgumentParser( @@ -22,7 +41,7 @@ def make_parser(): running the first time one should use the --preload flag to download the necessary resources into the --out_dir ('{Directories().CACHE_DIR}'). """, - epilog="Example: python -m exec.compile-scenario gathering apples", + epilog="Example: python -m exec.compile_scenario gathering apples", ) # Positional argument for scenario yaml files (required, can be multiple) parser.add_argument( @@ -44,7 +63,7 @@ def make_parser(): parser.add_argument( "--dataset_dir", default=None, - help="source directory of a dataset (for preloading), if you already downloaded it somewhere", + help="source directory of a dataset (for preloading), if already downloaded somewhere", ) parser.add_argument( "--resource_dir", @@ -72,6 +91,15 @@ def make_parser(): def main(): + """ + Main function to parse arguments and execute scenario compilation tasks. + + The function supports various modes of operation including preloading resources, + listing available YAML files, and creating scenarios. It also handles error + checking and warns the user if no actions are specified. + + For a more detailed documentation, check the parser. + """ # Parse args argv = sys.argv[1:] parser = make_parser() @@ -92,7 +120,7 @@ def main(): print(f"Listing contents of {dirs.SCENARIO_YAML_DIR}:") for flnm in os.listdir(dirs.SCENARIO_YAML_DIR): print(flnm) - print(f"If you want to load from a different folder, change this to") + print("If you want to load from a different folder, change this to") if do_make: cfg, needed_types = check_preload(cfg, args.test) any_dataset = False From 9522e10009852c5096ce777441ced190fd5a9562 Mon Sep 17 00:00:00 2001 From: Fabio Seel Date: Thu, 10 Oct 2024 14:15:37 +0200 Subject: [PATCH 27/49] fix: checkout must be in every top level workflow --- .github/workflows/code_check.yml | 7 ++----- .github/workflows/config_scan.yml | 1 + .github/workflows/setup.yml | 1 - 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/workflows/code_check.yml b/.github/workflows/code_check.yml index ceb2b34..19ed202 100644 --- a/.github/workflows/code_check.yml +++ b/.github/workflows/code_check.yml @@ -2,8 +2,8 @@ name: Code Checking on: push: - paths: - - '**/*.py' + # paths: + # - '**/*.py' pull_request: branches: - main @@ -17,9 +17,6 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: eWaterCycle/setup-apptainer@v2 - with: - apptainer-version: 1.3.0 - uses: ./.github/workflows/setup.yml with: singularity_image: ${{ env.singularity_image }} diff --git a/.github/workflows/config_scan.yml b/.github/workflows/config_scan.yml index 9764101..5fb1e81 100644 --- a/.github/workflows/config_scan.yml +++ b/.github/workflows/config_scan.yml @@ -9,6 +9,7 @@ jobs: scan: runs-on: ubuntu-latest steps: + - uses: actions/checkout@v4 - uses: ./.github/workflows/setup.yml with: singularity_image: ${{ env.singularity_image }} diff --git a/.github/workflows/setup.yml b/.github/workflows/setup.yml index d387e3e..439d67b 100644 --- a/.github/workflows/setup.yml +++ b/.github/workflows/setup.yml @@ -11,7 +11,6 @@ jobs: setup: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - uses: eWaterCycle/setup-apptainer@v2 with: apptainer-version: 1.3.0 From 19ecf45da24b6f60c7d68d3707e7869ac0d4d88c Mon Sep 17 00:00:00 2001 From: Fabio Seel Date: Thu, 10 Oct 2024 14:17:08 +0200 Subject: [PATCH 28/49] fix(?): add checkout also to setup workflow --- .github/workflows/setup.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/setup.yml b/.github/workflows/setup.yml index 439d67b..d387e3e 100644 --- a/.github/workflows/setup.yml +++ b/.github/workflows/setup.yml @@ -11,6 +11,7 @@ jobs: setup: runs-on: ubuntu-latest steps: + - uses: actions/checkout@v4 - uses: eWaterCycle/setup-apptainer@v2 with: apptainer-version: 1.3.0 From 00dddfd987688b9506b71cdfce76fbaf3357e067 Mon Sep 17 00:00:00 2001 From: Fabio Seel Date: Thu, 10 Oct 2024 14:36:48 +0200 Subject: [PATCH 29/49] fix(?): reusable workflow --- .github/workflows/code_check.yml | 7 +++++-- .github/workflows/config_scan.yml | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/workflows/code_check.yml b/.github/workflows/code_check.yml index 19ed202..3e86a17 100644 --- a/.github/workflows/code_check.yml +++ b/.github/workflows/code_check.yml @@ -13,13 +13,16 @@ env: sif_file: retinal-rl_singularity-image-latest.sif jobs: - lint: + init: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - uses: ./.github/workflows/setup.yml with: singularity_image: ${{ env.singularity_image }} + lint: + needs: init + runs-on: ubuntu-latest + steps: - name: Run Pylint run: singularity exec ${{ env.sif_file }} pylint $(git diff --name-only origin/master HEAD -- '*.py') diff --git a/.github/workflows/config_scan.yml b/.github/workflows/config_scan.yml index 5fb1e81..af21d8c 100644 --- a/.github/workflows/config_scan.yml +++ b/.github/workflows/config_scan.yml @@ -6,13 +6,16 @@ env: sif_file: retinal-rl_singularity-image-latest.sif jobs: - scan: + init: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - uses: ./.github/workflows/setup.yml with: singularity_image: ${{ env.singularity_image }} + scan: + needs: init + runs-on: ubuntu-latest + steps: - name: Scan classification config run: singularity exec ${{ env.sif_file }} python main.py -m +experiment=cifar10-class-recon command=scan system.device=cpu \ No newline at end of file From 2840e462e8bce837587212cb202d7431064615ad Mon Sep 17 00:00:00 2001 From: Fabio Seel Date: Thu, 10 Oct 2024 14:40:35 +0200 Subject: [PATCH 30/49] fix(?): local workflows can not be called in steps --- .github/workflows/code_check.yml | 8 +++----- .github/workflows/config_scan.yml | 8 +++----- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/.github/workflows/code_check.yml b/.github/workflows/code_check.yml index 3e86a17..330fbc9 100644 --- a/.github/workflows/code_check.yml +++ b/.github/workflows/code_check.yml @@ -14,11 +14,9 @@ env: jobs: init: - runs-on: ubuntu-latest - steps: - - uses: ./.github/workflows/setup.yml - with: - singularity_image: ${{ env.singularity_image }} + uses: ./.github/workflows/setup.yml + with: + singularity_image: ${{ env.singularity_image }} lint: needs: init diff --git a/.github/workflows/config_scan.yml b/.github/workflows/config_scan.yml index af21d8c..ac4d25d 100644 --- a/.github/workflows/config_scan.yml +++ b/.github/workflows/config_scan.yml @@ -7,11 +7,9 @@ env: jobs: init: - runs-on: ubuntu-latest - steps: - - uses: ./.github/workflows/setup.yml - with: - singularity_image: ${{ env.singularity_image }} + uses: ./.github/workflows/setup.yml + with: + singularity_image: ${{ env.singularity_image }} scan: needs: init From 70229c369927314be6b00de0437ba877d57878d5 Mon Sep 17 00:00:00 2001 From: Fabio Seel Date: Thu, 10 Oct 2024 14:53:12 +0200 Subject: [PATCH 31/49] fix: env variables seem poorly supported, removed that --- .github/workflows/code_check.yml | 8 ++------ .github/workflows/config_scan.yml | 8 ++------ 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/.github/workflows/code_check.yml b/.github/workflows/code_check.yml index 330fbc9..dc58d4d 100644 --- a/.github/workflows/code_check.yml +++ b/.github/workflows/code_check.yml @@ -8,19 +8,15 @@ on: branches: - main -env: - singularity_image: oras://ghcr.io/berenslab/retinal-rl:singularity-image-latest - sif_file: retinal-rl_singularity-image-latest.sif - jobs: init: uses: ./.github/workflows/setup.yml with: - singularity_image: ${{ env.singularity_image }} + singularity_image: oras://ghcr.io/berenslab/retinal-rl:singularity-image-latest lint: needs: init runs-on: ubuntu-latest steps: - name: Run Pylint - run: singularity exec ${{ env.sif_file }} pylint $(git diff --name-only origin/master HEAD -- '*.py') + run: singularity exec retinal-rl_singularity-image-latest.sif pylint $(git diff --name-only origin/master HEAD -- '*.py') diff --git a/.github/workflows/config_scan.yml b/.github/workflows/config_scan.yml index ac4d25d..8f7affd 100644 --- a/.github/workflows/config_scan.yml +++ b/.github/workflows/config_scan.yml @@ -1,19 +1,15 @@ name: Scan Configs on: [pull_request,workflow_dispatch] -env: - singularity_image: oras://ghcr.io/berenslab/retinal-rl:singularity-image-latest - sif_file: retinal-rl_singularity-image-latest.sif - jobs: init: uses: ./.github/workflows/setup.yml with: - singularity_image: ${{ env.singularity_image }} + singularity_image: oras://ghcr.io/berenslab/retinal-rl:singularity-image-latest scan: needs: init runs-on: ubuntu-latest steps: - name: Scan classification config - run: singularity exec ${{ env.sif_file }} python main.py -m +experiment=cifar10-class-recon command=scan system.device=cpu \ No newline at end of file + run: singularity exec retinal-rl_singularity-image-latest.sif python main.py -m +experiment=cifar10-class-recon command=scan system.device=cpu \ No newline at end of file From 40a09a81ca43bcd22b183f4764674a5230956225 Mon Sep 17 00:00:00 2001 From: Fabio Seel Date: Thu, 10 Oct 2024 15:11:08 +0200 Subject: [PATCH 32/49] feat: add cache, make code check more verbose --- .github/workflows/code_check.yml | 10 +++++++++- .github/workflows/config_scan.yml | 5 ++++- .github/workflows/setup.yml | 33 ++++++++++++++++++++++--------- 3 files changed, 37 insertions(+), 11 deletions(-) diff --git a/.github/workflows/code_check.yml b/.github/workflows/code_check.yml index dc58d4d..cfdaa77 100644 --- a/.github/workflows/code_check.yml +++ b/.github/workflows/code_check.yml @@ -13,10 +13,18 @@ jobs: uses: ./.github/workflows/setup.yml with: singularity_image: oras://ghcr.io/berenslab/retinal-rl:singularity-image-latest + sif_file: retinal-rl_singularity-image-latest.sif lint: needs: init runs-on: ubuntu-latest steps: + - name: list directory + run: ls + - uses: actions/checkout@v4 + - name: list directory + run: ls - name: Run Pylint - run: singularity exec retinal-rl_singularity-image-latest.sif pylint $(git diff --name-only origin/master HEAD -- '*.py') + run: | + singularity exec ~/singularity_images/retinal-rl_singularity-image-latest.sif \ + pylint $(git diff --name-only origin/master HEAD -- '*.py') diff --git a/.github/workflows/config_scan.yml b/.github/workflows/config_scan.yml index 8f7affd..630fa5b 100644 --- a/.github/workflows/config_scan.yml +++ b/.github/workflows/config_scan.yml @@ -6,10 +6,13 @@ jobs: uses: ./.github/workflows/setup.yml with: singularity_image: oras://ghcr.io/berenslab/retinal-rl:singularity-image-latest + sif_file: retinal-rl_singularity-image-latest.sif scan: needs: init runs-on: ubuntu-latest steps: - name: Scan classification config - run: singularity exec retinal-rl_singularity-image-latest.sif python main.py -m +experiment=cifar10-class-recon command=scan system.device=cpu \ No newline at end of file + run: | + singularity exec ~/singularity_images/retinal-rl_singularity-image-latest.sif \ + python main.py -m +experiment=cifar10-class-recon command=scan system.device=cpu \ No newline at end of file diff --git a/.github/workflows/setup.yml b/.github/workflows/setup.yml index d387e3e..efdc217 100644 --- a/.github/workflows/setup.yml +++ b/.github/workflows/setup.yml @@ -6,18 +6,33 @@ on: singularity_image: required: true type: string + sif_file: + required: true + type: string jobs: - setup: + init: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - uses: eWaterCycle/setup-apptainer@v2 + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup Apptainer + uses: eWaterCycle/setup-apptainer@v2 with: apptainer-version: 1.3.0 - - name: Login to ghcr - run: singularity registry login --username ${{ github.actor }} --password ${{ secrets.GITHUB_TOKEN }} oras://ghcr.io - - name: Pull Image - run: singularity pull ${{ inputs.singularity_image }} - - name: Copy Configs - run: cp -r resources/config_templates/* config/ \ No newline at end of file + + - name: Cache Singularity Image + id: cache-singularity + uses: actions/cache@v3 + with: + path: ~/singularity_images + key: ${{ runner.os }}-singularity-${{ hashFiles('**/singularity_image_url.txt') }} + + - name: Pull Singularity container + if: steps.cache-singularity.outputs.cache-hit != 'true' + run: | + mkdir -p ~/singularity_images + singularity registry login --username ${{ github.actor }} --password ${{ secrets.GITHUB_TOKEN }} oras://ghcr.io + singularity pull --dir ~/singularity_images ${{ inputs.sif_file }} ${{ inputs.singularity_image }} + echo "${{ inputs.singularity_image }}" > ~/singularity_images/singularity_image_url.txt \ No newline at end of file From 77f3121a81c425bbb259579644a86ab1321b2e1c Mon Sep 17 00:00:00 2001 From: Fabio Seel Date: Thu, 10 Oct 2024 15:25:35 +0200 Subject: [PATCH 33/49] fix(?): code check comparison to master make init/get singularity action do only the caching/pulling --- .github/workflows/code_check.yml | 15 ++++++++------- .github/workflows/config_scan.yml | 4 +++- .../workflows/{setup.yml => get_singularity.yml} | 7 ++----- 3 files changed, 13 insertions(+), 13 deletions(-) rename .github/workflows/{setup.yml => get_singularity.yml} (88%) diff --git a/.github/workflows/code_check.yml b/.github/workflows/code_check.yml index cfdaa77..f826811 100644 --- a/.github/workflows/code_check.yml +++ b/.github/workflows/code_check.yml @@ -10,7 +10,7 @@ on: jobs: init: - uses: ./.github/workflows/setup.yml + uses: ./.github/workflows/get_singularity.yml with: singularity_image: oras://ghcr.io/berenslab/retinal-rl:singularity-image-latest sif_file: retinal-rl_singularity-image-latest.sif @@ -19,12 +19,13 @@ jobs: needs: init runs-on: ubuntu-latest steps: - - name: list directory - run: ls - - uses: actions/checkout@v4 - - name: list directory - run: ls + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Fetch all branches + run: git fetch --all - name: Run Pylint run: | singularity exec ~/singularity_images/retinal-rl_singularity-image-latest.sif \ - pylint $(git diff --name-only origin/master HEAD -- '*.py') + pylint $(git diff --name-only origin/master...HEAD -- '*.py') diff --git a/.github/workflows/config_scan.yml b/.github/workflows/config_scan.yml index 630fa5b..51e5df4 100644 --- a/.github/workflows/config_scan.yml +++ b/.github/workflows/config_scan.yml @@ -3,7 +3,7 @@ on: [pull_request,workflow_dispatch] jobs: init: - uses: ./.github/workflows/setup.yml + uses: ./.github/workflows/get_singularity.yml with: singularity_image: oras://ghcr.io/berenslab/retinal-rl:singularity-image-latest sif_file: retinal-rl_singularity-image-latest.sif @@ -12,7 +12,9 @@ jobs: needs: init runs-on: ubuntu-latest steps: + - uses: actions/checkout@v4 - name: Scan classification config run: | + cp -r resources/config_templates/* config/ singularity exec ~/singularity_images/retinal-rl_singularity-image-latest.sif \ python main.py -m +experiment=cifar10-class-recon command=scan system.device=cpu \ No newline at end of file diff --git a/.github/workflows/setup.yml b/.github/workflows/get_singularity.yml similarity index 88% rename from .github/workflows/setup.yml rename to .github/workflows/get_singularity.yml index efdc217..411548e 100644 --- a/.github/workflows/setup.yml +++ b/.github/workflows/get_singularity.yml @@ -1,4 +1,4 @@ -name: Pull Singularity container & Setup Repository +name: Get Singularity Container on: workflow_call: @@ -13,10 +13,7 @@ on: jobs: init: runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v4 - + steps: - name: Setup Apptainer uses: eWaterCycle/setup-apptainer@v2 with: From e8fd44d061aa21c8812b27f1d2d5c3953b29894a Mon Sep 17 00:00:00 2001 From: Fabio Seel Date: Thu, 10 Oct 2024 16:07:09 +0200 Subject: [PATCH 34/49] fix: screw reusable actions, hopefully it runs now --- .github/workflows/code_check.yml | 30 +++++++++++++++++------ .github/workflows/config_scan.yml | 27 +++++++++++++++------ .github/workflows/get_singularity.yml | 35 --------------------------- 3 files changed, 42 insertions(+), 50 deletions(-) delete mode 100644 .github/workflows/get_singularity.yml diff --git a/.github/workflows/code_check.yml b/.github/workflows/code_check.yml index f826811..3c61a87 100644 --- a/.github/workflows/code_check.yml +++ b/.github/workflows/code_check.yml @@ -8,17 +8,31 @@ on: branches: - main -jobs: - init: - uses: ./.github/workflows/get_singularity.yml - with: - singularity_image: oras://ghcr.io/berenslab/retinal-rl:singularity-image-latest - sif_file: retinal-rl_singularity-image-latest.sif +env: + singularity_image: oras://ghcr.io/berenslab/retinal-rl:singularity-image-latest + sif_file: retinal-rl_singularity-image-latest.sif - lint: - needs: init +jobs: + check: runs-on: ubuntu-latest steps: + - name: Setup Apptainer + uses: eWaterCycle/setup-apptainer@v2 + with: + apptainer-version: 1.3.0 + - name: Cache Singularity Image + id: cache-singularity + uses: actions/cache@v3 + with: + path: ~/${{ env.sif_file }} + key: ${{ runner.os }}-singularity-${{ hashFiles('~/resources/retinal-rl.def') }} + - name: Pull Singularity container + if: steps.cache-singularity.outputs.cache-hit != 'true' + run: | + singularity registry login --username ${{ github.actor }} --password ${{ secrets.GITHUB_TOKEN }} oras://ghcr.io + singularity pull ${{ env.sif_file }} ${{ env.singularity_image }} + + - name: Checkout code uses: actions/checkout@v4 with: diff --git a/.github/workflows/config_scan.yml b/.github/workflows/config_scan.yml index 51e5df4..2978c3c 100644 --- a/.github/workflows/config_scan.yml +++ b/.github/workflows/config_scan.yml @@ -1,17 +1,30 @@ name: Scan Configs on: [pull_request,workflow_dispatch] -jobs: - init: - uses: ./.github/workflows/get_singularity.yml - with: - singularity_image: oras://ghcr.io/berenslab/retinal-rl:singularity-image-latest - sif_file: retinal-rl_singularity-image-latest.sif +env: + singularity_image: oras://ghcr.io/berenslab/retinal-rl:singularity-image-latest + sif_file: retinal-rl_singularity-image-latest.sif +jobs: scan: - needs: init runs-on: ubuntu-latest steps: + - name: Setup Apptainer + uses: eWaterCycle/setup-apptainer@v2 + with: + apptainer-version: 1.3.0 + - name: Cache Singularity Image + id: cache-singularity + uses: actions/cache@v3 + with: + path: ~/${{ env.sif_file }} + key: ${{ runner.os }}-singularity-${{ hashFiles('~/resources/retinal-rl.def') }} + - name: Pull Singularity container + if: steps.cache-singularity.outputs.cache-hit != 'true' + run: | + singularity registry login --username ${{ github.actor }} --password ${{ secrets.GITHUB_TOKEN }} oras://ghcr.io + singularity pull ${{ env.sif_file }} ${{ env.singularity_image }} + - uses: actions/checkout@v4 - name: Scan classification config run: | diff --git a/.github/workflows/get_singularity.yml b/.github/workflows/get_singularity.yml deleted file mode 100644 index 411548e..0000000 --- a/.github/workflows/get_singularity.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: Get Singularity Container - -on: - workflow_call: - inputs: - singularity_image: - required: true - type: string - sif_file: - required: true - type: string - -jobs: - init: - runs-on: ubuntu-latest - steps: - - name: Setup Apptainer - uses: eWaterCycle/setup-apptainer@v2 - with: - apptainer-version: 1.3.0 - - - name: Cache Singularity Image - id: cache-singularity - uses: actions/cache@v3 - with: - path: ~/singularity_images - key: ${{ runner.os }}-singularity-${{ hashFiles('**/singularity_image_url.txt') }} - - - name: Pull Singularity container - if: steps.cache-singularity.outputs.cache-hit != 'true' - run: | - mkdir -p ~/singularity_images - singularity registry login --username ${{ github.actor }} --password ${{ secrets.GITHUB_TOKEN }} oras://ghcr.io - singularity pull --dir ~/singularity_images ${{ inputs.sif_file }} ${{ inputs.singularity_image }} - echo "${{ inputs.singularity_image }}" > ~/singularity_images/singularity_image_url.txt \ No newline at end of file From ff58590c4fbb4054a03de66704984d2d5c75f6c6 Mon Sep 17 00:00:00 2001 From: Fabio Seel Date: Thu, 10 Oct 2024 16:09:32 +0200 Subject: [PATCH 35/49] fix: changed sif file path --- .github/workflows/code_check.yml | 2 +- .github/workflows/config_scan.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/code_check.yml b/.github/workflows/code_check.yml index 3c61a87..329612c 100644 --- a/.github/workflows/code_check.yml +++ b/.github/workflows/code_check.yml @@ -41,5 +41,5 @@ jobs: run: git fetch --all - name: Run Pylint run: | - singularity exec ~/singularity_images/retinal-rl_singularity-image-latest.sif \ + singularity exec ${{ env.sif_file }} \ pylint $(git diff --name-only origin/master...HEAD -- '*.py') diff --git a/.github/workflows/config_scan.yml b/.github/workflows/config_scan.yml index 2978c3c..45afddc 100644 --- a/.github/workflows/config_scan.yml +++ b/.github/workflows/config_scan.yml @@ -29,5 +29,5 @@ jobs: - name: Scan classification config run: | cp -r resources/config_templates/* config/ - singularity exec ~/singularity_images/retinal-rl_singularity-image-latest.sif \ + singularity exec ${{ env.sif_file }} \ python main.py -m +experiment=cifar10-class-recon command=scan system.device=cpu \ No newline at end of file From 17db57ecf26540540d5ea89b37803badbf038b4f Mon Sep 17 00:00:00 2001 From: Fabio Seel Date: Thu, 10 Oct 2024 16:18:56 +0200 Subject: [PATCH 36/49] exp: show state of directory before / after checkout --- .github/workflows/code_check.yml | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/.github/workflows/code_check.yml b/.github/workflows/code_check.yml index 329612c..ad3cb74 100644 --- a/.github/workflows/code_check.yml +++ b/.github/workflows/code_check.yml @@ -32,14 +32,21 @@ jobs: singularity registry login --username ${{ github.actor }} --password ${{ secrets.GITHUB_TOKEN }} oras://ghcr.io singularity pull ${{ env.sif_file }} ${{ env.singularity_image }} - + - name: List current state + run: | + ls + pwd - name: Checkout code uses: actions/checkout@v4 with: fetch-depth: 0 - name: Fetch all branches run: git fetch --all - - name: Run Pylint - run: | - singularity exec ${{ env.sif_file }} \ - pylint $(git diff --name-only origin/master...HEAD -- '*.py') + - name: List current state + run: | + ls + pwd + # - name: Run Pylint + # run: | + # singularity exec ${{ env.sif_file }} \ + # pylint $(git diff --name-only origin/master...HEAD -- '*.py') From 298af6d020cdd85c1b83ae4a7cd1548266640fff Mon Sep 17 00:00:00 2001 From: Fabio Seel Date: Thu, 10 Oct 2024 16:22:29 +0200 Subject: [PATCH 37/49] fix(?): checkout first before pulling container --- .github/workflows/code_check.yml | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/.github/workflows/code_check.yml b/.github/workflows/code_check.yml index ad3cb74..082be82 100644 --- a/.github/workflows/code_check.yml +++ b/.github/workflows/code_check.yml @@ -16,6 +16,17 @@ jobs: check: runs-on: ubuntu-latest steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Fetch all branches + run: git fetch --all + + - name: List current state + run: | + ls + pwd - name: Setup Apptainer uses: eWaterCycle/setup-apptainer@v2 with: @@ -31,17 +42,7 @@ jobs: run: | singularity registry login --username ${{ github.actor }} --password ${{ secrets.GITHUB_TOKEN }} oras://ghcr.io singularity pull ${{ env.sif_file }} ${{ env.singularity_image }} - - - name: List current state - run: | - ls - pwd - - name: Checkout code - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Fetch all branches - run: git fetch --all + - name: List current state run: | ls From 41ed433843de2804a393beda595bfdd7ae8d0b28 Mon Sep 17 00:00:00 2001 From: Fabio Seel Date: Thu, 10 Oct 2024 16:25:04 +0200 Subject: [PATCH 38/49] fix(?): path for cache --- .github/workflows/code_check.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/code_check.yml b/.github/workflows/code_check.yml index 082be82..2851719 100644 --- a/.github/workflows/code_check.yml +++ b/.github/workflows/code_check.yml @@ -35,14 +35,14 @@ jobs: id: cache-singularity uses: actions/cache@v3 with: - path: ~/${{ env.sif_file }} + path: ${{ env.sif_file }} key: ${{ runner.os }}-singularity-${{ hashFiles('~/resources/retinal-rl.def') }} - name: Pull Singularity container if: steps.cache-singularity.outputs.cache-hit != 'true' run: | singularity registry login --username ${{ github.actor }} --password ${{ secrets.GITHUB_TOKEN }} oras://ghcr.io singularity pull ${{ env.sif_file }} ${{ env.singularity_image }} - + - name: List current state run: | ls From 4278a6afbd75d6484cb41298db0ffa4ebb1049a5 Mon Sep 17 00:00:00 2001 From: Fabio Seel Date: Thu, 10 Oct 2024 16:27:18 +0200 Subject: [PATCH 39/49] fix: step order/cache order in config_scan --- .github/workflows/config_scan.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/config_scan.yml b/.github/workflows/config_scan.yml index 45afddc..9bc2faa 100644 --- a/.github/workflows/config_scan.yml +++ b/.github/workflows/config_scan.yml @@ -9,6 +9,7 @@ jobs: scan: runs-on: ubuntu-latest steps: + - uses: actions/checkout@v4 - name: Setup Apptainer uses: eWaterCycle/setup-apptainer@v2 with: @@ -17,7 +18,7 @@ jobs: id: cache-singularity uses: actions/cache@v3 with: - path: ~/${{ env.sif_file }} + path: ${{ env.sif_file }} key: ${{ runner.os }}-singularity-${{ hashFiles('~/resources/retinal-rl.def') }} - name: Pull Singularity container if: steps.cache-singularity.outputs.cache-hit != 'true' @@ -25,7 +26,6 @@ jobs: singularity registry login --username ${{ github.actor }} --password ${{ secrets.GITHUB_TOKEN }} oras://ghcr.io singularity pull ${{ env.sif_file }} ${{ env.singularity_image }} - - uses: actions/checkout@v4 - name: Scan classification config run: | cp -r resources/config_templates/* config/ From c2fd3cb8d12e4159fd2eec798017466e123b2fe1 Mon Sep 17 00:00:00 2001 From: Fabio Seel Date: Thu, 10 Oct 2024 16:27:54 +0200 Subject: [PATCH 40/49] fix: enable pylint instead of listing again --- .github/workflows/code_check.yml | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/.github/workflows/code_check.yml b/.github/workflows/code_check.yml index 2851719..9b66005 100644 --- a/.github/workflows/code_check.yml +++ b/.github/workflows/code_check.yml @@ -23,10 +23,6 @@ jobs: - name: Fetch all branches run: git fetch --all - - name: List current state - run: | - ls - pwd - name: Setup Apptainer uses: eWaterCycle/setup-apptainer@v2 with: @@ -43,11 +39,7 @@ jobs: singularity registry login --username ${{ github.actor }} --password ${{ secrets.GITHUB_TOKEN }} oras://ghcr.io singularity pull ${{ env.sif_file }} ${{ env.singularity_image }} - - name: List current state - run: | - ls - pwd - # - name: Run Pylint - # run: | - # singularity exec ${{ env.sif_file }} \ - # pylint $(git diff --name-only origin/master...HEAD -- '*.py') + - name: Run Pylint + run: | + singularity exec ${{ env.sif_file }} \ + pylint $(git diff --name-only origin/master...HEAD -- '*.py') From c7a8a694c848f78e9e6dabc7f2f6c269fde9eca7 Mon Sep 17 00:00:00 2001 From: Fabio Seel Date: Thu, 10 Oct 2024 16:40:08 +0200 Subject: [PATCH 41/49] fix: add pylintrc adding the repository to python path --- .pylintrc | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .pylintrc diff --git a/.pylintrc b/.pylintrc new file mode 100644 index 0000000..8f1de74 --- /dev/null +++ b/.pylintrc @@ -0,0 +1,2 @@ +[MASTER] +init-hook='import sys; sys.path.append(".")' \ No newline at end of file From 00b55868f3b8a553b897318ee9285ae49f95802a Mon Sep 17 00:00:00 2001 From: Fabio Seel Date: Thu, 10 Oct 2024 16:42:55 +0200 Subject: [PATCH 42/49] feat: restore code check only if py files changed --- .github/workflows/code_check.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/code_check.yml b/.github/workflows/code_check.yml index 9b66005..ec5f79d 100644 --- a/.github/workflows/code_check.yml +++ b/.github/workflows/code_check.yml @@ -2,8 +2,8 @@ name: Code Checking on: push: - # paths: - # - '**/*.py' + paths: + - '**/*.py' pull_request: branches: - main From f06ecc5f4caee2473c3650d159580c79a190e31c Mon Sep 17 00:00:00 2001 From: Fabio Seel Date: Thu, 10 Oct 2024 16:57:47 +0200 Subject: [PATCH 43/49] fix: make code check run on pull requests to master --- .github/workflows/code_check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/code_check.yml b/.github/workflows/code_check.yml index ec5f79d..69fc6cd 100644 --- a/.github/workflows/code_check.yml +++ b/.github/workflows/code_check.yml @@ -6,7 +6,7 @@ on: - '**/*.py' pull_request: branches: - - main + - master env: singularity_image: oras://ghcr.io/berenslab/retinal-rl:singularity-image-latest From 7770a4b3c43369bb2fe137480076386f56cf851e Mon Sep 17 00:00:00 2001 From: Fabio Seel Date: Thu, 10 Oct 2024 17:04:25 +0200 Subject: [PATCH 44/49] fix: make cache hit branch independent --- .github/workflows/code_check.yml | 2 ++ .github/workflows/config_scan.yml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/.github/workflows/code_check.yml b/.github/workflows/code_check.yml index 69fc6cd..6716b2c 100644 --- a/.github/workflows/code_check.yml +++ b/.github/workflows/code_check.yml @@ -33,6 +33,8 @@ jobs: with: path: ${{ env.sif_file }} key: ${{ runner.os }}-singularity-${{ hashFiles('~/resources/retinal-rl.def') }} + restore-keys: | + ${{ runner.os }}-singularity- - name: Pull Singularity container if: steps.cache-singularity.outputs.cache-hit != 'true' run: | diff --git a/.github/workflows/config_scan.yml b/.github/workflows/config_scan.yml index 9bc2faa..8f6051b 100644 --- a/.github/workflows/config_scan.yml +++ b/.github/workflows/config_scan.yml @@ -20,6 +20,8 @@ jobs: with: path: ${{ env.sif_file }} key: ${{ runner.os }}-singularity-${{ hashFiles('~/resources/retinal-rl.def') }} + restore-keys: | + ${{ runner.os }}-singularity- - name: Pull Singularity container if: steps.cache-singularity.outputs.cache-hit != 'true' run: | From 6fbface71d4d93a38be8669fadb3ab14aaa84060 Mon Sep 17 00:00:00 2001 From: Fabio Seel Date: Fri, 11 Oct 2024 10:02:16 +0200 Subject: [PATCH 45/49] revert: cross-branch caching only possible in child branches --- .github/workflows/code_check.yml | 2 -- .github/workflows/config_scan.yml | 2 -- 2 files changed, 4 deletions(-) diff --git a/.github/workflows/code_check.yml b/.github/workflows/code_check.yml index 6716b2c..69fc6cd 100644 --- a/.github/workflows/code_check.yml +++ b/.github/workflows/code_check.yml @@ -33,8 +33,6 @@ jobs: with: path: ${{ env.sif_file }} key: ${{ runner.os }}-singularity-${{ hashFiles('~/resources/retinal-rl.def') }} - restore-keys: | - ${{ runner.os }}-singularity- - name: Pull Singularity container if: steps.cache-singularity.outputs.cache-hit != 'true' run: | diff --git a/.github/workflows/config_scan.yml b/.github/workflows/config_scan.yml index 8f6051b..9bc2faa 100644 --- a/.github/workflows/config_scan.yml +++ b/.github/workflows/config_scan.yml @@ -20,8 +20,6 @@ jobs: with: path: ${{ env.sif_file }} key: ${{ runner.os }}-singularity-${{ hashFiles('~/resources/retinal-rl.def') }} - restore-keys: | - ${{ runner.os }}-singularity- - name: Pull Singularity container if: steps.cache-singularity.outputs.cache-hit != 'true' run: | From 426d0d12e2ce5bb4a5e842bf47f922ef62e5e4b6 Mon Sep 17 00:00:00 2001 From: Fabio Seel Date: Fri, 11 Oct 2024 10:11:11 +0200 Subject: [PATCH 46/49] fix: doom_creator/templates.py linting errors --- doom_creator/util/templates.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/doom_creator/util/templates.py b/doom_creator/util/templates.py index f093ebf..cbd8746 100644 --- a/doom_creator/util/templates.py +++ b/doom_creator/util/templates.py @@ -1 +1,8 @@ +"""Templates for doom scenario creation + +This module provides the templates for acs scripts, decorate +definitions and the overall config (vizdoom) +""" from doom_creator.util._templates import acs, decorate, vizdoom + +__all__ = ['acs', 'decorate', 'vizdoom'] From 3b7d091a9413575b97c1bddb44972be8542f9685 Mon Sep 17 00:00:00 2001 From: Fabio Seel Date: Fri, 11 Oct 2024 10:24:39 +0200 Subject: [PATCH 47/49] fix: restore keys in action needed for cross branch access? --- .github/workflows/code_check.yml | 3 +++ .github/workflows/config_scan.yml | 3 +++ 2 files changed, 6 insertions(+) diff --git a/.github/workflows/code_check.yml b/.github/workflows/code_check.yml index 69fc6cd..dcd5852 100644 --- a/.github/workflows/code_check.yml +++ b/.github/workflows/code_check.yml @@ -33,6 +33,9 @@ jobs: with: path: ${{ env.sif_file }} key: ${{ runner.os }}-singularity-${{ hashFiles('~/resources/retinal-rl.def') }} + restore-keys: | + ${{ runner.os }}-singularity-${{ hashFiles('~/resources/retinal-rl.def') }} + ${{ runner.os }}-singularity- - name: Pull Singularity container if: steps.cache-singularity.outputs.cache-hit != 'true' run: | diff --git a/.github/workflows/config_scan.yml b/.github/workflows/config_scan.yml index 9bc2faa..929ebb6 100644 --- a/.github/workflows/config_scan.yml +++ b/.github/workflows/config_scan.yml @@ -20,6 +20,9 @@ jobs: with: path: ${{ env.sif_file }} key: ${{ runner.os }}-singularity-${{ hashFiles('~/resources/retinal-rl.def') }} + restore-keys: | + ${{ runner.os }}-singularity-${{ hashFiles('~/resources/retinal-rl.def') }} + ${{ runner.os }}-singularity- - name: Pull Singularity container if: steps.cache-singularity.outputs.cache-hit != 'true' run: | From b7c698c3da1527cf87015093a36fddb773201df3 Mon Sep 17 00:00:00 2001 From: Fabio Seel Date: Fri, 11 Oct 2024 10:29:47 +0200 Subject: [PATCH 48/49] fix: pylint suggestions for vizdoom template --- doom_creator/util/_templates/vizdoom.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/doom_creator/util/_templates/vizdoom.py b/doom_creator/util/_templates/vizdoom.py index 52a05ea..eb03d17 100644 --- a/doom_creator/util/_templates/vizdoom.py +++ b/doom_creator/util/_templates/vizdoom.py @@ -1,5 +1,13 @@ -def config(scenario_name): - return """\ +""" +This module contains a dummy for a vizdoom config. +""" + + +def config(scenario_name: str): + """Returns a config for a vizdoom game, + referencing {scenario_name}.zip as the scenario.""" + + return f"""\ doom_scenario_path = {scenario_name}.zip living_reward = 0.0 @@ -32,6 +40,4 @@ def config(scenario_name): available_game_variables = {{ HEALTH }} mode = PLAYER -""".format( - scenario_name=scenario_name - ) +""" From 5f8ac4353c74692aef9c6c0fc2d5ba28a6b5848d Mon Sep 17 00:00:00 2001 From: Fabio Seel Date: Fri, 11 Oct 2024 11:21:36 +0200 Subject: [PATCH 49/49] feat: make build singularity container run on pull requests where def file changed --- .github/workflows/container_build.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/container_build.yml b/.github/workflows/container_build.yml index 07760db..b047ef2 100644 --- a/.github/workflows/container_build.yml +++ b/.github/workflows/container_build.yml @@ -6,6 +6,11 @@ on: push: paths: - 'resources/retinal-rl.def' + pull_request: + branches: + - master + paths: + - 'resources/retinal-rl.def' jobs: singularity-build: