nomad-coe / nomad-schema-plugin-example

This is an example for NOMAD schema plugins. It should be forked to create actual plugins.
Apache License 2.0
14 stars 17 forks source link

Support for src folder in the plugin #9

Open ka-sarthak opened 6 months ago

ka-sarthak commented 6 months ago

As a best practice, it's wise to have the plugin within src folder. Supporting this in the example plugin repo will be super nice.

For the fork I did https://github.com/FAIRmat-NFDI/nomad-analysis, it wasn't very obvious how to have the plugin inside src folder without running into some issues.

When I added plugin code into src and installed the package, nomad.client.parse ran into some errors while running pytest. To resolve this, I had to export the src folder path to the PYTHONPATH. But this isn't ideal as the pytest will then use the local source code, rather than the installed package.

Then, I modified the pyproject.toml file to have:

[tool.setuptools.packages.find]
include = ["src*"]

and did the pip install again on a fresh virtual environment. But this ran into the same issue. I believe this is related with the visibility of the plugin schema.

Eventually, I could resolve it (running the pytest without having to export PYTHONPATH) by slightly modifying the pyproject.toml to have:

[tool.setuptools.packages.find]
where = ["src"]

followed by pip install. https://github.com/FAIRmat-NFDI/nomad-analysis/blob/main/pyproject.toml

Maybe it's a good idea to already have this integrated in the example repo.

What do you think? @blueraft @markus1978

markus1978 commented 5 months ago

@ka-sarthak I just saw this now. I will bring this to the next plugins taskforce meetings. It makes sense to me and your plugins already implement it this way.

@blueraft What are your thoughts on this?

blueraft commented 4 months ago

Sorry forgot to reply. Our new plugin templates will be using the src folder.