diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index c0c2b9f2c..5d10d86c7 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -1,14 +1,25 @@ -name: Build and test [Python 3.9, 3.10, 3.11] - -on: [push, pull_request] - # paths: - # - '*.py' - # - 'environment.yml' - # - 'requirements.txt' - # - '*.pkl' - # - '*.csv' - # - '*.json' - +name: Build and test +on: + push: + paths: + - '**.yml' + - '**.toml' + - '**.ini' + - '**.py' + - '**.json' + - '**.csv' + - '**.pkl' + - '**.pbz2' + pull_request: + paths: + - '**.yml' + - '**.toml' + - '**.ini' + - '**.py' + - '**.json' + - '**.csv' + - '**.pkl' + - '**.pbz2' jobs: build: runs-on: ${{ matrix.os }} @@ -19,12 +30,11 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: persist-credentials: false - - name: Setup Miniconda using Python ${{ matrix.python-version }} - uses: conda-incubator/setup-miniconda@v2 + uses: conda-incubator/setup-miniconda@v3 with: miniforge-variant: Mambaforge auto-update-conda: true @@ -32,23 +42,22 @@ jobs: environment-file: environment.yml python-version: ${{ matrix.python-version }} auto-activate-base: false - - name: Build shell: bash -l {0} run: | pip install -e . - pip install pytest-cov - pip install pytest-pycodestyle - name: Test shell: bash -l {0} working-directory: ./ run: | - pytest -m 'not local' --cov=./ --cov-report=xml + python -m pytest -m "not local" --cov=./ --cov-report=xml - name: Upload coverage to Codecov - uses: codecov/codecov-action@v3 + if: matrix.os == 'ubuntu-latest' + uses: codecov/codecov-action@v4 with: files: ./coverage.xml flags: unittests name: codecov-umbrella + token: ${{ secrets.CODECOV_TOKEN }} fail_ci_if_error: true verbose: true diff --git a/.github/workflows/deploy_docs.yml b/.github/workflows/deploy_docs.yml index 4f21e8241..433e2d896 100644 --- a/.github/workflows/deploy_docs.yml +++ b/.github/workflows/deploy_docs.yml @@ -3,6 +3,14 @@ on: push: branches: - master + paths: + - './docs/**.png' + - './docs/book/content/theory/images/**.png' + - './docs/book/**.yml' + - './docs/book/**.bib' + - '**.md' + - './docs/book/content/api/**.rst' + - './ogcore/**.py' jobs: build-and-deploy: if: github.repository == 'PSLmodels/OG-Core' @@ -14,12 +22,12 @@ jobs: persist-credentials: false - name: Setup Miniconda - uses: conda-incubator/setup-miniconda@v2 + uses: conda-incubator/setup-miniconda@v3 with: miniforge-variant: Mambaforge - activate-environment: ogusa-dev + activate-environment: ogcore-dev environment-file: environment.yml - python-version: "3.10" + python-version: "3.11" auto-activate-base: false - name: Build # Build Jupyter Book @@ -27,8 +35,7 @@ jobs: run: | pip install -e . python -m ipykernel install --user --name=ogcore-dev - cd docs - jb build ./book + jb build ./docs/book - name: Deploy uses: JamesIves/github-pages-deploy-action@v4 diff --git a/.github/workflows/docs_check.yml b/.github/workflows/docs_check.yml index 9f21bd451..5a0d787d4 100644 --- a/.github/workflows/docs_check.yml +++ b/.github/workflows/docs_check.yml @@ -1,22 +1,31 @@ name: Check that docs build -on: [push, pull_request] +on: + pull_request: + paths: + - './docs/**.png' + - './docs/book/content/theory/images/**.png' + - './docs/book/**.yml' + - './docs/book/**.bib' + - '**.md' + - './docs/book/content/api/**.rst' + - './ogcore/**.py' jobs: build: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v4 # If you're using actions/checkout@v2 you must set persist-credentials to false in most cases for the deployment to work correctly. + uses: actions/checkout@v4 with: persist-credentials: false - name: Setup Miniconda - uses: conda-incubator/setup-miniconda@v2 + uses: conda-incubator/setup-miniconda@v3 with: miniforge-variant: Mambaforge - activate-environment: ogusa-dev + activate-environment: ogcore-dev environment-file: environment.yml - python-version: "3.10" + python-version: "3.11" auto-activate-base: false - name: Build # Build Jupyter Book @@ -24,5 +33,4 @@ jobs: run: | pip install -e . python -m ipykernel install --user --name=ogcore-dev - cd docs - jb build ./book + jb build ./docs/book diff --git a/.github/workflows/publish_to_pypi.yml b/.github/workflows/publish_to_pypi.yml index 2ca0318f2..8f54f3093 100644 --- a/.github/workflows/publish_to_pypi.yml +++ b/.github/workflows/publish_to_pypi.yml @@ -12,11 +12,11 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repo - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Setup Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: - python-version: 3.9 + python-version: "3.11" - name: Build package run: make pip-package - name: Publish a Python distribution to PyPI @@ -24,4 +24,4 @@ jobs: with: user: __token__ password: ${{ secrets.PYPI }} - skip_existing: true \ No newline at end of file + skip_existing: true diff --git a/CHANGELOG.md b/CHANGELOG.md index 19fae5664..e0491b507 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,15 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.11.5] - 2024-04-11 12:00:00 + +### Added + +- Adds a list of file change event triggers to `build_and_test.yml` so that those tests only run when one of those files is changed. +- Updates the codecov GH Action to version 4 and adds a secret token. +- Adds a list of file change event triggers to `deploy_docs.yml` and `docs_check.yml`, and limits `docs_check.yml` to only run on pull requests. + + ## [0.11.4] - 2024-04-03 22:00:00 ### Added @@ -210,6 +219,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Any earlier versions of OG-USA can be found in the [`OG-Core`](https://github.com/PSLmodels/OG-Core) repository [release history](https://github.com/PSLmodels/OG-Core/releases) from [v.0.6.4](https://github.com/PSLmodels/OG-Core/releases/tag/v0.6.4) (Jul. 20, 2021) or earlier. +[0.11.5]: https://github.com/PSLmodels/OG-Core/compare/v0.11.4...v0.11.5 [0.11.4]: https://github.com/PSLmodels/OG-Core/compare/v0.11.3...v0.11.4 [0.11.3]: https://github.com/PSLmodels/OG-Core/compare/v0.11.2...v0.11.3 [0.11.2]: https://github.com/PSLmodels/OG-Core/compare/v0.11.1...v0.11.2 diff --git a/codecov.yml b/codecov.yml index f72701275..2ba3b686b 100644 --- a/codecov.yml +++ b/codecov.yml @@ -22,7 +22,4 @@ comment: ignore: - "setup.py" - "./ogcore/_version.py" - - "./cs-config/**/*" # ignore folders and all its contents - "./tests/" # ignore folders and all its contents - - "./ogcore/tests/" # ignore folders and all its contents - - "./regression/**/*" # ignore folders and all its contents diff --git a/environment.yml b/environment.yml index 502809625..c770c358e 100644 --- a/environment.yml +++ b/environment.yml @@ -13,7 +13,7 @@ dependencies: - dask-core>=2.30.0 - distributed>=2.30.1 - paramtools>=0.15.0 -- sphinx +- sphinx>=3.5.4 - sphinx-argparse - sphinxcontrib-bibtex>=2.0.0 - sphinx-math-dollar @@ -21,11 +21,12 @@ dependencies: - jupyter-book>=0.11.3 - jupyter - pytest>=6.0 +- pytest-cov - pytest-xdist - pylint - coverage - requests -- openpyxl +- openpyxl>=3.1.2 - black>=24.1.1 - pip - pip: diff --git a/ogcore/SS.py b/ogcore/SS.py index 61da4a400..da1cd9643 100644 --- a/ogcore/SS.py +++ b/ogcore/SS.py @@ -255,7 +255,7 @@ def inner_loop(outer_loop_vars, p, client): results = results = compute( *lazy_values, scheduler=dask.multiprocessing.get, - num_workers=p.num_workers + num_workers=p.num_workers, ) for j, result in enumerate(results): diff --git a/ogcore/TPI.py b/ogcore/TPI.py index 811459b8f..af05b3fbf 100644 --- a/ogcore/TPI.py +++ b/ogcore/TPI.py @@ -743,7 +743,7 @@ def run_TPI(p, client=None): results = results = compute( *lazy_values, scheduler=dask.multiprocessing.get, - num_workers=p.num_workers + num_workers=p.num_workers, ) for j, result in enumerate(results): diff --git a/ogcore/__init__.py b/ogcore/__init__.py index 2e6fa0b4c..d44505fcc 100644 --- a/ogcore/__init__.py +++ b/ogcore/__init__.py @@ -20,4 +20,4 @@ from ogcore.txfunc import * from ogcore.utils import * -__version__ = "0.11.4" +__version__ = "0.11.5" diff --git a/ogcore/demographics.py b/ogcore/demographics.py index d4fa9fe95..2703707fb 100644 --- a/ogcore/demographics.py +++ b/ogcore/demographics.py @@ -165,17 +165,17 @@ def get_fert( if graph: if plot_path: pp.plot_fert_rates( - fert_rates_2D, - start_year, - [start_year, end_year], + [fert_rates_2D], + start_year=start_year, + years_to_plot=[start_year, end_year], path=plot_path, ) return fert_rates_2D else: fig = pp.plot_fert_rates( - fert_rates_2D, - start_year, - [start_year, end_year], + [fert_rates_2D], + start_year=start_year, + years_to_plot=[start_year, end_year], ) return fert_rates_2D, fig else: diff --git a/pyproject.toml b/pyproject.toml index b0f076532..0da40b0c4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,15 @@ [build-system] -requires = ["setuptools>=42"] +requires = ["setuptools>=61.0"] build-backend = "setuptools.build_meta" + +# Configuration for Black. + +# NOTE: you have to use single-quoted strings in TOML for regular expressions. +# It's the equivalent of r-strings in Python. Multiline strings are treated as +# verbose regular expressions by Black. Use [ ] to denote a significant space +# character. + +[tool.black] +line-length = 79 +target-version = ["py39", "py310", "py311"] +include = '\.pyi?$' diff --git a/setup.py b/setup.py index 318f6415e..875504feb 100755 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setuptools.setup( name="ogcore", - version="0.11.4", + version="0.11.5", author="Jason DeBacker and Richard W. Evans", license="CC0 1.0 Universal (CC0 1.0) Public Domain Dedication", description="A general equilibribum overlapping generations model for fiscal policy analysis", diff --git a/tests/test_demographics.py b/tests/test_demographics.py index 85d838069..9e37327f0 100644 --- a/tests/test_demographics.py +++ b/tests/test_demographics.py @@ -260,7 +260,7 @@ def test_infant_mort(): mort_rates, infmort_rate = demographics.get_mort(100, 0, 99, graph=False) # check that infant mortality equals rate hardcoded into # demographics.py - assert infmort_rate == 0.00491958 + assert infmort_rate == 0.00477758 def test_pop_rebin():