From b40228b535724edb902e9029153e2a1326003be5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Sch=C3=B6ppach?= Date: Fri, 27 Sep 2024 14:43:48 +0200 Subject: [PATCH] Added template for own solution schema --- pyproject.toml | 1 + .../schema_packages/__init__.py | 13 +++++++ .../schema_packages/solution.py | 39 +++++++++++++++++++ 3 files changed, 53 insertions(+) create mode 100644 src/nomad_unitov_plugin/schema_packages/solution.py diff --git a/pyproject.toml b/pyproject.toml index 3cc8f55..1023765 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -113,6 +113,7 @@ where = ["src"] [project.entry-points.'nomad.plugin'] parser_entry_point = "nomad_unitov_plugin.parsers:parser_entry_point" schema_package_entry_point = "nomad_unitov_plugin.schema_packages:schema_package_entry_point" +solution_entry_point = "nomad_unitov_plugin.schema_packages:solution_entry_point" [tool.cruft] diff --git a/src/nomad_unitov_plugin/schema_packages/__init__.py b/src/nomad_unitov_plugin/schema_packages/__init__.py index 4dbec7b..91242ed 100644 --- a/src/nomad_unitov_plugin/schema_packages/__init__.py +++ b/src/nomad_unitov_plugin/schema_packages/__init__.py @@ -15,3 +15,16 @@ def load(self): name='NewSchemaPackage', description='New schema package entry point configuration.', ) + + +class UNITOVSolitionEntryPoint(SchemaPackageEntryPoint): + def load(self): + from nomad_unitov_plugin.schema_packages.solution import m_package + + return m_package + + +solution_entry_point = UNITOVSolitionEntryPoint( + name='UNITOV Solution', + description='Schema package for UNITOV solution.', +) diff --git a/src/nomad_unitov_plugin/schema_packages/solution.py b/src/nomad_unitov_plugin/schema_packages/solution.py new file mode 100644 index 0000000..5586ebb --- /dev/null +++ b/src/nomad_unitov_plugin/schema_packages/solution.py @@ -0,0 +1,39 @@ +from typing import ( + TYPE_CHECKING, +) + +if TYPE_CHECKING: + from nomad.datamodel.datamodel import ( + EntryArchive, + ) + from structlog.stdlib import ( + BoundLogger, + ) + +from nomad.config import config + +# from nomad.datamodel.metainfo.annotations import ELNAnnotation, ELNComponentEnum +from nomad.metainfo import Quantity, SchemaPackage +from nomad_material_processing.solution.general import Solution + +configuration = config.get_plugin_entry_point( + "nomad_unitov_plugin.schema_packages:solution_entry_point" +) + +m_package = SchemaPackage() + + +class UNITOVSolution(Solution): + # name = Quantity( + # type=str, a_eln=ELNAnnotation(component=ELNComponentEnum.StringEditQuantity) + # ) + message = Quantity(type=str) + + def normalize(self, archive: "EntryArchive", logger: "BoundLogger") -> None: + super().normalize(archive, logger) + + logger.info("Normalizing UNITOVSolution") + self.message = f"Hello {self.name}!" + + +m_package.__init_metainfo__()