-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
using readonly instead of user_editability; enabling injesting multip… #486
base: master
Are you sure you want to change the base?
Changes from all commits
3c9c2b5
9f0b992
a70fa1e
d2cc0e9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,6 +47,7 @@ | |
InstrumentReference, | ||
Measurement, | ||
) | ||
from nomad.datamodel.metainfo.workflow import Link, Task, Workflow | ||
from nomad.metainfo import ( | ||
Attribute, | ||
Bytes, | ||
|
@@ -105,8 +106,8 @@ | |
"NXsample": [CompositeSystem], | ||
"NXsample_component": [Component], | ||
"NXidentifier": [EntityReference], | ||
"NXentry": [ActivityStep], | ||
"NXprocess": [ActivityStep], | ||
"NXentry": [ActivityStep], # , Task], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should eventually becomes its own workflow (nested in the workflow of the whole nxs file) containing its own Tasks. But fine for now |
||
"NXprocess": [ActivityStep], # , Task], | ||
"NXdata": [ActivityResult], | ||
# "object": BaseSection, | ||
} | ||
|
@@ -139,7 +140,44 @@ def normalize(self, archive, logger): | |
self.method = self.m_def.name + " Experiment" | ||
except (AttributeError, TypeError): | ||
pass | ||
super(NexusMeasurement, self).normalize(archive, logger) | ||
super(basesections.Activity, self).normalize(archive, logger) | ||
|
||
if archive.results.eln.methods is None: | ||
archive.results.eln.methods = [] | ||
if self.method: | ||
archive.results.eln.methods.append(self.method) | ||
else: | ||
archive.results.eln.methods.append(self.m_def.name) | ||
Comment on lines
+145
to
+150
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we actually want to fill the |
||
if archive.workflow2 is None: | ||
archive.workflow2 = Workflow(name=self.name) | ||
# steps to tasks | ||
act_array = archive.workflow2.tasks | ||
existing_items = {(task.name, task.section) for task in act_array} | ||
new_items = [ | ||
item.to_task() | ||
for item in self.steps | ||
if (item.name, item) not in existing_items | ||
] | ||
act_array.extend(new_items) | ||
# samples to inputs | ||
act_array = archive.workflow2.inputs | ||
existing_items = {(link.name, link.section) for link in act_array} | ||
new_items = [ | ||
Link(name=item.name, section=item.reference) | ||
for item in self.samples | ||
if (item.name, item.reference) not in existing_items | ||
] | ||
act_array.extend(new_items) | ||
|
||
# results to outputs | ||
act_array = archive.workflow2.outputs | ||
existing_items = {(link.name, link.section) for link in act_array} | ||
new_items = [ | ||
Link(name=item.name, section=item) | ||
for item in self.results | ||
if (item.name, item) not in existing_items | ||
] | ||
act_array.extend(new_items) | ||
|
||
|
||
VALIDATE = False | ||
|
@@ -952,7 +990,7 @@ def normalize_sample(self, archive, logger): | |
"""Normalizer for sample section.""" | ||
current_cls = __section_definitions[__rename_nx_for_nomad("NXsample")].section_cls | ||
self.name = self.__dict__["nx_name"] + ( | ||
"(" + self.name__field + ")" if self.name__field else "" | ||
" (" + self.name__field + ")" if self.name__field else "" | ||
) | ||
# one could also copy local ids to identifier for search purposes | ||
super(current_cls, self).normalize(archive, logger) | ||
|
@@ -964,12 +1002,18 @@ def normalize_entry(self, archive, logger): | |
if self.start_time__field: | ||
self.start_time = self.start_time__field | ||
self.name = self.__dict__["nx_name"] + ( | ||
"(" + self.title__field + ")" if self.title__field is not None else "" | ||
" (" + self.title__field + ")" if self.title__field is not None else "" | ||
) | ||
# one could also copy local ids to identifier for search purposes | ||
super(current_cls, self).normalize(archive, logger) | ||
|
||
|
||
# def to_task_itself(self): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove if not needed |
||
# """takes advantage if an object itself is also a Task""" | ||
# self.section=self | ||
# return self | ||
|
||
|
||
def normalize_process(self, archive, logger): | ||
"""Normalizer for Process section.""" | ||
current_cls = __section_definitions[__rename_nx_for_nomad("NXprocess")].section_cls | ||
|
@@ -998,7 +1042,7 @@ def create_Entity(lab_id, archive, f_name): | |
data=entitySec, | ||
m_context=archive.m_context, | ||
metadata=EntryMetadata( | ||
entry_type="identifier", domain="nexus" | ||
entry_type="identifier", domain="nexus", readonly=True | ||
), # upload_id=archive.m_context.upload_id, | ||
) | ||
with archive.m_context.raw_file(f_name, "w") as f_obj: | ||
|
@@ -1039,8 +1083,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, | ||
} | ||
|
||
|
@@ -1053,4 +1103,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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove comment here if not used