Skip to content

Commit

Permalink
add semsupport schema and yam files
Browse files Browse the repository at this point in the history
  • Loading branch information
budschi committed Jul 4, 2024
1 parent 29c3e28 commit 49b7ce6
Show file tree
Hide file tree
Showing 7 changed files with 207 additions and 11 deletions.
10 changes: 6 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ select = [
"UP",
# isort
"I",
# pylint
# pylint
"PL",
]

Expand Down Expand Up @@ -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/*"]
16 changes: 15 additions & 1 deletion src/nomad_ikz_sem/schema_packages/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,25 @@ class MySchemaPackageEntryPoint(SchemaPackageEntryPoint):

def load(self):
from nomad_ikz_sem.schema_packages.mypackage import m_package

return m_package


mypackage = MySchemaPackageEntryPoint(
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.',
)
172 changes: 172 additions & 0 deletions src/nomad_ikz_sem/schema_packages/semsupport.py
Original file line number Diff line number Diff line change
@@ -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__()
4 changes: 4 additions & 0 deletions tests/data/bedampfentest.archive.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
data:
m_def: nomad_ikz_sem.schema_packages.semsupport.Bedampfen
name: Markus
hallo: Sebastian Brückner
4 changes: 4 additions & 0 deletions tests/data/semtest.archive.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
data:
m_def: nomad_ikz_sem.schema_packages.semsupport.ScanningElectronMicroscopy
name: Markus
hallo: Sebastian Brückner
4 changes: 2 additions & 2 deletions yamlschemas/emsupport.schema.archive.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ definitions:
Reference:
type: nomad.datamodel.data.EntryData
shape: ['*']
description:
description: ''
m_annotations:
eln:
component: ReferenceEditQuantity
Expand Down Expand Up @@ -101,7 +101,7 @@ definitions:
Data_link:
type: string
shape: ['*']
description:
description: ''
m_annotations:
eln:
component: URLEditQuantity
Expand Down
8 changes: 4 additions & 4 deletions yamlschemas/sem_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -158,7 +158,7 @@ def __init__(self):
}
}
},

"FEG": {
"type": np.float64,
"shape": ['*'],
Expand Down Expand Up @@ -203,7 +203,7 @@ def __init__(self):
}
}
},

"Comment": {
"type": str,
"m_annotations": {
Expand All @@ -215,7 +215,7 @@ def __init__(self):
}
}
}




Expand Down

0 comments on commit 49b7ce6

Please sign in to comment.