Skip to content

Commit

Permalink
using readonly instead of user_editability; enabling injesting multip…
Browse files Browse the repository at this point in the history
…le methods to the base classes and not only the normalization; Entry to inherit also from Task, so Workflow click drives there directly
  • Loading branch information
sanbrock committed Dec 16, 2024
1 parent 657fbae commit 3c9c2b5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/pynxtools/nomad/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ def parse(
if archive.metadata.entry_type is None:
archive.metadata.entry_type = app_def
archive.metadata.domain = "nexus"
archive.metadata.user_editable = False
archive.metadata.readonly = True

# Normalise element info
if archive.results is None:
Expand Down
26 changes: 21 additions & 5 deletions src/pynxtools/nomad/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
InstrumentReference,
Measurement,
)
from nomad.datamodel.metainfo.workflow import Task
from nomad.metainfo import (
Attribute,
Bytes,
Expand Down Expand Up @@ -105,8 +106,8 @@
"NXsample": [CompositeSystem],
"NXsample_component": [Component],
"NXidentifier": [EntityReference],
"NXentry": [ActivityStep],
"NXprocess": [ActivityStep],
"NXentry": [ActivityStep, Task],
"NXprocess": [ActivityStep, Task],
"NXdata": [ActivityResult],
# "object": BaseSection,
}
Expand Down Expand Up @@ -970,6 +971,11 @@ def normalize_entry(self, archive, logger):
super(current_cls, self).normalize(archive, logger)


def to_task_itself(self):
"""takes advantage if an object itself is also a Task"""
return self


def normalize_process(self, archive, logger):
"""Normalizer for Process section."""
current_cls = __section_definitions[__rename_nx_for_nomad("NXprocess")].section_cls
Expand Down Expand Up @@ -1039,8 +1045,14 @@ def get_entry_reference(archive, f_name):
__rename_nx_for_nomad("NXsample"): normalize_sample,
__rename_nx_for_nomad("NXsample_component"): normalize_sample_component,
__rename_nx_for_nomad("NXidentifier"): normalize_identifier,
__rename_nx_for_nomad("NXentry"): normalize_entry,
__rename_nx_for_nomad("NXprocess"): normalize_process,
__rename_nx_for_nomad("NXentry"): {
"normalize": normalize_entry,
"to_task": to_task_itself,
},
__rename_nx_for_nomad("NXprocess"): {
"normalize": normalize_process,
"to_task": to_task_itself,
},
__rename_nx_for_nomad("NXdata"): normalize_data,
}

Expand All @@ -1053,4 +1065,8 @@ def get_entry_reference(archive, f_name):

# Append the normalize method from a function
if normalize_func:
section.section_cls.normalize = normalize_func
if isinstance(normalize_func, dict):
for key, value in normalize_func.items():
setattr(section.section_cls, key, value)
else:
section.section_cls.normalize = normalize_func

0 comments on commit 3c9c2b5

Please sign in to comment.