diff --git a/aiida_flexpart/calculations/inversion.py b/aiida_flexpart/calculations/inversion.py index 44ffda2..9b6bd5d 100644 --- a/aiida_flexpart/calculations/inversion.py +++ b/aiida_flexpart/calculations/inversion.py @@ -63,11 +63,28 @@ def prepare_for_submission(self, folder): codeinfo.code_uuid = self.inputs.code.uuid codeinfo.stdout_name = self.metadata.options.output_filename codeinfo.withmpi = self.inputs.metadata.options.withmpi - - with folder.open('inversion_settings.yaml', 'w') as f: - _ = yaml.dump(self.inputs.inv_params.get_dict(), f) - # Prepare a `CalcInfo` to be returned to the engine + + #create dict for yaml, add remotes by location + remote_dict = {} + for k,v in self.inputs.remotes.items(): + if k.split("_")[0] in remote_dict.keys(): + remote_dict[k.split("_")[0]].append(v.attributes["remote_path"]+'/'+k) + else: + remote_dict[k.split("_")[0]] = [v.attributes["remote_path"]+'/'+k] + + params_dict = self.inputs.inv_params.get_dict() + for k,v in remote_dict.items(): + params_dict['sites'][k].update({'ft.fls':v}) + + #replace _ by . in dict + params_dict = { + key.replace("_", "."): value for key, value in params_dict.items() +} + + with folder.open('inversion_settings.yaml', 'w') as f: + _ = yaml.dump(params_dict, f) + calcinfo = common.CalcInfo() calcinfo.codes_info = [codeinfo] calcinfo.retrieve_list = ['aiida.out'] diff --git a/aiida_flexpart/workflows/inspect.py b/aiida_flexpart/workflows/inspect.py index c627dc7..054a2b3 100644 --- a/aiida_flexpart/workflows/inspect.py +++ b/aiida_flexpart/workflows/inspect.py @@ -26,11 +26,6 @@ def check(nc_file, version): return False return True - -def validate_history(nc_file): - return True if "history" in nc_file.attributes["global_attributes"].keys() else None - - @calcfunction def store(remote_dir, file): with tempfile.TemporaryDirectory() as td: @@ -53,10 +48,16 @@ def store(remote_dir, file): nc_dimensions=nc_dimensions, ) - if validate_history(node) == None: + if "history" in node.attributes["global_attributes"].keys(): + if check(node, "history"): + return node + elif "created" in node.attributes["global_attributes"].keys(): + if check(node, "created"): + return node + else: return - elif check(node, "history"): - return node + + class InspectWorkflow(WorkChain):