Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nomad-coe/nomad-parser-plugin-example
This is an example for NOMAD parser plugins. It should be forked to create actual plugins.
https://github.com/nomad-coe/nomad-parser-plugin-example
Last synced: about 1 month ago
JSON representation
This is an example for NOMAD parser plugins. It should be forked to create actual plugins.
- Host: GitHub
- URL: https://github.com/nomad-coe/nomad-parser-plugin-example
- Owner: nomad-coe
- License: apache-2.0
- Created: 2023-03-30T13:01:15.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-03-02T12:33:13.000Z (10 months ago)
- Last Synced: 2024-04-24T11:54:50.302Z (8 months ago)
- Language: Python
- Size: 505 KB
- Stars: 6
- Watchers: 2
- Forks: 13
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# NOMAD's parser example plugin
## Getting started
### Fork the project
Go to the github project page https://github.com/nomad-coe/nomad-parser-plugin-example, hit
fork (and leave a star, thanks!). Maybe you want to rename the project while forking!### Clone your fork
Follow the github instructions. The URL and directory depends on your user name or organization and the
project name you choose. But, it should look somewhat like this:```
git clone [email protected]:markus1978/my-nomad-schema.git
cd my-nomad-schema
```### Install the dependencies
You should create a virtual environment. You will need the `nomad-lab` package (and `pytest`).
You need at least Python 3.9.```sh
python3 -m venv .pyenv
source .pyenv/bin/activate
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 plugins functionality. Make
sure to include NOMAD's internal package registry (e.g. via `--index-url`). Follow the instructions
in `requirements.txt`.### Run the tests
Make sure the current directory is in your path:
```sh
export PYTHONPATH=.
```You can run automated tests with `pytest`:
```sh
pytest -svx tests
```### Run linting
```sh
ruff check .
```### Run auto-formatting
This is entirely optional. To add this as a check in github actions pipeline, uncomment the `ruff-formatting` step in `./github/workflows/actions.yaml`.
```sh
ruff format .
```You can parse an example archive that uses the schema with `nomad`
(installed via `nomad-lab` Python package):```sh
nomad parse tests/data/test.example-format.txt --show-archive
```## Developing your schema
You can now start to develop you schema. Here are a few things that you might want to change:
- The metadata in `nomad_plugin.yaml`.
- The name of the Python package `nomadparserexample`. If you want to define multiple plugins, you can nest packages.
- The name of the example parser `ExampleParser` and the schema definitions it might define.
- When you change module and class names, make sure to update the `nomad_plugin.yaml` accordingly.## Build the python package
The `pyproject.toml` file contains everything that is necessary to turn the project
into a pip installable python package. Run the python build tool to create a package distribution:```
pip install build
python -m build --sdist
```You can install the package with pip:
```
pip install dist/nomad-schema-plugin-example-1.0.tar.gz
```Read more about python packages, `pyproject.toml`, and how to upload packages to PyPI
on the [PyPI documentation](https://packaging.python.org/en/latest/tutorials/packaging-projects/).## Next steps
To learn more about plugins, how to add them to an Oasis, how to publish them, read our
documentation on plugins: https://nomad-lab.eu/docs/plugins/plugins.html.