Skip to content

Commit

Permalink
Create one CI job for each example
Browse files Browse the repository at this point in the history
  • Loading branch information
PicoCentauri committed Mar 25, 2024
1 parent 54ed883 commit 94eefa0
Show file tree
Hide file tree
Showing 12 changed files with 88 additions and 33 deletions.
62 changes: 53 additions & 9 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,71 @@ on:
- cron: '0 8 * * 1' # run every Monday at 8am UTC

jobs:
generate-example:
runs-on: ubuntu-latest
strategy:
matrix:
example-name: [lode_linear, roy_gch, sample_selection, gaas_map, cp2k_run_batch]

steps:
- uses: actions/checkout@v4
- name: setup rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable

- name: setup Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: install tox
run: python -m pip install tox

- name: install cp2k
if: matrix.example-name == 'cp2k_run_batch'
run: sudo apt-get install -y cp2k

- name: build example
run: tox -e ${{ matrix.example-name }}

- name: store example as a github artifact
uses: actions/upload-artifact@v4
with:
name: example-${{ matrix.example-name }}
path: docs/src/examples/* # folders for each example will be merged later
overwrite: true # only keep the latest version of the example

build-and-publish:
needs: generate-example
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: setup rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
- name: setup Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: install dependencies
run: |
sudo apt-get install -y cp2k
python -m pip install tox
python-version: "3.12"

- name: install tox
run: python -m pip install tox

- name: load github artifact for each example
uses: actions/download-artifact@v4
with:
path: docs/src/examples
pattern: example-*
merge-multiple: true

- name: build documentation
run: tox -e docs
run: tox -e build_docs

- name: store documentation as github artifacts
- name: store documentation as github artifact to be downloaded by users
uses: actions/upload-artifact@v4
with:
name: documentation
Expand Down
12 changes: 7 additions & 5 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.10"
- run: pip install tox
python-version: "3.12"

- name: Test Lint
- name: install dependencies
run: pip install tox

- name: test lint
run: tox -e lint
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ dependencies:
- pip
- pip:
- ase
- matplotlib
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ dependencies:
- pip:
- ase
- chemiscope
- skmatter
- scikit-learn
- matplotlib
- metatensor
- skmatter
- rascaline @ git+https://github.com/Luthaf/rascaline@ca957642f512e141c7570e987aadc05c7ac71983
- scikit-learn
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ dependencies:
- pip
- pip:
- ase
- metatensor
- equisolve @ git+https://github.com/lab-cosmo/equisolve.git@c858bedef4b2799eb445e4c92535ee387224089a
- matplotlib
- metatensor
- rascaline @ git+https://github.com/Luthaf/rascaline@ca957642f512e141c7570e987aadc05c7ac71983
2 changes: 1 addition & 1 deletion examples/lode_linear/lode_tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
# For speeding up the calculations we already selected the first 130
# structures of the charge-charge structures.

frames = ase.io.read("dataset/charge-charge.xyz", ":")
frames = ase.io.read("charge-charge.xyz", ":")


# %%
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ dependencies:
- pip:
- ase
- chemiscope
- skmatter
- matplotlib
- metatensor
- rascaline @ git+https://github.com/Luthaf/rascaline@ca957642f512e141c7570e987aadc05c7ac71983
- skmatter
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ dependencies:
- pip:
- ase
- chemiscope
- matplotlib
- skmatter
- metatensor
- rascaline @ git+https://github.com/Luthaf/rascaline@ca957642f512e141c7570e987aadc05c7ac71983
File renamed without changes.
2 changes: 1 addition & 1 deletion examples/sample_selection/sample_selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

# Load a subset of structures of the example dataset
n_frames = 500
frames = ase.io.read("./dataset/input-fps.xyz", f":{n_frames}", format="extxyz")
frames = ase.io.read("input-fps.xyz", f":{n_frames}", format="extxyz")

# %%
# Compute SOAP descriptors using rascaline
Expand Down
30 changes: 17 additions & 13 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ lint_folders =
"{toxinidir}/examples"

install_conda_env =
conda env update --file examples/{envname}/environement.yml --prefix {envdir}/conda --verbose
conda env update --file examples/{envname}/environment.yml --prefix {envdir}/conda --verbose
# install sphinx-gallery and its dependencies
{envdir}/conda/bin/python -m pip install sphinx-gallery sphinx pillow matplotlib
{envdir}/conda/bin/python -m pip install sphinx-gallery sphinx pillow

generate_gallery =
{envdir}/conda/bin/python generate-gallery.py examples/{envname}
Expand All @@ -26,15 +26,8 @@ allowlist_externals =
conda
{envdir}/conda/bin/python

commands =
# error if the user gives a wrong testenv name in `tox -e`
python -c "import sys; print('environement {env_name} does not exist'); sys.exit(1)"


[testenv:docs]
deps =
-r docs/requirements.txt

description = Run all examples and build the documentation
allowlist_externals = tox
commands =
# transform all examples to rst
Expand All @@ -44,35 +37,47 @@ commands =
tox -e gaas_map
tox -e cp2k_run_batch

sphinx-build {posargs:-E} -W -b html docs/src docs/build/html
# Build the documentation
tox -e build_docs

[testenv:build_docs]
description = Build the documentation (example should be generated before)
deps = -r docs/requirements.txt
commands = sphinx-build {posargs:-E} -W -b html docs/src docs/build/html


[testenv:lode_linear]
description = Build the `lode_linear` examples
commands =
{[testenv]install_conda_env}
{[testenv]generate_gallery}

[testenv:roy_gch]
description = Build the `roy_gch` examples
commands =
{[testenv]install_conda_env}
{[testenv]generate_gallery}

[testenv:gaas_map]
description = Build the `gaas_map` examples
commands =
{[testenv]install_conda_env}
{[testenv]generate_gallery}

[testenv:sample_selection]
description = Build the `sample_selection` examples
commands =
{[testenv]install_conda_env}
{[testenv]generate_gallery}

[testenv:cp2k_run_batch]
description = Build the `cp2k_run_batch` examples
commands =
{[testenv]install_conda_env}
{[testenv]generate_gallery}

[testenv:lint]
description = Run linters and type checks
deps =
black
blackdoc
Expand All @@ -92,8 +97,7 @@ commands =


[testenv:format]
# Abuse tox to do actual formatting. Users can call `tox -e format` to run
# formatting on all files
description = Abuse tox to do actual formatting on all files.
deps =
black
blackdoc
Expand Down

0 comments on commit 94eefa0

Please sign in to comment.