From 258398a4f5f7b5c17f01664bd5a6b5142cf9c982 Mon Sep 17 00:00:00 2001 From: JosePizarro3 Date: Fri, 27 Sep 2024 11:50:28 +0200 Subject: [PATCH] Printing stuff --- src/nomad_parser_wannier90/parsers/parser.py | 82 ++++++++++--------- .../parsers/utils/utils.py | 10 ++- 2 files changed, 49 insertions(+), 43 deletions(-) diff --git a/src/nomad_parser_wannier90/parsers/parser.py b/src/nomad_parser_wannier90/parsers/parser.py index 0536a24..5502949 100644 --- a/src/nomad_parser_wannier90/parsers/parser.py +++ b/src/nomad_parser_wannier90/parsers/parser.py @@ -524,7 +524,10 @@ def parse( # Workflow section workflow = SinglePoint() - self.archive.workflow2 = workflow + workflow.normalize(archive=archive, logger=logger) + print('TB') + print(workflow) + archive.workflow2 = workflow # TODO extend to handle DFT+TB workflows using `self._dft_codes` # Checking if other mainfiles are present, if the closest is a DFT code, tries to create the @@ -546,45 +549,44 @@ def parse( required=MetadataRequired(include=['entry_id', 'mainfile']), ).data metadata = [[sid['entry_id'], sid['mainfile']] for sid in search_ids] - if len(metadata) > 1: - for entry_id, mainfile in metadata: - if ( - mainfile == filepath_stripped - ): # we skipped the current parsed mainfile - continue - entry_archive = self.archive.m_context.load_archive( - entry_id, upload_id, None + for entry_id, mainfile in metadata: + if ( + mainfile == filepath_stripped + ): # we skipped the current parsed mainfile + continue + entry_archive = self.archive.m_context.load_archive( + entry_id, upload_id, None + ) + if dft_path == mainfile: + dft_archive = entry_archive + + # ! commented out for now, until VASP parser is ready + # # check if the simulation cell is the same + # dft_cell = dft_archive.m_xpath( + # 'data.model_system[-1].cell[0]' + # ) + # tb_cell = self.archive.m_xpath( + # 'data.model_system[-1].cell[0]' + # ) + # if dft_cell is not None and tb_cell is not None: + # if dft_cell != tb_cell: + # logger.warning( + # 'The DFT and TB cells do not coincide. We might be connecting wrongly the DFT and TB tasks.' + # ) + # else: + # logger.warning( + # 'Could not resolve the DFT and TB cells.' + # ) + # return + + # Parse the workflow information + dft_plus_tb_archive = self._child_archives.get( + 'DFTPlusTB_workflow' ) - if dft_path == mainfile: - dft_archive = entry_archive - - # ! commented out for now, until VASP parser is ready - # # check if the simulation cell is the same - # dft_cell = dft_archive.m_xpath( - # 'data.model_system[-1].cell[0]' - # ) - # tb_cell = self.archive.m_xpath( - # 'data.model_system[-1].cell[0]' - # ) - # if dft_cell is not None and tb_cell is not None: - # if dft_cell != tb_cell: - # logger.warning( - # 'The DFT and TB cells do not coincide. We might be connecting wrongly the DFT and TB tasks.' - # ) - # else: - # logger.warning( - # 'Could not resolve the DFT and TB cells.' - # ) - # return - - # Parse the workflow information - dft_plus_tb_archive = self._child_archives.get( - 'DFTPlusTB_workflow' - ) - dft_plus_tb = parse_dft_plus_tb_workflow( - dft_archive=dft_archive, tb_archive=self.archive - ) - dft_plus_tb_archive.workflow2 = dft_plus_tb - break + dft_plus_tb = parse_dft_plus_tb_workflow( + dft_archive=dft_archive, tb_archive=self.archive + ) + dft_plus_tb_archive.workflow2 = dft_plus_tb + break except Exception: logger.warning('Could not resolve the DFT+TB workflow for Wannier90.') diff --git a/src/nomad_parser_wannier90/parsers/utils/utils.py b/src/nomad_parser_wannier90/parsers/utils/utils.py index b4f9178..d733d0b 100644 --- a/src/nomad_parser_wannier90/parsers/utils/utils.py +++ b/src/nomad_parser_wannier90/parsers/utils/utils.py @@ -60,9 +60,13 @@ def parse_dft_plus_tb_workflow( dft_task = dft_archive.workflow2 tb_task = tb_archive.workflow2 - - dft_plus_tb.inputs = dft_task.inputs[0] - dft_plus_tb.outputs = tb_task.outputs[-1] + print(dft_task, tb_task, dft_task.inputs, tb_task.outputs) + print(dft_task.m_xpath('inputs'), dft_task.m_xpath('inputs', dict=False)) + print(dft_task.m_xpath('inputs[0]'), dft_task.m_xpath('inputs[0]', dict=False)) + print(tb_task.m_xpath('outputs'), dft_task.m_xpath('outputs', dict=False)) + print(tb_task.m_xpath('outputs[-1]'), dft_task.m_xpath('outputs[-1]', dict=False)) + dft_plus_tb.inputs = dft_task.m_xpath('inputs[0]', dict=False) + dft_plus_tb.outputs = tb_task.m_xpath('outputs[-1]', dict=False) dft_plus_tb.tasks = [ TaskReference(task=dft_task), TaskReference(task=tb_task),