From cf5e85f7ca6276fefabc6e5d146ed2845c7fe40b Mon Sep 17 00:00:00 2001 From: nada moukaddem Date: Mon, 19 Feb 2024 14:23:39 +0100 Subject: [PATCH 01/14] add black formatter to check/format the code to the ci.yml file --- .github/workflows/ci.yml | 16 ++++++++++++++-- pyproject.toml | 2 +- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d11df938..e696b497 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,13 +17,25 @@ jobs: - name: uses: actions/checkout@v3 - - name: Set up Python 3.10.5 + - name: Set up Python 3.10.12 uses: actions/setup-python@v3 with: - python-version: "3.10.5" + python-version: "3.10.12" - name: Install dependencies run: python -m pip install ".[test]" - name: Test with pytest run: python -m pytest + + linter_name: + name: Run Black formatter + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Run Black formatter + uses: rickstaa/action-black@v1 + with: + black_args: ". --check" diff --git a/pyproject.toml b/pyproject.toml index 5f2ed86c..96497658 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -52,7 +52,7 @@ release = [ ] test = [ - "pytest", + "pytest==7.4.4", "pytest-black", "pytest-cases", "pytest-cov", From 62dd98c484d7f5365f9a15e62a9389ea48ef2e0c Mon Sep 17 00:00:00 2001 From: nadamoukaddem Date: Thu, 22 Feb 2024 15:14:50 +0100 Subject: [PATCH 02/14] Format code with Black --- src/wf_psf/data/training_preprocessing.py | 1 + src/wf_psf/psf_models/zernikes.py | 1 + src/wf_psf/run.py | 1 + src/wf_psf/tests/conftest.py | 1 + src/wf_psf/tests/metrics_test.py | 1 + src/wf_psf/tests/test_utils/conftest.py | 1 + src/wf_psf/training/train.py | 12 ++++++------ src/wf_psf/utils/configs_handler.py | 7 ++++--- 8 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/wf_psf/data/training_preprocessing.py b/src/wf_psf/data/training_preprocessing.py index 58e23d1e..2002211f 100644 --- a/src/wf_psf/data/training_preprocessing.py +++ b/src/wf_psf/data/training_preprocessing.py @@ -5,6 +5,7 @@ :Authors: Jennifer Pollack and Tobias Liaudat """ + import numpy as np import wf_psf.utils.utils as utils import tensorflow as tf diff --git a/src/wf_psf/psf_models/zernikes.py b/src/wf_psf/psf_models/zernikes.py index 9c099fb2..3530a030 100644 --- a/src/wf_psf/psf_models/zernikes.py +++ b/src/wf_psf/psf_models/zernikes.py @@ -5,6 +5,7 @@ :Author: Tobias Liaudat and Jennifer Pollack """ + import numpy as np import zernike as zk import tensorflow as tf diff --git a/src/wf_psf/run.py b/src/wf_psf/run.py index 304e2fbf..828a6e17 100644 --- a/src/wf_psf/run.py +++ b/src/wf_psf/run.py @@ -5,6 +5,7 @@ :Author: Jennifer Pollack """ + import argparse from wf_psf.utils.read_config import read_stream from wf_psf.utils.io import FileIOHandler diff --git a/src/wf_psf/tests/conftest.py b/src/wf_psf/tests/conftest.py index eb5b350f..7b8dc462 100644 --- a/src/wf_psf/tests/conftest.py +++ b/src/wf_psf/tests/conftest.py @@ -7,6 +7,7 @@ """ + import pytest from wf_psf.utils.read_config import RecursiveNamespace from wf_psf.training.train import TrainingParamsHandler diff --git a/src/wf_psf/tests/metrics_test.py b/src/wf_psf/tests/metrics_test.py index c22c1b80..b81c9a96 100644 --- a/src/wf_psf/tests/metrics_test.py +++ b/src/wf_psf/tests/metrics_test.py @@ -5,6 +5,7 @@ :Author: Jennifer Pollack """ + import pytest from wf_psf.utils.read_config import RecursiveNamespace from wf_psf.training import train diff --git a/src/wf_psf/tests/test_utils/conftest.py b/src/wf_psf/tests/test_utils/conftest.py index 6df37416..7d7a5a34 100644 --- a/src/wf_psf/tests/test_utils/conftest.py +++ b/src/wf_psf/tests/test_utils/conftest.py @@ -7,6 +7,7 @@ """ + import pytest import os diff --git a/src/wf_psf/training/train.py b/src/wf_psf/training/train.py index b74ebf92..a0da107d 100644 --- a/src/wf_psf/training/train.py +++ b/src/wf_psf/training/train.py @@ -397,13 +397,13 @@ def train( # Save optimisation history in the saving dict if psf_model.save_optim_history_param: - saving_optim_hist[ - "param_cycle{}".format(current_cycle) - ] = hist_param.history + saving_optim_hist["param_cycle{}".format(current_cycle)] = ( + hist_param.history + ) if psf_model.save_optim_history_nonparam: - saving_optim_hist[ - "nonparam_cycle{}".format(current_cycle) - ] = hist_non_param.history + saving_optim_hist["nonparam_cycle{}".format(current_cycle)] = ( + hist_non_param.history + ) # Save last cycle if no cycles were saved if not training_handler.multi_cycle_params.save_all_cycles: diff --git a/src/wf_psf/utils/configs_handler.py b/src/wf_psf/utils/configs_handler.py index bb8dc688..3ee7aaf4 100644 --- a/src/wf_psf/utils/configs_handler.py +++ b/src/wf_psf/utils/configs_handler.py @@ -6,6 +6,7 @@ :Authors: Jennifer Pollack """ + import numpy as np from wf_psf.utils.read_config import read_conf from wf_psf.data.training_preprocessing import TrainingDataHandler, TestDataHandler @@ -412,9 +413,9 @@ def call_plot_config_handler_run(self, model_metrics): ) # Update metrics_confs dict with latest result - plots_config_handler.metrics_confs[ - self._file_handler.workdir - ] = self.metrics_conf + plots_config_handler.metrics_confs[self._file_handler.workdir] = ( + self.metrics_conf + ) # Update metric results dict with latest result plots_config_handler.list_of_metrics_dict[self._file_handler.workdir] = [ From 3b5595f55cca878f6bb7226668ebd667b0323a70 Mon Sep 17 00:00:00 2001 From: nadamoukaddem Date: Thu, 22 Feb 2024 15:43:56 +0100 Subject: [PATCH 03/14] removed black formatter from ci.yml --- .github/workflows/ci.yml | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e696b497..c0b7afcd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,15 +27,3 @@ jobs: - name: Test with pytest run: python -m pytest - - linter_name: - name: Run Black formatter - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Run Black formatter - uses: rickstaa/action-black@v1 - with: - black_args: ". --check" From 26d85ace5188c3b0e48d69a09bc3359db0c77614 Mon Sep 17 00:00:00 2001 From: nadamoukaddem Date: Fri, 23 Feb 2024 11:54:03 +0100 Subject: [PATCH 04/14] Add matrix strategy to CI workflow for testing with multiple Python versions --- .github/workflows/ci.yml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c0b7afcd..1673d7bd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -# This workflow will install Python dependencies, run tests and lint with a single version of Python +# This workflow will install Python dependencies, run tests, and lint with multiple versions of Python # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python name: CI @@ -11,19 +11,24 @@ on: jobs: test-full: - runs-on: [ubuntu-latest] + runs-on: ubuntu-latest + + strategy: + matrix: + python-version: ["pypy3.9", "pypy3.10", "3.9", "3.10", "3.11", "3.12"] steps: - - name: + - name: Checkout code uses: actions/checkout@v3 - - name: Set up Python 3.10.12 + - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v3 with: - python-version: "3.10.12" + python-version: ${{ matrix.python-version }} - name: Install dependencies run: python -m pip install ".[test]" - name: Test with pytest run: python -m pytest + From e3a64c54fe4f556470f346058987fd3f5d694503 Mon Sep 17 00:00:00 2001 From: nadamoukaddem Date: Fri, 23 Feb 2024 14:21:31 +0100 Subject: [PATCH 05/14] remove matrix strategy to CI workflow --- .github/workflows/ci.yml | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1673d7bd..c0b7afcd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -# This workflow will install Python dependencies, run tests, and lint with multiple versions of Python +# This workflow will install Python dependencies, run tests and lint with a single version of Python # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python name: CI @@ -11,24 +11,19 @@ on: jobs: test-full: - runs-on: ubuntu-latest - - strategy: - matrix: - python-version: ["pypy3.9", "pypy3.10", "3.9", "3.10", "3.11", "3.12"] + runs-on: [ubuntu-latest] steps: - - name: Checkout code + - name: uses: actions/checkout@v3 - - name: Set up Python ${{ matrix.python-version }} + - name: Set up Python 3.10.12 uses: actions/setup-python@v3 with: - python-version: ${{ matrix.python-version }} + python-version: "3.10.12" - name: Install dependencies run: python -m pip install ".[test]" - name: Test with pytest run: python -m pytest - From ee030dad5e880d2902668aa0f08c2d65f52d7bcd Mon Sep 17 00:00:00 2001 From: nadamoukaddem Date: Fri, 23 Feb 2024 17:00:55 +0100 Subject: [PATCH 06/14] re-added matrix to CI --- .github/workflows/ci.yml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c0b7afcd..20f70c33 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -# This workflow will install Python dependencies, run tests and lint with a single version of Python +# This workflow will install Python dependencies, run tests, and lint with multiple versions of Python # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python name: CI @@ -11,19 +11,24 @@ on: jobs: test-full: - runs-on: [ubuntu-latest] + runs-on: ubuntu-latest + + strategy: + matrix: + python-version: ["3.9", "3.10"] steps: - - name: + - name: Checkout code uses: actions/checkout@v3 - - name: Set up Python 3.10.12 + - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v3 with: - python-version: "3.10.12" + python-version: ${{ matrix.python-version }} - name: Install dependencies run: python -m pip install ".[test]" - name: Test with pytest run: python -m pytest + From b39f1ae81e4d6ca1067871cf362198c6dd437beb Mon Sep 17 00:00:00 2001 From: nadamoukaddem Date: Mon, 26 Feb 2024 10:02:12 +0100 Subject: [PATCH 07/14] Add Python versions 3.11 and 3.12 to the matrix in CI --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 20f70c33..08fce2f3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,7 @@ jobs: strategy: matrix: - python-version: ["3.9", "3.10"] + python-version: ["3.9", "3.10","3.11","3.12"] steps: - name: Checkout code From 5ae288be014678c504f3d909e084b4c026cea58e Mon Sep 17 00:00:00 2001 From: nadamoukaddem Date: Tue, 27 Feb 2024 17:58:58 +0100 Subject: [PATCH 08/14] Remove Python versions 3.11 and 3.12 to the matrix in CI --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 08fce2f3..20f70c33 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,7 @@ jobs: strategy: matrix: - python-version: ["3.9", "3.10","3.11","3.12"] + python-version: ["3.9", "3.10"] steps: - name: Checkout code From dad37ddb16803c51ea39def1b8b0c009e301381f Mon Sep 17 00:00:00 2001 From: nadamoukaddem Date: Thu, 29 Feb 2024 12:17:04 +0100 Subject: [PATCH 09/14] remove pytest-black, run black during CI and add checkbox in PR --- .github/pull_request_template.md | 6 ++++++ .github/workflows/ci.yml | 10 +++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index af4136c2..5b057e36 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -25,3 +25,9 @@ - [ ] All changed files have been checked and comments provided to the developer - [ ] All of the reviewer's comments have been satisfactorily addressed by the developer - [ ] All Validation tests for the reported error are passing + +## CI Log Review + +> Reviewers should check the following box after reviewing the CI log to evaluate whether any files had to be changed or not. + +- [ ] I have reviewed the CI log to evaluate whether any files had to be changed or not. diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 20f70c33..0235eab1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,7 +28,15 @@ jobs: - name: Install dependencies run: python -m pip install ".[test]" - + - name: Test with pytest run: python -m pytest + # Add Black formatter + - name: Install Black formatter + run: python -m pip install black + + - name: Check code formatting with Black + run: black . --check --diff + + From 447a4000b3b5e4fe724d0bd1cc40458205c516b8 Mon Sep 17 00:00:00 2001 From: nadamoukaddem Date: Thu, 29 Feb 2024 14:15:42 +0100 Subject: [PATCH 10/14] remove pytest-black --- pyproject.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 96497658..3a8dc764 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -52,8 +52,8 @@ release = [ ] test = [ - "pytest==7.4.4", - "pytest-black", + "pytest", + #"pytest-black", "pytest-cases", "pytest-cov", "pytest-emoji", @@ -77,7 +77,7 @@ convention = "numpy" [tool.pytest.ini_options] addopts = [ "--verbose", - "--black", + #"--black", "--emoji", "--cov=wf_psf", "--cov-report=term-missing", From dbb576d5b3f65409ccccb79fcb83d34a55ff6b6c Mon Sep 17 00:00:00 2001 From: nadamoukaddem Date: Fri, 1 Mar 2024 11:59:04 +0100 Subject: [PATCH 11/14] remove pytest-cases --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 3a8dc764..5aeddfce 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -54,7 +54,7 @@ release = [ test = [ "pytest", #"pytest-black", - "pytest-cases", + #"pytest-cases", "pytest-cov", "pytest-emoji", "pytest-raises", From 06978723238643f35a492c0cd4239459c5692a38 Mon Sep 17 00:00:00 2001 From: nadamoukaddem Date: Fri, 1 Mar 2024 16:40:35 +0100 Subject: [PATCH 12/14] modified the PR template --- .github/pull_request_template.md | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 5b057e36..007118a5 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -25,9 +25,4 @@ - [ ] All changed files have been checked and comments provided to the developer - [ ] All of the reviewer's comments have been satisfactorily addressed by the developer - [ ] All Validation tests for the reported error are passing - -## CI Log Review - -> Reviewers should check the following box after reviewing the CI log to evaluate whether any files had to be changed or not. - -- [ ] I have reviewed the CI log to evaluate whether any files had to be changed or not. +- [ ] I have reviewed the CI log to verify if any files require formatting with Black. If any files are found to be improperly formatted, I have provided comments indicating the need for formatting. From 12ca7c92373922a373bce398738d478f7a268763 Mon Sep 17 00:00:00 2001 From: nadamoukaddem Date: Mon, 4 Mar 2024 11:34:53 +0100 Subject: [PATCH 13/14] remove commented plugins --- pyproject.toml | 2 -- 1 file changed, 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 5aeddfce..f66cf571 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -53,8 +53,6 @@ release = [ test = [ "pytest", - #"pytest-black", - #"pytest-cases", "pytest-cov", "pytest-emoji", "pytest-raises", From d3b3619c11d103471b90523528dda9ef8f5f459e Mon Sep 17 00:00:00 2001 From: nadamoukaddem Date: Mon, 4 Mar 2024 14:49:31 +0100 Subject: [PATCH 14/14] remove commented black plugin from addopts --- pyproject.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index f66cf571..09bc2c74 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -75,7 +75,6 @@ convention = "numpy" [tool.pytest.ini_options] addopts = [ "--verbose", - #"--black", "--emoji", "--cov=wf_psf", "--cov-report=term-missing",