Skip to content

Commit

Permalink
change package name to pynxtools... so it is importable; not to pollu…
Browse files Browse the repository at this point in the history
…te basesections with m_nx_ attributes; use Entity instead of BasicELN for Identifier entries
  • Loading branch information
sanbrock committed Nov 8, 2024
1 parent ad26393 commit 012dc6d
Showing 1 changed file with 14 additions and 21 deletions.
35 changes: 14 additions & 21 deletions src/pynxtools/nomad/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
"https://github.com/FAIRmat-NFDI/nexus_definitions.git": "https://fairmat-nfdi.github.io/nexus_definitions/classes",
}

__PACKAGE_NAME = "nexus"
__PACKAGE_NAME = "pynxtools.nomad.schema"
__GROUPING_NAME = "NeXus"

from nomad import utils
Expand Down Expand Up @@ -817,9 +817,8 @@ def init_nexus_metainfo():
sections.append(section)

for section in sections:
# TODO: add when quantities with mixed use_full_storage are supported by GUI
# if not (str(section).startswith("nexus.")):
# continue
if not (str(section).startswith("pynxtools.")):
continue
__add_additional_attributes(section)
for quantity in section.quantities:
__add_additional_attributes(quantity)
Expand Down Expand Up @@ -869,24 +868,18 @@ def normalize_identifier(self, archive, logger):
"""Normalizer for identifier section."""

def create_Entity(lab_id, archive, f_name):
# TODO: use this instead of BasicEln() when use_full_storage is properly supported by the GUI
# entitySec = Entity()
# entitySec.lab_id = lab_id
# entity = EntryArchive (
# data = entitySec,
# m_context=archive.m_context,
# metadata=EntryMetadata(entry_type = "identifier"), #upload_id=archive.m_context.upload_id,
# )
# with archive.m_context.raw_file(f_name, 'w') as f_obj:
# json.dump(entity.m_to_dict(with_meta=True), f_obj)
entity = BasicEln()
entity.lab_id = lab_id
entitySec = Entity()
entitySec.lab_id = lab_id
entity = EntryArchive(
data=entitySec,
m_context=archive.m_context,
metadata=EntryMetadata(
entry_type="identifier", domain="nexus"
), # upload_id=archive.m_context.upload_id,
)
with archive.m_context.raw_file(f_name, "w") as f_obj:
json.dump(
{"data": entity.m_to_dict(with_meta=True, include_derived=True)},
f_obj,
indent=4,
)
json.dump(entity.m_to_dict(with_meta=True), f_obj)
# json.dump(entity.m_to_dict(), f_obj)
archive.m_context.process_updated_raw_file(f_name)

def get_entry_reference(archive, f_name):
Expand Down

0 comments on commit 012dc6d

Please sign in to comment.