Skip to content

Commit

Permalink
Added template for own solution schema
Browse files Browse the repository at this point in the history
  • Loading branch information
fabianschoeppach committed Sep 27, 2024
1 parent 2440056 commit b40228b
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
13 changes: 13 additions & 0 deletions src/nomad_unitov_plugin/schema_packages/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.',
)
39 changes: 39 additions & 0 deletions src/nomad_unitov_plugin/schema_packages/solution.py
Original file line number Diff line number Diff line change
@@ -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__()

0 comments on commit b40228b

Please sign in to comment.