nomad-parser-magres

NOMAD

NOMAD’s parser for magres

This is a parser plugin for the magres file format developed in the CCP-NC for Nuclear Magnetic Resonance (NMR) data.

Getting started

Installation

To add this plugin to your Custom NOMAD Oasis image, you can follow the instructions in the dedicated repository

Adding this plugin to NOMAD custom image

Modify nomad.yaml to exclude the magres plugin provided by the electronicparser package:

plugins:
  exclude:
    - electronicparsers:magres_parser_entry_point

Note! Once you modify your nomad.yaml file adding include, all the default plugins will be disconnected, so you will need to include them as well.

Development

The plugin is still under development. If you would like to contribute, install the package in your development distro and follow the instructions to get started.

Adding this plugin to NOMAD development distro

As already mentioned in Installation section, modify nomad.yaml to exclude the magres plugin provided by the electronicparser package:

plugins:
  exclude:
    - electronicparsers:magres_parser_entry_point

Run the tests

You can run the unit testing using the pytest package:

python -m pytest -sv

We recommend to install the coverage and coveralls packages for a more comprehensive output of the testing:

pip install coverage coveralls
python -m coverage run -m pytest -sv

Run linting and auto-formatting

We use Ruff for linting and formatting the code. Ruff auto-formatting is also a part of the GitHub workflow actions. You can run locally:

ruff check .
ruff format . --check

Debugging

For interactive debugging of the tests, use pytest with the --pdb flag. We recommend using an IDE for debugging, e.g., VSCode. If that is the case, add the following snippet to your .vscode/launch.json:

{
  "configurations": [
      {
        "name": "<descriptive tag>",
        "type": "debugpy",
        "request": "launch",
        "cwd": "${workspaceFolder}",
        "program": "${workspaceFolder}/.pyenv/bin/pytest",
        "justMyCode": true,
        "env": {
            "_PYTEST_RAISE": "1"
        },
        "args": [
            "-sv",
            "--pdb",
            "<path-to-plugin-tests>",
        ]
    }
  ]
}

where <path-to-plugin-tests> must be changed to the local path to the test module to be debugged.

The settings configuration file .vscode/settings.json automatically applies the linting and formatting upon saving the modified file.

Documentation on Github pages

To view the documentation locally, install the related packages using:

uv pip install -r requirements_docs.txt

Run the documentation server:

mkdocs serve