Skip to content

Commit

Permalink
Parse a Nexus file as a entry or as a uploaded file. (#389)
Browse files Browse the repository at this point in the history
* Parse a Nexus file as a entry or as a uploaded file.

* update def.

* nexus version.
  • Loading branch information
RubelMozumder authored Jul 29, 2024
1 parent 699b141 commit a320595
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/pynxtools/definitions
2 changes: 1 addition & 1 deletion src/pynxtools/nexus-version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v2022.07-1283-g35035807
v2022.07-1284-gf75a2983
34 changes: 20 additions & 14 deletions src/pynxtools/nomad/dataconverter.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def populate_nexus_subsection(
logger,
output_file_path: Optional[str] = None,
on_temp_file=False,
nxs_as_entry=True,
):
"""Populate nexus subsection in nomad from nexus template.
Expand All @@ -82,6 +83,7 @@ def populate_nexus_subsection(
output_file_path: Output file should be a relative path not absolute path.
logger: nomad logger.
on_temp_file: Whether data will be written in temporary disk, by default False.
nxs_as_entry: If the nxs file should be as ann nonmad entry or a general file, by default True.
Raises:
Exception: could not trigger processing from NexusParser
Expand All @@ -102,21 +104,25 @@ def populate_nexus_subsection(

nexus_parser = NexusParser()
nexus_parser.parse(
mainfile=archive.data.output, archive=archive, logger=logger
mainfile=archive.data.output,
archive=archive,
logger=logger,
)
try:
archive.m_context.process_updated_raw_file(
output_file_path, allow_modify=True
)
except Exception as e:
logger.error(
"could not trigger processing",
mainfile=archive.data.output,
exc_info=e,
)
raise e
else:
logger.info("triggered processing", mainfile=archive.data.output)
# If a NeXus file written a an entry e.g XRD use case
if nxs_as_entry:
try:
archive.m_context.process_updated_raw_file(
output_file_path, allow_modify=True
)
except Exception as e:
logger.error(
"could not trigger processing",
mainfile=archive.data.output,
exc_info=e,
)
raise e
else:
logger.info("triggered processing", mainfile=archive.data.output)
except Exception as e:
logger.error("could not trigger processing", exc_info=e)
raise e
Expand Down
1 change: 1 addition & 0 deletions src/pynxtools/nomad/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,7 @@ def parse(
if getattr(archive.nexus, var, None) is not None:
app_def = var
break

archive.metadata.entry_type = app_def
archive.metadata.domain = "nexus"

Expand Down

0 comments on commit a320595

Please sign in to comment.