diff --git a/pyproject.toml b/pyproject.toml index 960d090..227e439 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -74,7 +74,7 @@ select = [ "UP", # isort "I", - # pylint + # pylint "PL", ] @@ -108,10 +108,12 @@ package-dir = { "" = "src" } where = ["src"] [project.entry-points.'nomad.plugin'] -myparser = "nomad_ikz_sem.parsers:myparser" -mypackage = "nomad_ikz_sem.schema_packages:mypackage" +# myparser = "nomad_ikz_sem.parsers:myparser" +# mypackage = "nomad_ikz_sem.schema_packages:mypackage" + +# myapp = "nomad_ikz_sem.apps:myapp" +semsupport = "nomad_ikz_sem.schema_packages:semsupport -myapp = "nomad_ikz_sem.apps:myapp" [tool.cruft] # Avoid updating workflow files, this leads to permissions issues skip = [".github/*"] diff --git a/src/nomad_ikz_sem/schema_packages/__init__.py b/src/nomad_ikz_sem/schema_packages/__init__.py index eb24897..9fd10cd 100644 --- a/src/nomad_ikz_sem/schema_packages/__init__.py +++ b/src/nomad_ikz_sem/schema_packages/__init__.py @@ -7,7 +7,7 @@ class MySchemaPackageEntryPoint(SchemaPackageEntryPoint): def load(self): from nomad_ikz_sem.schema_packages.mypackage import m_package - + return m_package @@ -15,3 +15,17 @@ def load(self): name='MyPackage', description='Schema package defined using the new plugin mechanism.', ) + +class SEMSupportPackageEntryPoint(SchemaPackageEntryPoint): + parameter: int = Field(0, description='Custom configuration parameter') + + def load(self): + from nomad_ikz_sem.schema_packages.semsupport import m_package + + return m_package + + +semsupport = SEMSupportPackageEntryPoint( + name='SEMSupport', + description='Schema package defined using the new plugin mechanism.', +) diff --git a/src/nomad_ikz_sem/schema_packages/semsupport.py b/src/nomad_ikz_sem/schema_packages/semsupport.py new file mode 100644 index 0000000..36324ad --- /dev/null +++ b/src/nomad_ikz_sem/schema_packages/semsupport.py @@ -0,0 +1,172 @@ +# +# Copyright The NOMAD Authors. +# +# This file is part of NOMAD. See https://nomad-lab.eu for further info. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +from nomad.datamodel.metainfo.basesections import Experiment, Entity, Process, Measurement +from nomad.datamodel.data import EntryData +import numpy as np +from typing import ( + TYPE_CHECKING, +) +from nomad.metainfo import ( + MSection, + Package, + Quantity, + SubSection, + MEnum, + Reference, + Datetime, + Section, +) +from nomad.datamodel.data import ( + EntryData, + ArchiveSection, + Author, +) +if TYPE_CHECKING: + from nomad.datamodel.datamodel import ( + EntryArchive, + ) + from structlog.stdlib import ( + BoundLogger, + ) + +m_package = Package(name='Scanning Electron Microscopy Support') + +class Bedampfen(Process, EntryData, ArchiveSection): + m_def = Section() + hallo = Quantity( + type=str, + a_eln={ + "component": "StringEditQuantity" + }, + ) + + +class ScanningElectronMicroscopy(Experiment, EntryData, ArchiveSection): + ''' + Class autogenerated from yaml schema. + ''' + m_def = Section() + Date = Quantity( + type=Datetime, + a_eln={ + "component": "DateTimeEditQuantity" + }, + ) + hallo = Quantity( + type=Author, + a_eln={ + "component": "AuthorEditQuantity" + }, + ) + sample_from = Quantity( + type=Author, + a_eln={ + "component": "AuthorEditQuantity" + }, + ) + equipment = Quantity( + type=MEnum(['Nova 600', 'Apreo S']), + a_eln={ + "component": "EnumEditQuantity" + }, + shape=["2"], + ) + measurement_method = Quantity( + type=MEnum(['Images', 'EDX', 'EBSD', 'CL']), + a_eln={ + "component": "EnumEditQuantity" + }, + shape=["4"], + ) + material = Quantity( + type=str, + a_eln={ + "component": "StringEditQuantity" + }, + ) + sampleID = Quantity( + type=str, + a_eln={ + "component": "StringEditQuantity" + }, + base_sections=["nomad.datamodel.data.EntryData"], + ) + reference = Quantity( + type=Entity, + description='', + a_eln={ + "component": "ReferenceEditQuantity" + }, + shape=["*"], + ) + preperation = Quantity( + type=str, + a_eln={ + "component": "StringEditQuantity" + }, + ) + goal_or_question = Quantity( + type=str, + a_eln={ + "component": "StringEditQuantity" + }, + shape=["*"], + ) + summary = Quantity( + type=str, + a_eln={ + "component": "RichTextEditQuantity" + }, + shape=["*"], + ) + data_file = Quantity( + type=str, + description=''' + #The png file name. + ''', + a_eln={ + "component": "FileEditQuantity" + }, + a_browser={ + "adaptor": "RawFileAdaptor" + }, + shape=["*"], + ) + data_link = Quantity( + type=str, + description='', + a_eln={ + "component": "URLEditQuantity" + }, + shape=["*"], + ) + + def normalize(self, archive: 'EntryArchive', logger: 'BoundLogger') -> None: + ''' + The normalizer for the `ElectronMicroscopy` class. + + Args: + archive (EntryArchive): The archive containing the section that is being + normalized. + logger (BoundLogger): A structlog logger. + ''' + super().normalize(archive, logger) + + +m_package.__init_metainfo__() diff --git a/tests/data/bedampfentest.archive.yaml b/tests/data/bedampfentest.archive.yaml new file mode 100644 index 0000000..40b5fe2 --- /dev/null +++ b/tests/data/bedampfentest.archive.yaml @@ -0,0 +1,4 @@ +data: + m_def: nomad_ikz_sem.schema_packages.semsupport.Bedampfen + name: Markus + hallo: Sebastian Brückner diff --git a/tests/data/semtest.archive.yaml b/tests/data/semtest.archive.yaml new file mode 100644 index 0000000..f74bb34 --- /dev/null +++ b/tests/data/semtest.archive.yaml @@ -0,0 +1,4 @@ +data: + m_def: nomad_ikz_sem.schema_packages.semsupport.ScanningElectronMicroscopy + name: Markus + hallo: Sebastian Brückner diff --git a/yamlschemas/emsupport.schema.archive.yaml b/yamlschemas/emsupport.schema.archive.yaml index 8690aae..adc735f 100644 --- a/yamlschemas/emsupport.schema.archive.yaml +++ b/yamlschemas/emsupport.schema.archive.yaml @@ -65,7 +65,7 @@ definitions: Reference: type: nomad.datamodel.data.EntryData shape: ['*'] - description: + description: '' m_annotations: eln: component: ReferenceEditQuantity @@ -101,7 +101,7 @@ definitions: Data_link: type: string shape: ['*'] - description: + description: '' m_annotations: eln: component: URLEditQuantity diff --git a/yamlschemas/sem_support.py b/yamlschemas/sem_support.py index fc99b35..b607b11 100644 --- a/yamlschemas/sem_support.py +++ b/yamlschemas/sem_support.py @@ -10,7 +10,7 @@ import numpy as np from nomad.config import config -from nomad.datamodel.data import ArchiveSection, EntryData, EntryDataCategory, Schema +from nomad.datamodel.data import ArchiveSection, EntryData, EntryDataCategory, Schema, Author from nomad.datamodel.metainfo.annotations import ( ELNAnnotation, ELNComponentEnum, @@ -158,7 +158,7 @@ def __init__(self): } } }, - + "FEG": { "type": np.float64, "shape": ['*'], @@ -203,7 +203,7 @@ def __init__(self): } } }, - + "Comment": { "type": str, "m_annotations": { @@ -215,7 +215,7 @@ def __init__(self): } } } - +