From fb078b973ec2166efef0c07d300d57a03d48ec4e Mon Sep 17 00:00:00 2001 From: Alvin Noe Ladines Date: Mon, 19 Aug 2024 18:22:36 +0200 Subject: [PATCH 1/4] Add entry point --- pyproject.toml | 4 ++-- soapnormalizer/__init__.py | 18 +++++++++++++++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index ac87676..90b1ad3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -73,5 +73,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" diff --git a/soapnormalizer/__init__.py b/soapnormalizer/__init__.py index a5f0ec0..3c54cae 100644 --- a/soapnormalizer/__init__.py +++ b/soapnormalizer/__init__.py @@ -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.", +) From bfcc496faec135ea554194437a13697b28b6111a Mon Sep 17 00:00:00 2001 From: Alvin Noe Ladines Date: Tue, 20 Aug 2024 13:02:15 +0200 Subject: [PATCH 2/4] Fix test --- tests/test_soapnormalizer.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/test_soapnormalizer.py b/tests/test_soapnormalizer.py index 118af35..9e872b6 100644 --- a/tests/test_soapnormalizer.py +++ b/tests/test_soapnormalizer.py @@ -18,12 +18,13 @@ 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(): 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 From c605acd77bc6a23986caf3adf0729d07359e3692 Mon Sep 17 00:00:00 2001 From: Alvin Noe Ladines Date: Tue, 20 Aug 2024 13:15:19 +0200 Subject: [PATCH 3/4] Fix tests --- tests/test_soapnormalizer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_soapnormalizer.py b/tests/test_soapnormalizer.py index 9e872b6..e60fa30 100644 --- a/tests/test_soapnormalizer.py +++ b/tests/test_soapnormalizer.py @@ -17,12 +17,12 @@ # import json -from nomad.datamodel import EntryArchive -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'))) for normalizer in normalizers: normalizer(archive).normalize() From e1b5691fe656e171ee991821629471248d9bb983 Mon Sep 17 00:00:00 2001 From: Alvin Noe Ladines Date: Tue, 20 Aug 2024 13:26:08 +0200 Subject: [PATCH 4/4] Add workflow schema dep --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 90b1ad3..5abb2ab 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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", ]