FAIRmat-NFDI / nomad-ML-generate-smiles-reader

This is an reader to create a NOMAD archive JSON file from the Generic JSON Writer in the 3DS BIOVIA Pipeline Pilot software.
Apache License 2.0
0 stars 0 forks source link

NOMAD

NOMAD's ML generated SMILES molecules plugin

This is a plugin for NOMAD to create NOMAD archive JSON files from an input ML generated SMILES file as created from the Generic JSON Writer in the 3DS BIOVIA Pipeline Pilot software.

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/FAIRmat-NFDI/nomad-ML-generate-smiles-reader.git
cd nomad-ML-generate-smiles-reader/
python3.9 -m venv .pyenv
. .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 plugins functionality. Make sure to include NOMAD's internal package registry (via --index-url in the above command).

Run the tests

You can 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 plugin on your local installation

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

You need to modify the src/nomad_ML_smiles_reader/nomad_plugin.yaml to define the plugin adding the following content:

plugin_type: schema
name: schemas/nomad_ML_smiles_reader
description: |
  This plugin is used to read a ML-generated SMILES molecules calculation and generate a NOMAD archive.

and define the nomad.yaml configuration file of your NOMAD instance in the root folder with the following content:

plugins:
  include: 'schemas/nomad_ML_smiles_reader'
  options:
    schemas/nomad_ML_smiles_reader:
      python_package: nomad_ML_smiles_reader

You also need to add the package folder to the PYTHONPATH of the Python environment of your local NOMAD installation. This can be done by specifying the relative path to this repository. Either run the following command every time you start a new terminal for running the appworker, or add it to your virtual environment in <path-to-local-nomad-installation>/.pyenv/bin/activate file:

export PYTHONPATH="$PYTHONPATH:<path-to-nomad_ML_smiles_reader-cloned-repo>"

If you are working in this repository, you just need to activate the environment to start working using the nomad-nomad_ML_smiles_reader package.

Run linting and auto-formatting

ruff check .
ruff format . --check

Ruff auto-formatting is also a part of the GitHub workflow actions. Make sure that before you make a Pull Request, ruff format . --check runs in your local without any errors otherwise the workflow action will fail.

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.