From 3ca9a593f422d1608210f599832bf18535840110 Mon Sep 17 00:00:00 2001 From: lkstrp Date: Mon, 22 Jul 2024 14:36:34 +0200 Subject: [PATCH 01/12] ci: upgrade deploy and test ci --- .github/workflows/CI.yml | 43 ----------- .github/workflows/{deploy.yml => release.yml} | 58 +++++++++------ .github/workflows/test.yml | 73 +++++++++++++++++++ 3 files changed, 107 insertions(+), 67 deletions(-) delete mode 100644 .github/workflows/CI.yml rename .github/workflows/{deploy.yml => release.yml} (54%) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml deleted file mode 100644 index fadafbad..00000000 --- a/.github/workflows/CI.yml +++ /dev/null @@ -1,43 +0,0 @@ -name: CI - -on: - push: - branches: - - master - pull_request: - branches: - - master - schedule: - - cron: "0 5 * * TUE" - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - name: Set up Python 3.8 - uses: actions/setup-python@v5 - with: - python-version: 3.8 - - name: Set up JDK 1.8 - uses: actions/setup-java@v4 - with: - distribution: 'temurin' - java-version: 8 - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -e . - - name: Lint with flake8 - run: | - pip install flake8 - # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - name: Test with pytest - run: | - pip install pytest - pytest diff --git a/.github/workflows/deploy.yml b/.github/workflows/release.yml similarity index 54% rename from .github/workflows/deploy.yml rename to .github/workflows/release.yml index 5d448400..22806222 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/release.yml @@ -1,36 +1,46 @@ -name: Deploy release +name: Release on: push: tags: - - v*.*.* + - v*.*.* jobs: - build-n-publish: - name: Build and publish Python 🐍 distributions 📦 to PyPI and TestPyPI + build: + # Build the Python SDist and wheel, performs metadata and readme linting + name: Build and verify package runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: hynek/build-and-inspect-python-package@v2 + release: + # Publish a GitHub release from the given git tag + name: Create GitHub Release + needs: [build] + runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - name: Set up Python 3.9 - uses: actions/setup-python@v5 - with: - python-version: 3.9 + - uses: actions/checkout@v4 + - uses: softprops/action-gh-release@v2 + with: + generate_release_notes: true - - name: Install pypa/build - run: >- - python -m - pip install - build - --user - - name: Build a binary wheel and a source tarball - run: >- - python -m - build - --sdist - --wheel - --outdir dist/ - . + publish: + # Publish the built SDist and wheel from "dist" job to PyPI + name: Publish to PyPI + needs: [build] + runs-on: ubuntu-latest + environment: + name: Release + url: https://pypi.org/project/powerplantmatching/ + permissions: + id-token: write + steps: + - uses: actions/download-artifact@v4 + with: + name: Packages + path: dist + - uses: pypa/gh-action-pypi-publish@release/v1 update-dataset: name: Update powerplants.csv in repository @@ -70,4 +80,4 @@ jobs: git commit -m '[github-actions.ci] auto update `powerplants.csv`' || exit 0 git push origin master env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..44fec09c --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,73 @@ + +name: Tests + +on: + push: + branches: [ master ] + pull_request: + branches: [ '*' ] + schedule: + - cron: "0 5 * * TUE" + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build: + # Build the Python SDist and wheel, performs metadata and readme linting + name: Build and verify package + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # Needed for setuptools_scm + - uses: hynek/build-and-inspect-python-package@v2 + id: baipp + + outputs: + python-versions: ${{ steps.baipp.outputs.supported_python_classifiers_json_array }} + + test: + # Test package build in matrix of OS and Python versions + name: Test package + needs: [build] + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + python-version: ${{ fromJSON(needs.build.outputs.python-versions) }} + os: + - ubuntu-latest + - macos-latest + - windows-latest + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # Needed for setuptools_scm + + - name: Set up Python ${{ matrix.python-version }} on ${{ matrix.os }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Set up JDK 1.8 + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: 8 + + - name: Download package + uses: actions/download-artifact@v4 + with: + name: Packages + path: dist + + - name: Install package and dependencies + run: | + python -m pip install "$(ls dist/*.whl)[dev]" + + - name: Test with pytest + run: | + pytest --doctest-modules From 8537552c55dc8abc4d5f3fb6dc668bf5bd239a46 Mon Sep 17 00:00:00 2001 From: lkstrp Date: Mon, 22 Jul 2024 15:02:35 +0200 Subject: [PATCH 02/12] build: use `setuptools_scm` for dynamic versioning --- pyproject.toml | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++ setup.cfg | 2 -- setup.py | 60 ------------------------------------------- 3 files changed, 69 insertions(+), 62 deletions(-) delete mode 100644 setup.cfg delete mode 100644 setup.py diff --git a/pyproject.toml b/pyproject.toml index e7900879..591e63af 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,4 +1,73 @@ # Formater and linter settings +[build-system] +requires = ["setuptools>=64", "setuptools_scm>=8"] +build-backend = "setuptools.build_meta" + + +[project] +name="powerplantmatching" +dynamic = ["version"] +description="Toolset for generating and managing Power Plant Data" +readme="README.md" +authors = [{ name = "Fabian Hofmann (FIAS)", email = "hofmann@fias.uni-frankfurt.de" }, +{ name = "Jonas Hoersch (KIT)" }, +{ name = "Fabian Gotzens (FZ Jülich)" }] +license = { file = "LICENSE" } +classifiers=[ + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Environment :: Console", + "Intended Audience :: Science/Research", + "License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)", + "Natural Language :: English", + "Operating System :: OS Independent", +] + +requires-python = ">=3.9" + +dependencies = [ + "numpy", + "scipy", + "pandas>=0.24.0", + "networkx>=1.10", + "pycountry", + "country_converter", + "xlrd", + "seaborn", + "pyyaml >=5.1.0", + "requests", + "matplotlib", + "geopy", + "xlrd", + "unidecode", + "entsoe-py >=0.3.1", + "deprecation", + "tqdm", + "openpyxl", +] + +[project.urls] +Homepage = "https://github.com/PyPSA/powerplantmatching" +Source = "https://github.com/PyPSA/powerplantmatching" + +[project.optional-dependencies] +docs= [ + "numpydoc", + "sphinx", + "sphinx-book-theme", + "nbsphinx", + "sphinx-automodapi", +] +dev= ["pre-commit", "pytest", "pytest-cov"] + +[tool.setuptools_scm] + +[tool.setuptools.packages.find] +include = ["powerplantmatching"] + +# Formatter and linter settings [tool.ruff] line-length = 88 diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 2a9acf13..00000000 --- a/setup.cfg +++ /dev/null @@ -1,2 +0,0 @@ -[bdist_wheel] -universal = 1 diff --git a/setup.py b/setup.py deleted file mode 100644 index b2bd3a66..00000000 --- a/setup.py +++ /dev/null @@ -1,60 +0,0 @@ -from codecs import open - -from setuptools import setup - -with open("README.md", encoding="utf-8") as f: - long_description = f.read() - -setup( - name="powerplantmatching", - version="0.5.15", - author="Fabian Hofmann (FIAS), Jonas Hoersch (KIT), Fabian Gotzens (FZ Jülich)", - author_email="hofmann@fias.uni-frankfurt.de", - description="Toolset for generating and managing Power Plant Data", - long_description=long_description, - long_description_content_type="text/markdown", - url="https://github.com/FRESNA/powerplantmatching", - license="GPLv3", - # packages=find_packages(include='matching_analysis'), - packages=["powerplantmatching"], - include_package_data=True, - install_requires=[ - "numpy", - "scipy", - "pandas>=0.24.0", - "networkx>=1.10", - "pycountry", - "country_converter", - "xlrd", - "seaborn", - "pyyaml >=5.1.0", - "requests", - "matplotlib", - "geopy", - "xlrd", - "unidecode", - "entsoe-py >=0.3.1", - "deprecation", - "tqdm", - "openpyxl", - ], - extras_require={ - "docs": [ - "numpydoc", - "sphinx", - "sphinx-book-theme", - "nbsphinx", - "sphinx-automodapi", - ], - "dev": ["pre-commit", "pytest", "pytest-cov"], - }, - classifiers=[ - "Programming Language :: Python :: 3", - # 'Development Status :: 3 - Alpha', - "Environment :: Console", - "Intended Audience :: Science/Research", - "License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)", - "Natural Language :: English", - "Operating System :: OS Independent", - ], -) From 9f43af8b886171b4f291ffe6f439a8a5708820a9 Mon Sep 17 00:00:00 2001 From: lkstrp Date: Mon, 22 Jul 2024 15:06:08 +0200 Subject: [PATCH 03/12] build: update package versioning --- powerplantmatching/__init__.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/powerplantmatching/__init__.py b/powerplantmatching/__init__.py index 17870317..fc0ffc0e 100644 --- a/powerplantmatching/__init__.py +++ b/powerplantmatching/__init__.py @@ -21,17 +21,28 @@ power plant databases. """ -__version__ = "0.5.15" -__author__ = "Fabian Hofmann" -__copyright__ = "Copyright 2017-2024 Technical University of Berlin" -# The rough hierarchy of this package is -# core, utils, heuristics, cleaning, matching, collection, data +import re +from importlib.metadata import version from . import core, data, heuristics, plot, utils from .accessor import PowerPlantAccessor from .collection import powerplants from .core import get_config, package_config +__author__ = "Fabian Hofmann" +__copyright__ = "Copyright 2017-2024 Technical University of Berlin" +# The rough hierarchy of this package is +# core, utils, heuristics, cleaning, matching, collection, data + +# e.g. "0.17.1" or "0.17.1.dev4+ga3890dc0" (if installed from git) +__version__ = version("powerplantmatching") +# e.g. "0.17.0" # TODO, in the network structure it should use the dev version +release_version = re.match(r"(\d+\.\d+(\.\d+)?)", __version__).group(0) + +# Assert that version is not 0.1 (which is the default version in the setup.py) +assert release_version != "0.1", "setuptools_scm could not find the version number" + + __all__ = [ "powerplants", "get_config", From 3225fd5e8b679f27714e76cdecf21cf2dd2865c1 Mon Sep 17 00:00:00 2001 From: lkstrp Date: Mon, 22 Jul 2024 15:21:51 +0200 Subject: [PATCH 04/12] build: use post-release versioning --- powerplantmatching/__init__.py | 10 ++++------ powerplantmatching/collection.py | 4 ++-- pyproject.toml | 1 + 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/powerplantmatching/__init__.py b/powerplantmatching/__init__.py index fc0ffc0e..1b445949 100644 --- a/powerplantmatching/__init__.py +++ b/powerplantmatching/__init__.py @@ -21,7 +21,6 @@ power plant databases. """ -import re from importlib.metadata import version from . import core, data, heuristics, plot, utils @@ -34,13 +33,12 @@ # The rough hierarchy of this package is # core, utils, heuristics, cleaning, matching, collection, data -# e.g. "0.17.1" or "0.17.1.dev4+ga3890dc0" (if installed from git) +# e.g. "0.5.15" or "0.5.15.post27+g761e814.d20240722" (if installed from master branch) __version__ = version("powerplantmatching") -# e.g. "0.17.0" # TODO, in the network structure it should use the dev version -release_version = re.match(r"(\d+\.\d+(\.\d+)?)", __version__).group(0) +# e.g. "0.5.15", without the post part (if it exists, otherwise the same as __version__) +latest_release = __version__.split(".post")[0] -# Assert that version is not 0.1 (which is the default version in the setup.py) -assert release_version != "0.1", "setuptools_scm could not find the version number" +assert latest_release != "0.1", "setuptools_scm could not find the version number" __all__ = [ diff --git a/powerplantmatching/collection.py b/powerplantmatching/collection.py index b3175f83..88e7ff06 100644 --- a/powerplantmatching/collection.py +++ b/powerplantmatching/collection.py @@ -169,7 +169,7 @@ def powerplants( Arguments passed to powerplantmatching.collection.Collection. """ - from . import __version__ + from . import latest_release if config is None: if config_update is None: @@ -200,7 +200,7 @@ def powerplants( if from_url: fn = _data_out("matched_data_red.csv", config) - url = config["matched_data_url"].format(tag="v" + __version__) + url = config["matched_data_url"].format(tag="v" + latest_release) logger.info(f"Retrieving data from {url}") df = ( pd.read_csv(url, index_col=0) diff --git a/pyproject.toml b/pyproject.toml index 591e63af..8e764646 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -63,6 +63,7 @@ docs= [ dev= ["pre-commit", "pytest", "pytest-cov"] [tool.setuptools_scm] +version_scheme = "post-release" [tool.setuptools.packages.find] include = ["powerplantmatching"] From 14b9af37116d4187a6d4feba264ed134379289d2 Mon Sep 17 00:00:00 2001 From: lkstrp Date: Mon, 22 Jul 2024 15:22:22 +0200 Subject: [PATCH 05/12] docs: update email --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 8e764646..9311e687 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,7 +9,7 @@ name="powerplantmatching" dynamic = ["version"] description="Toolset for generating and managing Power Plant Data" readme="README.md" -authors = [{ name = "Fabian Hofmann (FIAS)", email = "hofmann@fias.uni-frankfurt.de" }, +authors = [{ name = "Fabian Hofmann (FIAS)", email = "fabianmarikhofmann@gmail.com" }, { name = "Jonas Hoersch (KIT)" }, { name = "Fabian Gotzens (FZ Jülich)" }] license = { file = "LICENSE" } From 42992aea206237c9916a73ccbada7b39d9438ee9 Mon Sep 17 00:00:00 2001 From: lkstrp Date: Wed, 31 Jul 2024 09:03:04 +0200 Subject: [PATCH 06/12] fix: update java, use `uv` and point to tests dir --- .github/workflows/test.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 44fec09c..afeafeea 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -52,11 +52,11 @@ jobs: with: python-version: ${{ matrix.python-version }} - - name: Set up JDK 1.8 + - name: Set up Java uses: actions/setup-java@v4 with: distribution: 'temurin' - java-version: 8 + java-version: 22 - name: Download package uses: actions/download-artifact@v4 @@ -66,8 +66,10 @@ jobs: - name: Install package and dependencies run: | - python -m pip install "$(ls dist/*.whl)[dev]" + python -m pip install uv + uv pip install --system "$(ls dist/*.whl)[dev]" - name: Test with pytest run: | - pytest --doctest-modules + pytest + From c7a2db8f9b1bea1d9471488ce6eb370acdff045a Mon Sep 17 00:00:00 2001 From: lkstrp Date: Wed, 31 Jul 2024 09:03:50 +0200 Subject: [PATCH 07/12] build: allow future pandas `stack` --- powerplantmatching/collection.py | 4 +++- powerplantmatching/matching.py | 2 +- powerplantmatching/utils.py | 2 +- pyproject.toml | 3 +-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/powerplantmatching/collection.py b/powerplantmatching/collection.py index 88e7ff06..1bb1c285 100644 --- a/powerplantmatching/collection.py +++ b/powerplantmatching/collection.py @@ -247,7 +247,9 @@ def powerplants( matched = matched[matched.lat.notnull()] if isinstance(matched.columns, pd.MultiIndex): - matched.stack().drop_duplicates(["Name", "Fueltype", "Country"]).unstack(-1) + matched.stack(future_stack=True).drop_duplicates( + ["Name", "Fueltype", "Country"] + ).unstack(-1) else: matched.drop_duplicates(["Name", "Fueltype", "Country"]) diff --git a/powerplantmatching/matching.py b/powerplantmatching/matching.py index 4333da2d..382c6f00 100644 --- a/powerplantmatching/matching.py +++ b/powerplantmatching/matching.py @@ -307,7 +307,7 @@ def reduce_matched_dataframe(df, show_orig_names=False, config=None): sdf = ( df.assign(Set=lambda df: df.Set.where(df.Set != "PP")) .assign(Fueltype=lambda df: df.Fueltype.where(df.Set != "Other")) - .stack(1) + .stack(1, future_stack=True) .reindex(rel_scores.index, level=1) .groupby(level=0) .agg(props_for_groups) diff --git a/powerplantmatching/utils.py b/powerplantmatching/utils.py index 9ef096cd..6326a206 100644 --- a/powerplantmatching/utils.py +++ b/powerplantmatching/utils.py @@ -641,7 +641,7 @@ def fill_geoposition( if isinstance(df.columns, pd.MultiIndex): new_data = ( df.drop(columns=["lat", "lon"]) - .stack() + .stack(future_stack=True) .join(locs, on=["Name", "Country"]) .unstack(-1) .reindex(columns=df.columns) diff --git a/pyproject.toml b/pyproject.toml index 9311e687..b9fefd53 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -87,8 +87,7 @@ select = [ ] # Pytest settings - [tool.pytest.ini_options] filterwarnings = [ "error::FutureWarning", # Raise all FutureWarnings as errors -] \ No newline at end of file +] From 2fbeef4b423e5775910749c8bc88034aa6adeb49 Mon Sep 17 00:00:00 2001 From: lkstrp Date: Wed, 31 Jul 2024 09:04:15 +0200 Subject: [PATCH 08/12] docs: show docs also for older versions --- doc/conf.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/doc/conf.py b/doc/conf.py index d661724a..65e01667 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -4,6 +4,8 @@ # list see the documentation: # https://www.sphinx-doc.org/en/master/usage/configuration.html +from importlib.metadata import version as get_version + # -- Path setup -------------------------------------------------------------- # If extensions (or modules to document with autodoc) are in another directory, @@ -14,13 +16,17 @@ # import sys # sys.path.insert(0, os.path.abspath('.')) - # -- Project information ----------------------------------------------------- project = "powerplantmatching" copyright = "2021-2024, Fabian Hofmann, Fabian Gotzens, Jonas Hörsch, Martha Frysztacki" author = "Fabian Hofmann, Fabian Gotzens, Jonas Hörsch, Martha Frysztacki" +# -- Version information ------------------------------------------------- + +# The short X.Y version. +release: str = get_version("powerplantmatching") +version: str = ".".join(release.split(".")[:2]) # -- General configuration --------------------------------------------------- From badfb01ff5719428c097b00e81d308cc43d1cd80 Mon Sep 17 00:00:00 2001 From: lkstrp Date: Wed, 31 Jul 2024 09:05:58 +0200 Subject: [PATCH 09/12] chore: remove `requirements.yaml` --- requirements.yaml | 28 ---------------------------- 1 file changed, 28 deletions(-) delete mode 100644 requirements.yaml diff --git a/requirements.yaml b/requirements.yaml deleted file mode 100644 index 7d3eb593..00000000 --- a/requirements.yaml +++ /dev/null @@ -1,28 +0,0 @@ -name: powerplantmatching -channels: - - conda-forge - - defaults -dependencies: - - cartopy - - country_converter - - geopy - - ipython - - matplotlib - - networkx - - numpy - - pandas - - python=3 - - pyyaml - - requests - - scipy - - seaborn - - six - - xlrd - - openpyxl - - deprecation - - tqdm - - unidecode - - pip - - pip: - - pycountry - - entsoe-py>=0.3.1 From b9a4c80b9e34db1ab26f3d43d383b6de8d59aca6 Mon Sep 17 00:00:00 2001 From: lkstrp Date: Wed, 31 Jul 2024 09:31:03 +0200 Subject: [PATCH 10/12] fix: clean up --- .github/workflows/test.yml | 4 +++- pyproject.toml | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index afeafeea..9c7ba578 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,4 +1,3 @@ - name: Tests on: @@ -9,6 +8,7 @@ on: schedule: - cron: "0 5 * * TUE" +# Cancel any in-progress runs when a new run is triggered concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true @@ -72,4 +72,6 @@ jobs: - name: Test with pytest run: | pytest + env: + GITHUB_ACTIONS: true diff --git a/pyproject.toml b/pyproject.toml index b9fefd53..4074de50 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,9 +1,7 @@ -# Formater and linter settings [build-system] requires = ["setuptools>=64", "setuptools_scm>=8"] build-backend = "setuptools.build_meta" - [project] name="powerplantmatching" dynamic = ["version"] @@ -62,6 +60,8 @@ docs= [ ] dev= ["pre-commit", "pytest", "pytest-cov"] + # setuptools_scm settings + [tool.setuptools_scm] version_scheme = "post-release" @@ -71,7 +71,6 @@ include = ["powerplantmatching"] # Formatter and linter settings [tool.ruff] -line-length = 88 extend-include = ['*.ipynb'] [tool.ruff.lint] @@ -87,6 +86,7 @@ select = [ ] # Pytest settings + [tool.pytest.ini_options] filterwarnings = [ "error::FutureWarning", # Raise all FutureWarnings as errors From 0e0396bc3d057cef228d314afed00c8cef91b47b Mon Sep 17 00:00:00 2001 From: lkstrp Date: Wed, 31 Jul 2024 09:31:12 +0200 Subject: [PATCH 11/12] test: skip url_retrieve test in gh runner --- test/test_data.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/test/test_data.py b/test/test_data.py index 166ef0f3..f8c42454 100755 --- a/test/test_data.py +++ b/test/test_data.py @@ -5,6 +5,8 @@ @author: fabian """ +import os + import pytest import powerplantmatching as pm @@ -17,6 +19,11 @@ sources.remove("ENTSOE") +@pytest.fixture(scope="session") +def is_github_actions(): + return os.environ.get("GITHUB_ACTIONS") == "true" + + @pytest.mark.parametrize("source", sources) def test_data_request_raw(source): func = getattr(data, source) @@ -51,8 +58,11 @@ def test_OPSD_VRE_country(): assert df.Capacity.sum() > 0 -def test_url_retrieval(): - pm.powerplants(from_url=True) +@pytest.mark.github_actions +def test_url_retrieval(is_github_actions): + # Leads to HTTPError in GitHubAction + if not is_github_actions: + pm.powerplants(from_url=True) def test_reduced_retrieval(): From 19a92e025ea9ffc706b175d4cdacc76e5a54b1c8 Mon Sep 17 00:00:00 2001 From: lkstrp Date: Wed, 31 Jul 2024 09:45:40 +0200 Subject: [PATCH 12/12] chore: set gh env --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 22806222..2c0fa1a9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -31,7 +31,7 @@ jobs: needs: [build] runs-on: ubuntu-latest environment: - name: Release + name: pypi url: https://pypi.org/project/powerplantmatching/ permissions: id-token: write