Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add entry point #5

Merged
merged 4 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ dev = [
]

tests = [
"nomad-schema-plugin-simulation-workflow@git+https://github.com/nomad-coe/nomad-schema-plugin-simulation-workflow.git@develop",
"nomad-schema-plugin-run@git+https://github.com/nomad-coe/nomad-schema-plugin-run.git@develop",
]

Expand Down Expand Up @@ -73,5 +74,5 @@ line-ending = "auto"
[tool.setuptools.packages.find]
include = ["soapnormalizer*"]

[tool.setuptools.package-data]
soapnormalizer = ["*/nomad_plugin.yaml"]
[project.entry-points.'nomad.plugin']
soapnormalizer = "soapnormalizer:soap_normalizer_entry_point"
18 changes: 17 additions & 1 deletion soapnormalizer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,20 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
from .normalizer import SoapNormalizer
from nomad.config.models.plugins import NormalizerEntryPoint


class SoapNormalizerEntryPoint(NormalizerEntryPoint):
def load(self):
import soapnormalizer
from .normalizer import SoapNormalizer

soapnormalizer.SoapNormalizer = SoapNormalizer

return SoapNormalizer(**self.dict())


soap_normalizer_entry_point = SoapNormalizerEntryPoint(
name="SoapNormalizer",
description="Normalizer for the SOAP data.",
)
9 changes: 5 additions & 4 deletions tests/test_soapnormalizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@
#
import json

from nomad.datamodel import EntryArchive
from soapnormalizer import SoapNormalizer
import runschema # pylint: disable=unused-import
from nomad.normalizing import normalizers


def test_soap():
from nomad.datamodel import EntryArchive

archive = EntryArchive.m_from_dict(json.load(open('tests/data/vasp.archive.json')))
SoapNormalizer(only_representatives=True).normalize(archive)
for normalizer in normalizers:
normalizer(archive).normalize()

assert archive.run[-1].system[-1].descriptors.soap is not None
Loading