From 6892f942955790268093f5ac63575a1be89b640a Mon Sep 17 00:00:00 2001 From: Jared Lewis Date: Fri, 12 May 2023 12:12:38 +0200 Subject: [PATCH 1/4] chore(ci): Cleanup failing CI --- .coveragerc | 13 ---------- .github/workflows/ci-cd-workflow.yml | 6 ++--- CHANGELOG.rst | 10 ++++++++ pyproject.toml | 24 +++++++++++++++++++ setup.cfg | 6 +++-- .../adapters/ciceroscm_adapter/ciceroscm.py | 2 +- .../adapters/magicc7/magicc7.py | 6 ++++- src/openscm_runner/testing.py | 14 ++++++----- 8 files changed, 55 insertions(+), 26 deletions(-) delete mode 100644 .coveragerc diff --git a/.coveragerc b/.coveragerc deleted file mode 100644 index 5bdead9a..00000000 --- a/.coveragerc +++ /dev/null @@ -1,13 +0,0 @@ -[run] -branch = True -source = openscm_runner -omit = *_version.py,*adapters/magicc7*,*testing.py - -[report] -fail_under = 90 -exclude_lines = - if self.debug: - pragma: no cover - raise NotImplementedError - if __name__ == .__main__.: -ignore_errors = True diff --git a/.github/workflows/ci-cd-workflow.yml b/.github/workflows/ci-cd-workflow.yml index 4dda0c46..700f3f29 100644 --- a/.github/workflows/ci-cd-workflow.yml +++ b/.github/workflows/ci-cd-workflow.yml @@ -56,7 +56,7 @@ jobs: matrix: # no mac binary for CICERO so fails code coverage os: ["ubuntu-latest", "macos-latest", "windows-latest"] - python-version: [3.7, 3.8, 3.9] + python-version: [3.7, 3.8, 3.9, "3.10", 3.11] env: MIN_COVERAGE: 90 @@ -82,7 +82,7 @@ jobs: env: MAGICC_EXECUTABLE_7: bin/magicc/magicc-v7.5.3/bin/magicc run: | - pytest tests -r a --cov=openscm_runner --cov-report='' --cov-fail-under=$MIN_COVERAGE + pytest tests -r a --cov=openscm_runner --cov-report='term-missing' --cov-fail-under=$MIN_COVERAGE - name: Test with pytest macOS if: runner.os == 'macOS' env: @@ -134,7 +134,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.7, 3.8, 3.9] + python-version: [3.7, 3.8, 3.9, "3.10", 3.11] steps: - name: Checkout repository diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 88fee100..d1836928 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -17,6 +17,16 @@ The changes listed in this file are categorised as follows: Master ------ +Added +~~~~~ + +- (`#83 `_) Added support for Python v3.10 and v3.11 + +Changed +~~~~~~~ + +- (`#83 `_) Fix failing CI. ``fair`` is now pinned to < 2 + v0.12.0 - 2023-05-12 -------------------- diff --git a/pyproject.toml b/pyproject.toml index d88e8656..76b8deed 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,3 +7,27 @@ requires = [ build-backend = "setuptools.build_meta" [tool.setuptools_scm] + +[tool.coverage.run] +branch = true +source = [ + "src/openscm_runner" +] +omit = [ + "*_version.py", + # TODO: remove the exclusion for MAGICC + "*adapters/magicc7*", + "*testing.py" +] + +[tool.coverage.report] +fail_under = 90 +skip_empty = true +show_missing = true +ignore_errors = true + +# Regexes for lines to exclude from consideration in addition to the defaults +exclude_also = [ + # Don't complain about missing type checking code: + "if TYPE_CHECKING", +] diff --git a/setup.cfg b/setup.cfg index d8356b49..d72d03e2 100644 --- a/setup.cfg +++ b/setup.cfg @@ -32,6 +32,8 @@ classifiers = Programming Language :: Python :: 3.7 Programming Language :: Python :: 3.8 Programming Language :: Python :: 3.9 + Programming Language :: Python :: 3.10 + Programming Language :: Python :: 3.11 Topic :: Scientific/Engineering [options] @@ -54,7 +56,7 @@ where = src [options.extras_require] fair = - fair + fair < 2 magicc = pymagicc >= 2.0.0, < 3 @@ -74,7 +76,7 @@ notebooks = tests = codecov - coverage + coverage>=7 nbval pytest-cov pytest>=4.0 diff --git a/src/openscm_runner/adapters/ciceroscm_adapter/ciceroscm.py b/src/openscm_runner/adapters/ciceroscm_adapter/ciceroscm.py index 20adde27..bb13cf28 100644 --- a/src/openscm_runner/adapters/ciceroscm_adapter/ciceroscm.py +++ b/src/openscm_runner/adapters/ciceroscm_adapter/ciceroscm.py @@ -72,7 +72,7 @@ def get_version(cls): os.path.join(os.path.dirname(__file__), "utils_templates", "run_dir") ) try: - check_output(executable) + check_output(executable) # nosec except OSError as orig_exc: raise OSError( "CICERO-SCM is not available on your operating system" diff --git a/src/openscm_runner/adapters/magicc7/magicc7.py b/src/openscm_runner/adapters/magicc7/magicc7.py index 429755e0..30ca7a23 100644 --- a/src/openscm_runner/adapters/magicc7/magicc7.py +++ b/src/openscm_runner/adapters/magicc7/magicc7.py @@ -216,7 +216,11 @@ def get_version(cls): str The MAGICC7 version id """ - return check_output([cls._executable(), "--version"]).decode("utf-8").strip() + return ( + check_output([cls._executable(), "--version"]) # nosec + .decode("utf-8") + .strip() + ) @classmethod def _executable(cls): diff --git a/src/openscm_runner/testing.py b/src/openscm_runner/testing.py index 676a5412..22f84fed 100644 --- a/src/openscm_runner/testing.py +++ b/src/openscm_runner/testing.py @@ -189,18 +189,20 @@ def test_run(self, test_scenarios): out_config=None, ) - assert isinstance(res, ScmRun) - assert res["run_id"].min() == 0 # pylint: disable=compare-to-zero - assert res["run_id"].min() == 0 # pylint: disable=compare-to-zero - assert res["run_id"].max() == 8 + assert isinstance(res, ScmRun) # nosec + assert res["run_id"].min() == 0 # pylint: disable=compare-to-zero # nosec + assert res["run_id"].min() == 0 # pylint: disable=compare-to-zero # nosec + assert res["run_id"].max() == 8 # nosec - assert res.get_unique_meta("climate_model", no_duplicates=True) == "model_name" + assert ( + res.get_unique_meta("climate_model", no_duplicates=True) == "model_name" + ) # nosec assert set(res.get_unique_meta("variable")) == { "expected", "output", "variables", - } + } # nosec # output value checks e.g. npt.assert_allclose( From a667a1513ce738926e0e47c643752ec0b42fda35 Mon Sep 17 00:00:00 2001 From: Jared Lewis Date: Fri, 12 May 2023 14:49:43 +0200 Subject: [PATCH 2/4] chore(ci): add flags to coverage to handle multiprocessing --- .github/workflows/ci-cd-workflow.yml | 2 +- .github/workflows/test-conda-install.yml | 2 +- .github/workflows/test-pypi-install.yml | 2 +- pyproject.toml | 3 +++ src/openscm_runner/adapters/ciceroscm_py_adapter/_compat.py | 2 +- 5 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci-cd-workflow.yml b/.github/workflows/ci-cd-workflow.yml index 700f3f29..3888c315 100644 --- a/.github/workflows/ci-cd-workflow.yml +++ b/.github/workflows/ci-cd-workflow.yml @@ -104,7 +104,7 @@ jobs: environment: CI strategy: matrix: - python-version: [3.7, 3.8, 3.9] + python-version: [3.7, 3.8, 3.9, "3.10", 3.11] steps: - name: Checkout repository diff --git a/.github/workflows/test-conda-install.yml b/.github/workflows/test-conda-install.yml index b5651b41..9e2d79d0 100644 --- a/.github/workflows/test-conda-install.yml +++ b/.github/workflows/test-conda-install.yml @@ -11,7 +11,7 @@ jobs: strategy: matrix: os: ["ubuntu-latest", "macos-latest", "windows-latest"] - python-version: [3.7, 3.8, 3.9] + python-version: [3.7, 3.8, 3.9, "3.10", 3.11] steps: - name: Setup conda diff --git a/.github/workflows/test-pypi-install.yml b/.github/workflows/test-pypi-install.yml index a1143532..b0fcb6d6 100644 --- a/.github/workflows/test-pypi-install.yml +++ b/.github/workflows/test-pypi-install.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.7, 3.8, 3.9] + python-version: [3.7, 3.8, 3.9, "3.10", 3.11] steps: - name: Setup python diff --git a/pyproject.toml b/pyproject.toml index 76b8deed..21241788 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,6 +19,9 @@ omit = [ "*adapters/magicc7*", "*testing.py" ] +concurrency = ["multiprocessing"] +parallel = true +sigterm = true [tool.coverage.report] fail_under = 90 diff --git a/src/openscm_runner/adapters/ciceroscm_py_adapter/_compat.py b/src/openscm_runner/adapters/ciceroscm_py_adapter/_compat.py index ea13f747..4e8758d1 100644 --- a/src/openscm_runner/adapters/ciceroscm_py_adapter/_compat.py +++ b/src/openscm_runner/adapters/ciceroscm_py_adapter/_compat.py @@ -5,7 +5,7 @@ try: import ciceroscm as cscmpy - HAS_CICEROSCM = True + HAS_CICEROSCM_PY = True except ImportError: cscmpy = None HAS_CICEROSCM_PY = False From a0ff8757d58015b7a3f25cf01790a759cc8ac6df Mon Sep 17 00:00:00 2001 From: Jared Lewis Date: Fri, 12 May 2023 15:00:39 +0200 Subject: [PATCH 3/4] chore(ci): Loosening coverage check under windows --- .github/workflows/ci-cd-workflow.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-cd-workflow.yml b/.github/workflows/ci-cd-workflow.yml index 3888c315..39982406 100644 --- a/.github/workflows/ci-cd-workflow.yml +++ b/.github/workflows/ci-cd-workflow.yml @@ -97,7 +97,8 @@ jobs: - name: Test with pytest Windows if: runner.os == 'Windows' run: | - pytest tests -r a --cov=openscm_runner --cov-report='' --cov-fail-under=$env:MIN_COVERAGE + # Not strictly testing coverage under windows as MAGICC isn't available + pytest tests -r a --cov=openscm_runner --cov-report='term-missing' --cov-fail-under=70 test-notebooks: runs-on: ubuntu-latest From cbb04274cf807e64ebe510e70ada1394da223f42 Mon Sep 17 00:00:00 2001 From: Jared Lewis Date: Mon, 15 May 2023 13:40:38 +0200 Subject: [PATCH 4/4] chore(ci): Try including MAGICC in coverage --- pyproject.toml | 2 -- 1 file changed, 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 21241788..2456fa95 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,8 +15,6 @@ source = [ ] omit = [ "*_version.py", - # TODO: remove the exclusion for MAGICC - "*adapters/magicc7*", "*testing.py" ] concurrency = ["multiprocessing"]