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

Use nox instead of tox #41

Merged
merged 5 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
39 changes: 13 additions & 26 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,35 +14,26 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
example-name:
- lode_linear
- roy_gch
- sample_selection
- gaas_map
- cp2k_run_batch
example-name:
- lode-linear
- roy-gch
- sample-selection
- gaas-map
# - batch-cp2k

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: install nox
run: python -m pip install nox

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

- name: store example as a github artifact
uses: actions/upload-artifact@v4
Expand All @@ -56,18 +47,14 @@ jobs:
runs-on: ubuntu-latest
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 nox
run: python -m pip install nox

- name: load github artifact for each example
uses: actions/download-artifact@v4
Expand All @@ -77,7 +64,7 @@ jobs:
merge-multiple: true

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

- name: store documentation as github artifact to be downloaded by users
uses: actions/upload-artifact@v4
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
python-version: "3.12"

- name: install dependencies
run: pip install tox
run: pip install nox

- name: test lint
run: tox -e lint
run: nox -e lint
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ docs/src/examples/

*build*
*egg-info/
sg_execution_times.rst

.nox/
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
name: cp2k_run_batch
dependencies:
- python=3.11
- pip
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@

import os
import re
import shutil
import subprocess
from os.path import basename, splitext
from typing import List, Union
Expand Down Expand Up @@ -68,7 +67,7 @@ def write_reftraj(fname: str, frames: Union[ase.Atoms, List[ase.Atoms]]) -> None
"CP2K does not support changing atom types within a reftraj run!"
)

out += f"{len(atoms):>8}\n i = {i+1:>8}, time = {0:>12.3f}\n"
out += f"{len(atoms):>8}\n i = {i + 1:>8}, time = {0:>12.3f}\n"
for atom in atoms:
pos = atom.position
out += f"{atom.symbol}{pos[0]:24.15f}{pos[1]:24.15f}{pos[2]:24.15f}\n"
Expand Down Expand Up @@ -105,7 +104,7 @@ def write_cellfile(fname: str, frames: Union[ase.Atoms, List[ase.Atoms]]) -> Non
)

for i, atoms in enumerate(frames):
out += f"{i+1:>8}{0:>12.3f}"
out += f"{i + 1:>8}{0:>12.3f}"
out += "".join([f"{c:>20.10f}" for c in atoms.cell.flatten()])
out += f"{atoms.cell.volume:>25.10f}"
out += "\n"
Expand Down Expand Up @@ -162,7 +161,7 @@ def mkdir_force(*args, **kwargs) -> None:
# files for the structures, the ``project_name`` used to build the name of the
# trajectory during the CP2K run, the ``project_directory`` where we store all
# simulation output as well as the path ``write_to_file`` which is the name of the file
# containing the computed energies and forces of the sinulation.
# containing the computed energies and forces of the simulation.

frames_full = ase.io.read("example.xyz", ":")
project_name = "test_calcs" # name of the global PROJECT
Expand All @@ -181,7 +180,7 @@ def mkdir_force(*args, **kwargs) -> None:
plt.show()

# %%
# We now extreact the stoichiometry from the input dataset using ASE's
# We now extract the stoichiometry from the input dataset using ASE's
# :py:meth:`ase.symbols.Symbols.get_chemical_formula` method.

frames_dict = {}
Expand Down Expand Up @@ -236,8 +235,8 @@ def mkdir_force(*args, **kwargs) -> None:
# %%
# .. note::
#
# For a usage on an HPC environment you can parallize the loop over the subfolders
# and submit and single job per stoichiometry.
# For a usage on an HPC environment you can parallelize the loop over the
# sub-directories and submit and single job per stoichiometry.
#
# Load results
# ------------
Expand Down Expand Up @@ -289,18 +288,13 @@ def mkdir_force(*args, **kwargs) -> None:
# Perform calculations using ASE calculator
# -----------------------------------------
# Above we performed the calculations using an external bash script. ASE also provides a
# calculator class that we can use the perform the caclulations with our input file
# calculator class that we can use the perform the calculations with our input file
# without a detour of writing files to disk.
#
# To use the ASE calculator together with a custom input script this requires some
# adjustments. First the name of the executable that has the exact name ``cp2k_shell``.
# We create a symlink to follow this requirement.

try:
os.symlink(shutil.which("cp2k"), "cp2k_shell.ssmp")
except OSError:
pass

# %%
# Next, we load the input file abd remove ``GLOBAL`` section because from it

Expand All @@ -326,11 +320,10 @@ def mkdir_force(*args, **kwargs) -> None:
stress_tensor=False,
poisson_solver=None,
print_level=None,
command="./cp2k_shell.ssmp --shell",
)

# %%
# We now load a new struture, add the calculator and perform the computation.
# We now load a new structure, add the calculator and perform the computation.

atoms = ase.io.read("example.xyz")
atoms.set_calculator(calc)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ for i in $(find ./production/ -mindepth 1 -type d); do
cp2k -i in.cp2k
cd -
done

2 changes: 2 additions & 0 deletions docs/src/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
sg_execution_times.rst
index.rst
7 changes: 1 addition & 6 deletions docs/src/index.rst → docs/src/index.rst.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,7 @@ COSMO Software Cookbook
:start-after: marker-intro-start
:end-before: marker-intro-end


.. toctree::
:caption: Table of Contents
:maxdepth: 1

examples/roy_gch/roy_gch
examples/lode_linear/lode_tutorial
examples/sample_selection/sample_selection
examples/gaas_map/gaas_map
examples/cp2k_run_batch/setup_reftraj
3 changes: 0 additions & 3 deletions examples/README.rst

This file was deleted.

2 changes: 2 additions & 0 deletions examples/gaas-map/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
gaas_training.xyz
gaas_map.chemiscope.json.gz
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
name: gaas_map
channels:
- conda-forge
dependencies:
- python=3.11
- pip
- rust
- pip:
- ase
- chemiscope
- matplotlib
- metatensor
- skmatter
- rascaline @ git+https://github.com/Luthaf/rascaline@ca957642f512e141c7570e987aadc05c7ac71983
- scikit-learn
- skmatter
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
name: lode_linear
channels:
- conda-forge
dependencies:
- python=3.11
- pip
- rust
- pip:
- ase
- equisolve @ git+https://github.com/lab-cosmo/equisolve.git@c858bedef4b2799eb445e4c92535ee387224089a
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
name: sample_selection
channels:
- conda-forge
dependencies:
- python=3.11
- pip
- rust
- pip:
- ase
- chemiscope
- matplotlib
- skmatter
- metatensor
Luthaf marked this conversation as resolved.
Show resolved Hide resolved
- rascaline @ git+https://github.com/Luthaf/rascaline@ca957642f512e141c7570e987aadc05c7ac71983
- skmatter
File renamed without changes.
1 change: 1 addition & 0 deletions examples/sample-selection/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sample-selection.json.gz
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
name: roy_gch
channels:
- conda-forge
dependencies:
- python=3.11
- pip
- rust
- pip:
- ase
- chemiscope
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@

# Display with chemiscope. This currently does not work - as raised in issue #8
# https://github.com/lab-cosmo/software-cookbook/issues/8
cs = chemiscope.show(
widget = chemiscope.show(
frames,
properties=properties,
settings={
Expand All @@ -209,9 +209,9 @@
if chemiscope.jupyter._is_running_in_notebook():
from IPython.display import display

display(cs)
display(widget)
else:
cs.save("sample_selection.json.gz")
widget.save("sample-selection.json.gz")


# %%
Expand Down
Loading