Skip to content

Latest commit

 

History

History
128 lines (96 loc) · 6.33 KB

README.md

File metadata and controls

128 lines (96 loc) · 6.33 KB

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

Install the dependencies

Clone the project and, in the workspace folder, create a virtual environment (note this project uses Python 3.9):

git clone https://github.com/nomad-coe/nomad-parser-magres.git
cd nomad-parser-magres
python3.9 -m venv .pyenv
source .pyenv/bin/activate

Install the nomad-lab package:

pip install --upgrade pip
pip install '.[dev]' --index-url https://gitlab.mpcdf.mpg.de/api/v4/projects/2187/packages/pypi/simple

Note: Until we have an official PyPI NOMAD release with the plugin functionality, make sure to include NOMAD's internal package registry (via --index-url in the above command).

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

Development

The plugin is still under development. If you would like to contribute, install the package in editable mode (with the added -e flag) with the development dependencies:

pip install -e .[dev] --index-url https://gitlab.mpcdf.mpg.de/api/v4/projects/2187/packages/pypi/simple

Setting up the plugin on your local installation

Read the NOMAD plugin documentation for all details on how to deploy the plugin on your local NOMAD installation.

To deploy the plugin in your local NOMAD installation, follow the next steps:

  1. Add the configurations related to NOMAD. This is already implemented through the plugin definition file src/nomad_parser_magres/nomad_plugin.yaml:

    plugin_type: parser
    name: parsers/magres
    description: |
      This plugin is used to parsed magres files into the NOMAD schema.

    and the nomad.yaml configuration file:

    normalize:
      normalizers:
        include:
          - MetainfoNormalizer
    plugins:
      # We only include our schema here. Without the explicit include, all plugins will be
      # loaded. Many build in plugins require more dependencies. Install nomad-lab[parsing]
      # to make all default plugins work.
      include:
        - 'parsers/magres'
        - 'runschema'
        - 'simulationworkflowschema'
      options:
        parsers/magres:
          python_package: nomad_parser_magres
        runschema:
          python_package: runschema
        simulationworkflowschema:
          python_package: simulationworkflowschema
  2. Add to your local NOMAD installation the same lines of your plugin nomad.yaml file.

  3. Add to your local NOMAD installation environment the PYTHONPATH to your plugin. This can be done either by running the following command every time you start a new terminal for running the appworker, or by adding it to your virtual environment in the <path-to-local-nomad-installation>/.pyenv/bin/activate file:

    export PYTHONPATH="$PYTHONPATH:<path-to-nomad-parser-magres-cloned-repo>/src"

If you are working in this repository, you just need to activate the environment to start working using the nomad-parser-magres package locally in your own Python scripts.

Run linting and auto-formatting

Ruff auto-formatting is also a part of the GitHub workflow actions. Make sure that before you make a Pull Request to add your contributions to this repo, the following commands run in your local without any errors otherwise the workflow action will fail.

ruff check .
ruff format . --check

Alternatively, if you are using VSCode as your IDE, we added the settings configuration file, .vscode/settings.json, such that it performs ruff format whenever you save progress in a file.