From 8109b376b30b57652322c41baf3d3dd7269a4bfa Mon Sep 17 00:00:00 2001 From: Sebastiaan Huber Date: Tue, 14 May 2019 15:00:19 +0200 Subject: [PATCH] Automatically set `CalcInfo.uuid` in `CalcJob.run` (#2874) The `uuid` field in the `CalcInfo` data structure which is built and returned by the `CalcJob.prepare_for_submission` implementation, is used subsequently by the engine to create the remote working directory. Previously, the implementer of `prepare_for_submission` was required to set it, but this always boiled down to setting it to the UUID of the process node. Since this is the only behavior that should happen anyway, we might as well have the engine take care of this, making the implementation of the `prepare_for_submission` for plugins simpler. --- aiida/calculations/plugins/arithmetic/add.py | 1 - aiida/calculations/plugins/templatereplacer.py | 1 - aiida/engine/processes/calcjobs/calcjob.py | 1 + 3 files changed, 1 insertion(+), 2 deletions(-) diff --git a/aiida/calculations/plugins/arithmetic/add.py b/aiida/calculations/plugins/arithmetic/add.py index a5f4bddc77..192a4aad4e 100644 --- a/aiida/calculations/plugins/arithmetic/add.py +++ b/aiida/calculations/plugins/arithmetic/add.py @@ -64,7 +64,6 @@ def prepare_for_submission(self, folder): codeinfo.code_uuid = input_code.uuid calcinfo = CalcInfo() - calcinfo.uuid = str(self.node.uuid) calcinfo.codes_info = [codeinfo] calcinfo.retrieve_list = retrieve_list calcinfo.local_copy_list = local_copy_list diff --git a/aiida/calculations/plugins/templatereplacer.py b/aiida/calculations/plugins/templatereplacer.py index c9560d5c85..ff78ad7e08 100644 --- a/aiida/calculations/plugins/templatereplacer.py +++ b/aiida/calculations/plugins/templatereplacer.py @@ -167,7 +167,6 @@ def prepare_for_submission(self, folder): calcinfo.retrieve_list = [] calcinfo.retrieve_temporary_list = [] - calcinfo.uuid = self.node.uuid calcinfo.local_copy_list = local_copy_list calcinfo.remote_copy_list = remote_copy_list diff --git a/aiida/engine/processes/calcjobs/calcjob.py b/aiida/engine/processes/calcjobs/calcjob.py index ecaf7c082d..b3ea4d8d58 100644 --- a/aiida/engine/processes/calcjobs/calcjob.py +++ b/aiida/engine/processes/calcjobs/calcjob.py @@ -145,6 +145,7 @@ def run(self): raise exceptions.InvalidOperation('calculation node has unstored links in cache') calc_info, script_filename = self.presubmit(folder) + calc_info.uuid = str(self.uuid) input_codes = [load_node(_.code_uuid, sub_classes=(Code,)) for _ in calc_info.codes_info] for code in input_codes: