Skip to content
Snippets Groups Projects
Commit 96f08596 authored by Ashwin Kumar Karnad's avatar Ashwin Kumar Karnad
Browse files

Merge branch 'convert-to-a-package' into 'main'

Convert to a package

See merge request !70
parents 525df25b cdfd2525
No related branches found
No related tags found
1 merge request!70Convert to a package
Pipeline #371935 passed
...@@ -2,4 +2,7 @@ ...@@ -2,4 +2,7 @@
**/*.pyc **/*.pyc
logs logs
dev-23a/ dev-23a/
*.log *.log
\ No newline at end of file dist/
build/
*.egg-info/
\ No newline at end of file
...@@ -80,10 +80,10 @@ style: ...@@ -80,10 +80,10 @@ style:
- pydocstyle --version - pydocstyle --version
- ruff . - ruff .
- black --check --diff . - black --check --diff .
- pydocstyle mpsd-software.py - pydocstyle src/mpsd_software_manager/mpsd_software.py
- pydocstyle test_mpsd-software.py - pydocstyle tests/test_mpsd_software.py
# we could also use `ruff --select D` for pycodestyle. But the behaviour is not exactly the same. # we could also use `ruff --select D` for pycodestyle. But the behaviour is not exactly the same.
- ./mpsd-software.py --version - src/mpsd_software_manager/mpsd_software.py --version
test-bullseye: test-bullseye:
...@@ -91,12 +91,11 @@ test-bullseye: ...@@ -91,12 +91,11 @@ test-bullseye:
image: debian:bullseye-slim image: debian:bullseye-slim
script: script:
- *prepare_debian - *prepare_debian
- pytest -v -l test_mpsd-software.py - pytest -v -l
test-bookworm: test-bookworm:
stage: test stage: test
image: debian:bookworm-slim image: debian:bookworm-slim
script: script:
- *prepare_debian - *prepare_debian
- pytest -v -l test_mpsd-software.py - pytest -v -l
LICENSE 0 → 100644
The MIT License (MIT)
Copyright (c) 2023 SSU-Computational Science Group (Fangohr et al)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
...@@ -34,22 +34,23 @@ To install, for example, the ``foss2022a-serial`` toolchain: ...@@ -34,22 +34,23 @@ To install, for example, the ``foss2022a-serial`` toolchain:
$ cd /home/user/mpsd-software $ cd /home/user/mpsd-software
3. Initiate the installation at this location using:: .. comment:
3. Initiate the installation at this location using::
$ mpsd-software init
$ mpsd-software init
(This creates a hidden file ``.mpsd-software-root`` to tag the location for
as the root of the installation. All compiled files, logs etc are written in (This creates a hidden file ``.mpsd-software-root`` to tag the location for
or below this subdirectory.) as the root of the installation. All compiled files, logs etc are written in
or below this subdirectory.)
4. From the same directory, run the command to install the ``foss2022a-serial``
3. From the same directory, run the command to install the ``foss2022a-serial``
toolchain:: toolchain::
$ mpsd-software install dev-23a foss2022a-serial $ mpsd-software install dev-23a foss2022a-serial
This will take some time (up to several hours depending on hardware). This will take some time (up to several hours depending on hardware).
5. To see the installation status, and the required ``module use`` command line 4. To see the installation status, and the required ``module use`` command line
to activate the created modules, try the ``status`` command:: to activate the created modules, try the ``status`` command::
$ mpsd-software status dev-23a $ mpsd-software status dev-23a
...@@ -172,8 +173,10 @@ Requirements for particular toolchains and package sets ...@@ -172,8 +173,10 @@ Requirements for particular toolchains and package sets
Working example Working example
~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~
We have a continuous integration example at XXX, that shows the complete There is an
compilation cycle (including compilation of Octopus). (TODO) [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.
......
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"
[project]
name = "mpsd_software_manager"
authors = [{name = "SSU-Computational Science (Fangohr et al)", email = "ssu-cs@mpsd.mpg.de"}]
license = {file = "LICENSE"}
classifiers = ["License :: OSI Approved :: MIT License"]
version = "2023.6.14"
readme = "README.rst"
dependencies = [
"archspec",
"rich",
]
[project.scripts]
mpsd-software = "mpsd_software_manager.mpsd_software:main"
[project.urls]
Home = "https://gitlab.gwdg.de/mpsd-cs/mpsd-software-manager/"
[project.optional-dependencies]
dev = [
"black",
"pytest",
"pytest-mock",
"pytest-cov",
"ruff",
]
[tool.pytest.ini_options]
addopts = [
"--import-mode=importlib",
]
pythonpath = "src"
"""mpsd-software: tool for installation of software as on MPSD HPC."""
...@@ -599,24 +599,28 @@ def record_script_execution_summary( ...@@ -599,24 +599,28 @@ def record_script_execution_summary(
cmd_line = " ".join(sys.argv) cmd_line = " ".join(sys.argv)
# script branch and commit hash # script branch and commit hash
with os_chdir(root_dir): with os_chdir(root_dir):
script_branch = ( try:
run( script_branch = (
["git", "rev-parse", "--abbrev-ref", "HEAD"], run(
stdout=subprocess.PIPE, ["git", "rev-parse", "--abbrev-ref", "HEAD"],
check=True, stdout=subprocess.PIPE,
check=True,
)
.stdout.decode()
.strip()
) )
.stdout.decode() script_commit_hash = (
.strip() run(
) ["git", "rev-parse", "--short", "HEAD"],
script_commit_hash = ( stdout=subprocess.PIPE,
run( check=True,
["git", "rev-parse", "--short", "HEAD"], )
stdout=subprocess.PIPE, .stdout.decode()
check=True, .strip()
) )
.stdout.decode() except subprocess.CalledProcessError:
.strip() script_branch = "unknown"
) script_commit_hash = "unknown"
# spack-environments branch and commit hash from kwargs # spack-environments branch and commit hash from kwargs
spe_branch = kwargs.get("spe_branch", None) spe_branch = kwargs.get("spe_branch", None)
spe_commit_hash = kwargs.get("spe_commit_hash", None) spe_commit_hash = kwargs.get("spe_commit_hash", None)
...@@ -1189,8 +1193,8 @@ def main(): ...@@ -1189,8 +1193,8 @@ def main():
# Carry out the action # Carry out the action
args = parser.parse_args() args = parser.parse_args()
# target dir is the place where this script exists. the # root dir is the place where this script is called from
root_dir = Path(os.path.dirname(os.path.realpath(__file__))) root_dir = Path(os.getcwd())
set_up_logging( set_up_logging(
args.loglevel, args.loglevel,
......
...@@ -11,7 +11,7 @@ import sys ...@@ -11,7 +11,7 @@ import sys
import pytest import pytest
mod = importlib.import_module("mpsd-software") mod = importlib.import_module("mpsd_software_manager.mpsd_software")
# set loglevel to debug - useful for understanding problems. # set loglevel to debug - useful for understanding problems.
# (if the tests pass, pytest doesn't show any output) # (if the tests pass, pytest doesn't show any output)
...@@ -190,13 +190,15 @@ def test_record_script_execution_summary(tmp_path): ...@@ -190,13 +190,15 @@ def test_record_script_execution_summary(tmp_path):
def test_install_environment_wrong_package_set(tmp_path): def test_install_environment_wrong_package_set(tmp_path):
"""Test exception is raised for non-existing package_set.""" """Test exception is raised for non-existing package_set."""
# Expect an Exception when wrong package_sets are provided # exits with exit code 1 when wrong package_sets are provided
with pytest.raises(Exception): with pytest.raises(SystemExit) as e:
mod.install_environment( mod.install_environment(
mpsd_release="dev-23a", mpsd_release="dev-23a",
package_sets=["wrong-package_set"], package_sets=["wrong-package_set"],
root_dir=(tmp_path), root_dir=(tmp_path),
) )
assert e.type == SystemExit
assert e.value.code == 1
def test_install_environment_wrong_mpsd_release(tmp_path): def test_install_environment_wrong_mpsd_release(tmp_path):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment