From b34029b2f489958cd0d1cf3b6366a773b1ba10af Mon Sep 17 00:00:00 2001 From: iamashwin99 <ashwin-kumar.karnad@mpsd.mpg.de> Date: Wed, 21 Jun 2023 15:09:05 +0200 Subject: [PATCH 01/16] add basic precommit hook config --- .pre-commit-config.yaml | 58 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..44af4af --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,58 @@ +# Config based on https://gitlab.com/octopus-code/postopus/-/blob/main/.pre-commit-config.yaml +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: trailing-whitespace + - id: check-ast + - id: check-docstring-first + - id: check-executables-have-shebangs + - id: check-json + - id: check-merge-conflict + - id: check-xml + - id: check-yaml + - id: check-toml + - id: debug-statements + - id: end-of-file-fixer + - id: requirements-txt-fixer + - id: mixed-line-ending + args: ['--fix=auto'] # replace 'auto' with 'lf' to enforce Linux/Mac line endings or 'crlf' for Windows + +# other hooks +# Ruff: +- repo: https://github.com/astral-sh/ruff-pre-commit + # Ruff version. + rev: v0.0.274 + hooks: + - id: ruff + args: [--fix, --exit-non-zero-on-fix] + +# Black +- repo: https://github.com/psf/black + rev: 22.12.0 + hooks: + - id: black + language_version: python3 + +## If like to embrace black styles even in the docs: +# - repo: https://github.com/asottile/blacken-docs +# rev: v1.9.1 +# hooks: +# - id: blacken-docs +# additional_dependencies: [black] + +# pydocstyle +- repo: https://github.com/PyCQA/pydocstyle + rev: 6.1.1 + hooks: + - id: pydocstyle + name: pydocstyle + description: pydocstyle is a static analysis tool for checking compliance with Python docstring conventions. + entry: pydocstyle + language: python + types: [python] + +- repo: https://github.com/abravalheri/validate-pyproject + rev: v0.10.1 + hooks: + - id: validate-pyproject -- GitLab From 692798ec9794ed56ac1d2c74060345524be19692 Mon Sep 17 00:00:00 2001 From: iamashwin99 <ashwin-kumar.karnad@mpsd.mpg.de> Date: Wed, 21 Jun 2023 15:14:08 +0200 Subject: [PATCH 02/16] update versions of hooks --- .pre-commit-config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 44af4af..4ed6d7c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -22,14 +22,14 @@ repos: # Ruff: - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: v0.0.274 + rev: v0.0.269 hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] # Black - repo: https://github.com/psf/black - rev: 22.12.0 + rev: 23.3.0 hooks: - id: black language_version: python3 @@ -43,7 +43,7 @@ repos: # pydocstyle - repo: https://github.com/PyCQA/pydocstyle - rev: 6.1.1 + rev: 6.3.0 hooks: - id: pydocstyle name: pydocstyle -- GitLab From f5dc121fb8ce08cc8f0799cd4b16d79a972d4c4c Mon Sep 17 00:00:00 2001 From: iamashwin99 <ashwin-kumar.karnad@mpsd.mpg.de> Date: Wed, 21 Jun 2023 15:21:37 +0200 Subject: [PATCH 03/16] add documentation --- README.rst | 7 +++++-- development.rst | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 development.rst diff --git a/README.rst b/README.rst index 491a64a..1211d68 100644 --- a/README.rst +++ b/README.rst @@ -165,7 +165,7 @@ The ``mpsd-software-manager`` python package. - Install via pip or pipx. Pipx commands are: - + - to install: ``pipx install git+https://gitlab.gwdg.de/mpsd-cs/mpsd-software-manager`` - to update: ``pipx upgrade mpsd-software-manager`` - to uninstall: ``pipx uninstall mpsd-software-manager`` @@ -192,7 +192,7 @@ Working example There is an `example <https://github.com/mpsd-computational-science/octopus-with-mpsd-software>`__ compilation that shows the complete compilation cycle (including compilation of -Octopus) using the ``foss2022a-serial`` toolchain. +Octopus) using the ``foss2022a-serial`` toolchain. @@ -249,3 +249,6 @@ Frequently asked questions to experiment with toolchains etc. +Development +----------- +Developers documentation is available at [development.rst](development.rst). diff --git a/development.rst b/development.rst new file mode 100644 index 0000000..59ae675 --- /dev/null +++ b/development.rst @@ -0,0 +1,18 @@ +Developers Setup +================ +This section is for developers wanting to contribute to the project. + +Setup pre-commit hooks +---------------------- +The project uses [pre-commit](https://pre-commit.com/) to run some checks before committing code. +Install pre-commit by running the following command: + + pip install pre-commit +To setup the pre-commit hooks, run the following command from the root of the project: + + pre-commit install + +Then every time you commit, pre-commit will run all checks defined in `.pre-commit-config.yaml`. +you can run the pre-commit checks manually by running: + + pre-commit run --all-files -- GitLab From 1603ed87851d32077d97133a4f3e2ae27ced82a7 Mon Sep 17 00:00:00 2001 From: iamashwin99 <ashwin-kumar.karnad@mpsd.mpg.de> Date: Wed, 21 Jun 2023 15:24:27 +0200 Subject: [PATCH 04/16] update development file link --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 1211d68..93e2339 100644 --- a/README.rst +++ b/README.rst @@ -251,4 +251,4 @@ Frequently asked questions Development ----------- -Developers documentation is available at [development.rst](development.rst). +Developers documentation is available at `development.rst<development.rst>`. -- GitLab From 760070da8ecfe73173b6603b573a8b514e03d882 Mon Sep 17 00:00:00 2001 From: iamashwin99 <ashwin-kumar.karnad@mpsd.mpg.de> Date: Wed, 21 Jun 2023 15:26:48 +0200 Subject: [PATCH 05/16] correct reference to development.rst --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 93e2339..670c412 100644 --- a/README.rst +++ b/README.rst @@ -251,4 +251,4 @@ Frequently asked questions Development ----------- -Developers documentation is available at `development.rst<development.rst>`. +Developers documentation is available at development.rst :ref: `development.rst` -- GitLab From 54109267c0a59badf2faed413a71463bb6a85a0f Mon Sep 17 00:00:00 2001 From: iamashwin99 <ashwin-kumar.karnad@mpsd.mpg.de> Date: Wed, 21 Jun 2023 15:28:33 +0200 Subject: [PATCH 06/16] remove link to development.rst --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 670c412..08583c9 100644 --- a/README.rst +++ b/README.rst @@ -251,4 +251,4 @@ Frequently asked questions Development ----------- -Developers documentation is available at development.rst :ref: `development.rst` +Developers documentation is available at development.rst. -- GitLab From 557f2d02f492c93317d3ea941b9d7f479f18445b Mon Sep 17 00:00:00 2001 From: Hans Fangohr <hans.fangohr@mpsd.mpg.de> Date: Wed, 21 Jun 2023 16:53:23 +0200 Subject: [PATCH 07/16] add pre-commit dev-dependency to pyproject.toml --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 43fabe2..951bf92 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,6 +22,7 @@ Home = "https://gitlab.gwdg.de/mpsd-cs/mpsd-software-manager/" [project.optional-dependencies] dev = [ "black", + "pre-commit", "pytest", "pytest-mock", "pytest-cov", -- GitLab From 5bf66265e8f5b9cc9d2b9435aec2d18f459028e5 Mon Sep 17 00:00:00 2001 From: Hans Fangohr <hans.fangohr@mpsd.mpg.de> Date: Wed, 21 Jun 2023 15:00:41 +0000 Subject: [PATCH 08/16] Apply changes from Hanss changes --- development.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/development.rst b/development.rst index 59ae675..71e325b 100644 --- a/development.rst +++ b/development.rst @@ -4,15 +4,15 @@ This section is for developers wanting to contribute to the project. Setup pre-commit hooks ---------------------- -The project uses [pre-commit](https://pre-commit.com/) to run some checks before committing code. -Install pre-commit by running the following command: +The project uses `pre-commit <https://pre-commit.com/>`__ to run some checks before committing code. +Install pre-commit by running the following command:: pip install pre-commit -To setup the pre-commit hooks, run the following command from the root of the project: +To setup the pre-commit hooks, run the following command from the root of the project:: pre-commit install Then every time you commit, pre-commit will run all checks defined in `.pre-commit-config.yaml`. -you can run the pre-commit checks manually by running: +you can run the pre-commit checks manually by running:: pre-commit run --all-files -- GitLab From 9c609105199536332818a49269d30f0103331aee Mon Sep 17 00:00:00 2001 From: iamashwin99 <ashwin-kumar.karnad@mpsd.mpg.de> Date: Wed, 21 Jun 2023 17:01:35 +0200 Subject: [PATCH 09/16] remove unused file checks in precommit --- .pre-commit-config.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4ed6d7c..b3bc7b4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -7,10 +7,7 @@ repos: - id: check-ast - id: check-docstring-first - id: check-executables-have-shebangs - - id: check-json - id: check-merge-conflict - - id: check-xml - - id: check-yaml - id: check-toml - id: debug-statements - id: end-of-file-fixer -- GitLab From 117d781ffd90a337033ce6e87c5cbd0c46f2fcbf Mon Sep 17 00:00:00 2001 From: iamashwin99 <ashwin-kumar.karnad@mpsd.mpg.de> Date: Wed, 21 Jun 2023 17:05:47 +0200 Subject: [PATCH 10/16] update codeblock syntax --- development.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/development.rst b/development.rst index 71e325b..4d029e4 100644 --- a/development.rst +++ b/development.rst @@ -8,6 +8,7 @@ The project uses `pre-commit <https://pre-commit.com/>`__ to run some checks bef Install pre-commit by running the following command:: pip install pre-commit + To setup the pre-commit hooks, run the following command from the root of the project:: pre-commit install -- GitLab From e40619350f8f23a3186d1988525c17643a602b8b Mon Sep 17 00:00:00 2001 From: iamashwin99 <ashwin-kumar.karnad@mpsd.mpg.de> Date: Thu, 22 Jun 2023 10:40:56 +0200 Subject: [PATCH 11/16] remove reaquirements txt check --- .pre-commit-config.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b3bc7b4..ff1842c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -11,7 +11,6 @@ repos: - id: check-toml - id: debug-statements - id: end-of-file-fixer - - id: requirements-txt-fixer - id: mixed-line-ending args: ['--fix=auto'] # replace 'auto' with 'lf' to enforce Linux/Mac line endings or 'crlf' for Windows -- GitLab From cfd060a7c6a8c51dbd623f2e3a64ca7e88ed9c06 Mon Sep 17 00:00:00 2001 From: iamashwin99 <ashwin-kumar.karnad@mpsd.mpg.de> Date: Thu, 22 Jun 2023 10:41:05 +0200 Subject: [PATCH 12/16] run precommit on all files --- .gitignore | 2 +- .gitlab-ci.yml | 5 ++--- install-dev23a.sh | 6 +++--- src/mpsd_software_manager/mpsd_software.py | 16 ++++++++-------- tests/test_mpsd_software.py | 2 +- 5 files changed, 15 insertions(+), 16 deletions(-) diff --git a/.gitignore b/.gitignore index 3a1ec4c..bdecffe 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,4 @@ dev-23a/ *.log dist/ build/ -*.egg-info/ \ No newline at end of file +*.egg-info/ diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b70ecaf..c7020b0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -91,11 +91,10 @@ test-bullseye: image: debian:bullseye-slim script: - *prepare_debian - - pytest -v -l + - pytest -v -l test-bookworm: stage: test image: debian:bookworm-slim script: - *prepare_debian - - pytest -v -l - + - pytest -v -l diff --git a/install-dev23a.sh b/install-dev23a.sh index c01e10b..5a97c1a 100755 --- a/install-dev23a.sh +++ b/install-dev23a.sh @@ -1,21 +1,21 @@ #!/bin/bash # Script to build all toolchains for this MPSD release ( 23a ) # Run this script inside the cloned folder for eg: -# mpsddeb@mpsd-hpc-ibm-022:/opt_mpsd/linux-debian11/mpsd-software-environments$ ./install-dev23a.sh +# mpsddeb@mpsd-hpc-ibm-022:/opt_mpsd/linux-debian11/mpsd-software-environments$ ./install-dev23a.sh set -e cd .. mkdir -p dev-23a cd dev-23a # clone repo if it doesn't exist yet -[ -d 'spack-environments' ] || git clone git@gitlab.gwdg.de:mpsd-cs/spack-environments.git +[ -d 'spack-environments' ] || git clone git@gitlab.gwdg.de:mpsd-cs/spack-environments.git pushd spack-environments git checkout dev-23a git pull popd mkdir -p sandybridge cd sandybridge -../spack-environments/spack_setup.sh -b global +../spack-environments/spack_setup.sh -b global ../spack-environments/spack_setup.sh foss2021a-serial ../spack-environments/spack_setup.sh foss2021a-mpi ../spack-environments/spack_setup.sh foss2021a-cuda-mpi diff --git a/src/mpsd_software_manager/mpsd_software.py b/src/mpsd_software_manager/mpsd_software.py index b3b4da2..aa896e6 100755 --- a/src/mpsd_software_manager/mpsd_software.py +++ b/src/mpsd_software_manager/mpsd_software.py @@ -35,10 +35,10 @@ Build software as on MPSD HPC. It follows recipes as used on the MPSD HPC system and the (spack-based) Octopus buildbot. Compiled software is organised into MPSD software release versions (such as `dev-23a`) and CPU microarchitecture (such as `sandybridge`). - + Compiled packages and toolchains can be activated and used via `module load` as on the HPC system. - + Further documentation is available in the README.rst file, online at https://gitlab.gwdg.de/mpsd-cs/mpsd-software-manager/-/blob/main/README.rst @@ -56,17 +56,17 @@ Examples: 1. Query what package sets and toolchains are available for installation in release dev-23a - + $> {sys.argv[0]} available dev-23a - + 2. Install foss2022a-serial toolchain from the dev-23a release - + $> {sys.argv[0]} install dev-23a foss2022a-serial - + 3. Check what package sets and toolchains are installed from release dev-23a - + $> {sys.argv[0]} status dev-23a - + The `status` command also displays the `module use` command needed to load the created modules. diff --git a/tests/test_mpsd_software.py b/tests/test_mpsd_software.py index 6efde25..514c8e5 100644 --- a/tests/test_mpsd_software.py +++ b/tests/test_mpsd_software.py @@ -107,7 +107,7 @@ def test_run_method(tmp_path): def test_prepare_environment(tmp_path): """Simulate running preparation of environment. - + Simulate running ./install-software-environment.py --release dev-23a \ --target-directory /tmp/test_prepare_env prepare_env is run when cmd is not specified, we can test cmd='prepare' -- GitLab From 328fafa896bc7ae53e71859009bf87b7773ba32e Mon Sep 17 00:00:00 2001 From: iamashwin99 <ashwin-kumar.karnad@mpsd.mpg.de> Date: Thu, 22 Jun 2023 10:45:31 +0200 Subject: [PATCH 13/16] update precommit vers --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ff1842c..82390e6 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -18,7 +18,7 @@ repos: # Ruff: - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: v0.0.269 + rev: v0.0.274 hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] @@ -49,6 +49,6 @@ repos: types: [python] - repo: https://github.com/abravalheri/validate-pyproject - rev: v0.10.1 + rev: v0.13 hooks: - id: validate-pyproject -- GitLab From 273dfdcf3647a35c69c6dcce7af41be09df17a77 Mon Sep 17 00:00:00 2001 From: iamashwin99 <ashwin-kumar.karnad@mpsd.mpg.de> Date: Thu, 22 Jun 2023 10:47:10 +0200 Subject: [PATCH 14/16] add rstcheck precommit --- .pre-commit-config.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 82390e6..0009707 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -52,3 +52,11 @@ repos: rev: v0.13 hooks: - id: validate-pyproject + +- repo: https://github.com/myint/rstcheck + rev: v6.1.1 + hooks: + - id: rstcheck + additional_dependencies: + - sphinx==4.5.0 + - sphinx-click==3.1.0 -- GitLab From 2e23d01312766a5442e0d86e68fefc4741602439 Mon Sep 17 00:00:00 2001 From: iamashwin99 <ashwin-kumar.karnad@mpsd.mpg.de> Date: Thu, 22 Jun 2023 11:00:41 +0200 Subject: [PATCH 15/16] reduce verbosity of rstcheck --- .pre-commit-config.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0009707..00e5c86 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -60,3 +60,6 @@ repos: additional_dependencies: - sphinx==4.5.0 - sphinx-click==3.1.0 + args: [ + --report-level=WARNING, + ] -- GitLab From 490c853be54b7b6523eb864eea3289a352bf0b50 Mon Sep 17 00:00:00 2001 From: iamashwin99 <ashwin-kumar.karnad@mpsd.mpg.de> Date: Thu, 22 Jun 2023 11:00:45 +0200 Subject: [PATCH 16/16] fix issues mentioned by rstcheck --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 08583c9..05ddf0f 100644 --- a/README.rst +++ b/README.rst @@ -183,7 +183,7 @@ Requirements for particular toolchains and package sets - ``foss*-serial`` should compile with the dependencies outlined above - ``foss*-mpi`` currently needs linux header files installed (to compile the ``knem`` package) -- ``foss*-cuda-mpi`` (proably as `*-mpi, needs testing TODO) +- ``foss*-cuda-mpi`` (proably as `*-mpi, needs testing TODO`) Working example -- GitLab