diff --git a/src/nomad_simulations/schema_packages/workflow/general.py b/src/nomad_simulations/schema_packages/workflow/general.py index d7527f3c..7965ffb1 100644 --- a/src/nomad_simulations/schema_packages/workflow/general.py +++ b/src/nomad_simulations/schema_packages/workflow/general.py @@ -1,5 +1,6 @@ from nomad.datamodel import EntryArchive from nomad.datamodel.metainfo.workflow import Link, Task, Workflow +from nomad.metainfo.util import MSubSectionList from structlog.stdlib import BoundLogger INCORRECT_N_TASKS = 'Incorrect number of tasks found.' @@ -43,24 +44,28 @@ def normalize(self, archive: EntryArchive, logger: BoundLogger): # link tasks based on overlap in execution time if time[0] >= times[parent_n][1]: # if no overlap, assign outputs of parent as input to next task - task.inputs = [ - Link(name='Input', section=output.section) - for output in parent_outputs or task.outputs - ] + task.inputs.extend( + [ + Link(name='Input', section=output.section) + for output in parent_outputs or task.outputs + ] + ) # assign first parent outputs as workflow inputs if not self.inputs: - self.inputs = task.inputs + self.inputs.extend(task.inputs) # assign as new parent parent_n = n # reset outputs - parent_outputs = task.outputs + parent_outputs = list(task.outputs) else: parent_outputs.extend(task.outputs) # if overlap, assign parent outputs to task inputs - task.inputs = [ - Link(name='Input', section=output.section) - for output in self.tasks[parent_n or n].outputs - ] + task.inputs.extend( + [ + Link(name='Input', section=output.section) + for output in self.tasks[parent_n or n].outputs + ] + ) if not self.outputs: # assign parent outputs as workflow outputs - self.outputs = parent_outputs + self.outputs.extend(parent_outputs) diff --git a/src/nomad_simulations/schema_packages/workflow/gw.py b/src/nomad_simulations/schema_packages/workflow/gw.py index 94ed45a7..a5bede53 100644 --- a/src/nomad_simulations/schema_packages/workflow/gw.py +++ b/src/nomad_simulations/schema_packages/workflow/gw.py @@ -16,7 +16,7 @@ def normalize(self, archive: EntryArchive, logger: BoundLogger) -> None: super().normalize(archive, logger) if not self.name: - self.name = 'DFT+GW' + self.name: str = 'DFT+GW' if len(self.tasks) != 2: logger.error(INCORRECT_N_TASKS) @@ -24,11 +24,11 @@ def normalize(self, archive: EntryArchive, logger: BoundLogger) -> None: if not self.inputs: # set inputs to inputs of DFT - self.inputs = self.tasks[0].task.inputs + self.inputs.extend(self.tasks[0].task.inputs) if not self.outputs: # set ouputs to outputs of GW - self.outputs = self.tasks[1].task.outputs + self.outputs.extend(self.tasks[1].task.outputs) # link dft and gw workflows self.tasks[0].inputs = self.inputs diff --git a/src/nomad_simulations/schema_packages/workflow/single_point.py b/src/nomad_simulations/schema_packages/workflow/single_point.py index 71d59019..c377095c 100644 --- a/src/nomad_simulations/schema_packages/workflow/single_point.py +++ b/src/nomad_simulations/schema_packages/workflow/single_point.py @@ -20,7 +20,7 @@ def normalize(self, archive: EntryArchive, logger: BoundLogger) -> None: return if not self.inputs: - self.inputs = self.tasks[0].inputs + self.inputs.extend(self.tasks[0].inputs) inps: list[Link] = [] for inp in self.inputs: @@ -32,4 +32,9 @@ def normalize(self, archive: EntryArchive, logger: BoundLogger) -> None: inps.append( Link(name='Input method', section=inp.section.model_method_ref) ) - self.inputs = inps + self.inputs.clear() + self.inputs.extend(inps) + + # reconnect inputs to link as these are redefined + self.tasks[0].inputs.clear() + self.tasks[0].inputs.extend(inps)