From 308f7f5a97947e4633fdc39040d93eb268573a94 Mon Sep 17 00:00:00 2001 From: Rubel Date: Wed, 4 Sep 2024 14:00:30 +0200 Subject: [PATCH 1/2] To allow entry_type would be written or not. --- src/pynxtools/nomad/dataconverter.py | 3 +++ src/pynxtools/nomad/parser.py | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/pynxtools/nomad/dataconverter.py b/src/pynxtools/nomad/dataconverter.py index 9e02e67dd..18cb5ebec 100644 --- a/src/pynxtools/nomad/dataconverter.py +++ b/src/pynxtools/nomad/dataconverter.py @@ -66,6 +66,7 @@ def populate_nexus_subsection( output_file_path: Optional[str] = None, on_temp_file=False, nxs_as_entry=True, + write_entry_type=True, ): """Populate nexus subsection in nomad from nexus template. @@ -84,6 +85,7 @@ def populate_nexus_subsection( 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. + write_entry_type: If the attr entry_type in archive.meatadata.entry_type would be written or not. Raises: Exception: could not trigger processing from NexusParser @@ -107,6 +109,7 @@ def populate_nexus_subsection( mainfile=archive.data.output, archive=archive, logger=logger, + write_entry_type=write_entry_type, ) # If a NeXus file written a an entry e.g XRD use case if nxs_as_entry: diff --git a/src/pynxtools/nomad/parser.py b/src/pynxtools/nomad/parser.py index c20c68aa9..ffff477bf 100644 --- a/src/pynxtools/nomad/parser.py +++ b/src/pynxtools/nomad/parser.py @@ -465,6 +465,7 @@ def parse( mainfile: str, archive: EntryArchive, logger=None, + write_entry_type=True, child_archives: Dict[str, EntryArchive] = None, ) -> None: self.archive = archive @@ -487,7 +488,7 @@ def parse( if getattr(archive.nexus, var, None) is not None: app_def = var break - if archive.metadata.entry_type is None: + if write_entry_type: archive.metadata.entry_type = app_def archive.metadata.domain = "nexus" From 98b6aa987fe97879b1f59016b72ae04f4536edfa Mon Sep 17 00:00:00 2001 From: Rubel Date: Wed, 4 Sep 2024 15:48:15 +0200 Subject: [PATCH 2/2] modify doc. --- src/pynxtools/nomad/dataconverter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pynxtools/nomad/dataconverter.py b/src/pynxtools/nomad/dataconverter.py index 18cb5ebec..45d252b9d 100644 --- a/src/pynxtools/nomad/dataconverter.py +++ b/src/pynxtools/nomad/dataconverter.py @@ -85,7 +85,7 @@ def populate_nexus_subsection( 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. - write_entry_type: If the attr entry_type in archive.meatadata.entry_type would be written or not. + write_entry_type: If the attr entry_type in archive.meatadata would be written or not. Raises: Exception: could not trigger processing from NexusParser