Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve infrastructure (CI, Linting, Docs Build) #420

Merged
merged 42 commits into from
Jan 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
5c7aa92
Put versions in strings
timmens Nov 18, 2022
9a3cc63
Update .readthedocs.yml
timmens Nov 18, 2022
e32d21c
Set default Python to 3.10
timmens Nov 18, 2022
3796f72
Merge branch 'yaml-fix' of https://github.com/OpenSourceEconomics/est…
timmens Nov 18, 2022
b644afa
Use mamba in readthedocs.
hmgaudecker Dec 22, 2022
684992f
Fix location of conf.py.
hmgaudecker Dec 22, 2022
216b92b
Broadening the scope a bit: Remove output from notebooks.
hmgaudecker Dec 22, 2022
4e694a0
Allow installing pre-commit hooks in freshly generated environment.
hmgaudecker Dec 22, 2022
d8d6f9b
Remove all output from notebooks.
hmgaudecker Dec 22, 2022
7cee016
Remove more output.
hmgaudecker Jan 10, 2023
caa74bc
Fix link.
janosg Jan 12, 2023
9bb84db
[pre-commit.ci] pre-commit autoupdate (#421)
pre-commit-ci[bot] Jan 12, 2023
1a0109d
Adjust patch target.
janosg Jan 13, 2023
9304a42
Add separate mamba inspired action.
janosg Jan 13, 2023
93eb2e1
Add more actions.
janosg Jan 13, 2023
3fd2bb1
Add linkcheck.
janosg Jan 13, 2023
1cc3da1
Actually use different python versions.
janosg Jan 13, 2023
4a10175
Fix?
janosg Jan 13, 2023
5d0db80
Fix?
janosg Jan 13, 2023
ba5497b
Fix?
janosg Jan 13, 2023
45e492c
Add linkcheck env.
janosg Jan 13, 2023
ba2084a
Fix link in readme.
tobiasraabe Jan 13, 2023
33602e5
Do not use dev env for code snippets.
janosg Jan 13, 2023
3757b7d
Use linkcheck env.
janosg Jan 13, 2023
f39a4ce
Reduce environments.
janosg Jan 13, 2023
e74dcc7
Re-add a few.
janosg Jan 13, 2023
4c060be
Fix?
janosg Jan 13, 2023
c58fdb3
Fix?
janosg Jan 13, 2023
7aef698
Reduce more environments.
janosg Jan 13, 2023
e03dda0
Remove tox.ini and migrate remaining configs to pyproject.toml.
janosg Jan 13, 2023
0b19903
Also run slow tests on linux.
janosg Jan 13, 2023
990b5e9
Mark a few more tests as slow.
janosg Jan 13, 2023
39ec65b
Update environment file creation
timmens Jan 14, 2023
a5a437e
Fix error in extra_spec for documentation workflow
timmens Jan 14, 2023
b281ed5
Fix error in extra_spec for documentation workflow
timmens Jan 14, 2023
d1fc3b8
Improve readability
timmens Jan 14, 2023
ef2896c
Fix doctests in .envs/update_envs.py
timmens Jan 14, 2023
f0e979d
Merge branch 'yaml-fix' into use-mamba-on-rtd
timmens Jan 14, 2023
874e066
Run all notebooks and save output.
janosg Jan 14, 2023
6eab304
Enable ruff rule for unused arguments.
janosg Jan 14, 2023
8bcb641
Add rule B904.
janosg Jan 14, 2023
19141f2
Enable ISC rules.
janosg Jan 14, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 0 additions & 60 deletions .conda/meta.yaml

This file was deleted.

22 changes: 22 additions & 0 deletions .envs/testenv-linkcheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: estimagic

channels:
- conda-forge
- defaults

dependencies:
- jupyterlab # dev, docs
- nb_black # dev, docs
- pip # dev, tests, docs


- pydata-sphinx-theme>=0.3.0 # docs
- myst-parser # docs
- nbsphinx # docs
- sphinx # docs
- sphinx-copybutton # docs
- sphinx-panels # docs
- sphinxcontrib-bibtex # docs

- pip: # dev, tests, docs
- -e ../
37 changes: 37 additions & 0 deletions .envs/testenv-linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: estimagic

channels:
- conda-forge
- defaults

dependencies:
- jax
- pygmo
- nlopt # dev, tests
- pip # dev, tests, docs
- pytest # dev, tests
- pytest-cov # tests
- pytest-xdist # dev, tests
- statsmodels # dev, tests

- bokeh<=2.4.3 # run, tests
- click # run, tests
- cloudpickle # run, tests
- fuzzywuzzy # run, tests
- joblib # run, tests
- numba # run, tests
- numpy>=1.17.0 # run, tests
- pandas # run, tests
- plotly # run, tests
- pybaum >= 0.1.2 # run, tests
- scipy>=1.2.1 # run, tests
- sqlalchemy>=1.3 # run, tests


- pip: # dev, tests, docs
- DFO-LS # dev, tests
- Py-BOBYQA # dev, tests
- fides==0.7.4 # dev, tests
- kaleido # dev, tests
- simoptlib==1.0.1 # dev, tests
- -e ../
36 changes: 36 additions & 0 deletions .envs/testenv-others.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: estimagic

channels:
- conda-forge
- defaults

dependencies:
- cyipopt
- nlopt # dev, tests
- pip # dev, tests, docs
- pytest # dev, tests
- pytest-cov # tests
- pytest-xdist # dev, tests
- statsmodels # dev, tests

- bokeh<=2.4.3 # run, tests
- click # run, tests
- cloudpickle # run, tests
- fuzzywuzzy # run, tests
- joblib # run, tests
- numba # run, tests
- numpy>=1.17.0 # run, tests
- pandas # run, tests
- plotly # run, tests
- pybaum >= 0.1.2 # run, tests
- scipy>=1.2.1 # run, tests
- sqlalchemy>=1.3 # run, tests


- pip: # dev, tests, docs
- DFO-LS # dev, tests
- Py-BOBYQA # dev, tests
- fides==0.7.4 # dev, tests
- kaleido # dev, tests
- simoptlib==1.0.1 # dev, tests
- -e ../
50 changes: 50 additions & 0 deletions .envs/update_envs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
from copy import deepcopy
from pathlib import Path


def _keep_line(line: str, flag: str) -> bool:
"""Return True if line contains flag and does not include a comment.

Examples:
>>> assert _keep_line(" - jax # tests", "tests") is True
>>> assert _keep_line("name: env", "tests") is True
>>> assert _keep_line(" - jax # run", "tests") is False
"""
return flag in line or "#" not in line


def main():

lines = Path("environment.yml").read_text().splitlines()

# create standard testing environments

test_env = [line for line in lines if _keep_line(line, "tests")]
test_env.append(" - -e ../") # add local installation

# find index to insert additional dependencies
_insert_idx = [i for i, line in enumerate(lines) if "dependencies:" in line][0] + 1

## linux
test_env_linux = deepcopy(test_env)
test_env_linux.insert(_insert_idx, " - pygmo")
test_env_linux.insert(_insert_idx, " - jax")

## test environment others
test_env_others = deepcopy(test_env)
test_env_others.insert(_insert_idx, " - cyipopt")

# create docs testing environment

docs_env = [line for line in lines if _keep_line(line, "docs")]
docs_env.append(" - -e ../") # add local installation

# write environments
for name, env in zip(
["linux", "others", "linkcheck"], [test_env_linux, test_env_others, docs_env]
):
Path(f".envs/testenv-{name}.yml").write_text("\n".join(env) + "\n")


if __name__ == "__main__":
main()
103 changes: 55 additions & 48 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ concurrency:
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true


on:
push:
branches:
Expand All @@ -13,6 +14,7 @@ on:
branches:
- '*'


jobs:

run-tests-linux:
Expand All @@ -27,27 +29,29 @@ jobs:
python-version: ['3.8', '3.9', '3.10']

steps:
- uses: actions/checkout@v2
- uses: conda-incubator/setup-miniconda@v2
- uses: actions/checkout@v3
- name: create build environment
uses: mamba-org/provision-with-micromamba@main
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}

- name: Install core dependencies.
shell: bash -l {0}
run: conda install -c conda-forge tox-conda

- name: Run pytest.
environment-file: ./.envs/testenv-linux.yml
environment-name: estimagic
cache-env: true
extra-specs: |
python=${{ matrix.python-version }}
- name: run pytest
shell: bash -l {0}
run: tox -e pytest-linux -- --cov-report=xml --cov=./
run: |
micromamba activate estimagic
pytest --cov-report=xml --cov=./

- name: Upload coverage report.
if: runner.os == 'Linux' && matrix.python-version == '3.10'
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}

run-tests:

run-tests-win-and-mac:

name: Run tests for ${{ matrix.os }} on ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
Expand All @@ -59,57 +63,60 @@ jobs:
python-version: ['3.8', '3.9', '3.10']

steps:
- uses: actions/checkout@v2
- uses: conda-incubator/setup-miniconda@v2
- uses: actions/checkout@v3
- name: create build environment
uses: mamba-org/provision-with-micromamba@main
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}

- name: Install core dependencies.
environment-file: ./.envs/testenv-others.yml
environment-name: estimagic
cache-env: true
extra-specs: |
python=${{ matrix.python-version }}
- name: run pytest
shell: bash -l {0}
run: conda install -c conda-forge tox-conda
run: |
micromamba activate estimagic
pytest -m "not slow and not jax"

- name: Run pytest.
shell: bash -l {0}
run: tox -e pytest -- -m "not slow and not jax"

docs:
check-links-in-documentation:

name: Run documentation.
name: Check links in documentation.
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: conda-incubator/setup-miniconda@v2
- uses: actions/checkout@v3
- name: create build environment
uses: mamba-org/provision-with-micromamba@main
with:
auto-update-conda: true
python-version: "3.10"

- name: Install core dependencies.
shell: bash -l {0}
run: conda install -c conda-forge tox-conda

- name: Build docs
environment-file: ./.envs/testenv-linkcheck.yml
environment-name: estimagic
cache-env: true
extra-specs: python=3.10
- name: run sphinx
shell: bash -l {0}
run: tox -e sphinx

run: |
micromamba activate estimagic
cd docs/source
sphinx-build -T -b linkcheck -d doctrees . linkcheck

code-in-docs:

name: Run code snippets in documentation.
name: Run code snippets in documentation
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: conda-incubator/setup-miniconda@v2
- uses: actions/checkout@v3
- name: create build environment
uses: mamba-org/provision-with-micromamba@main
with:
auto-update-conda: true
python-version: "3.10"

- name: Install core dependencies.
shell: bash -l {0}
run: conda install -c conda-forge tox-conda
environment-file: ./.envs/testenv-linux.yml
environment-name: estimagic
cache-env: true
extra-specs: python=3.10

- name: Run doctest
- name: run sphinx
shell: bash -l {0}
run: tox -e code-in-docs
run: |
micromamba activate estimagic
cd docs/source
python -m doctest -v how_to_guides/optimization/how_to_specify_constraints.md
Loading