From b553b73d1b3e95ba8153bfbecba42a9c2bf00259 Mon Sep 17 00:00:00 2001 From: t-reents Date: Thu, 10 Oct 2024 12:45:27 +0200 Subject: [PATCH] Update scripts to aiida 2.6.2 --- .../1-create-aiida-archive-from-cifs.py | 2 +- .../oxides/upload-test-structure.py | 2 +- .../1-create_unaries_structures_group.py | 2 +- .../1-create_unaries_structures_group-set1.py | 2 +- 1-preliminary/create_starting_subgroup.py | 4 +-- 2-submit/launch_calculations_qe.py | 2 +- 3-analyze/get_results.py | 28 +++++++++++++------ 7 files changed, 26 insertions(+), 16 deletions(-) diff --git a/0-preliminary-do-not-run/oxides/1-create-aiida-archive-from-cifs.py b/0-preliminary-do-not-run/oxides/1-create-aiida-archive-from-cifs.py index 76d40036..1213e328 100644 --- a/0-preliminary-do-not-run/oxides/1-create-aiida-archive-from-cifs.py +++ b/0-preliminary-do-not-run/oxides/1-create-aiida-archive-from-cifs.py @@ -9,7 +9,7 @@ STRUCTURES_FULL_GROUP_LABEL = f'acwf-verification/{SET_NAME}/structures' Structure = DataFactory('structure') -group, _ = orm.Group.objects.get_or_create(label=STRUCTURES_FULL_GROUP_LABEL) +group, _ = orm.Group.collection.get_or_create(label=STRUCTURES_FULL_GROUP_LABEL) query = orm.QueryBuilder() query.append(Structure, tag='structure', project=['extras', 'id']) diff --git a/0-preliminary-do-not-run/oxides/upload-test-structure.py b/0-preliminary-do-not-run/oxides/upload-test-structure.py index 3fb248d4..d88efef9 100644 --- a/0-preliminary-do-not-run/oxides/upload-test-structure.py +++ b/0-preliminary-do-not-run/oxides/upload-test-structure.py @@ -22,7 +22,7 @@ STRUCTURES_FULL_GROUP_LABEL = f'acwf-verification/{set_name}/structures/{code_name}' Structure = DataFactory('structure') -group, created = orm.Group.objects.get_or_create(label=STRUCTURES_FULL_GROUP_LABEL) +group, created = orm.Group.collection.get_or_create(label=STRUCTURES_FULL_GROUP_LABEL) if not created and len(group.nodes) > 0: print(f"Stopping, non-empty group '{STRUCTURES_FULL_GROUP_LABEL}' already exists") diff --git a/0-preliminary-do-not-run/unaries/1-create_unaries_structures_group.py b/0-preliminary-do-not-run/unaries/1-create_unaries_structures_group.py index 957b1556..3808b844 100755 --- a/0-preliminary-do-not-run/unaries/1-create_unaries_structures_group.py +++ b/0-preliminary-do-not-run/unaries/1-create_unaries_structures_group.py @@ -118,7 +118,7 @@ def get_aiida_structures(alats): print(f"# {len(existing)} structures already in the group") print(f"# {len(missing)} structures that I will add to the group") - group, _ = Group.objects.get_or_create(label=AIIDA_GROUP_LABEL) + group, _ = Group.collection.get_or_create(label=AIIDA_GROUP_LABEL) structures_to_add = [all_structures[extras] for extras in missing] # I need to store all these structures first for structure in structures_to_add: diff --git a/0-preliminary-do-not-run/unaries/old-sets/1-create_unaries_structures_group-set1.py b/0-preliminary-do-not-run/unaries/old-sets/1-create_unaries_structures_group-set1.py index 61ad973f..c4ca890c 100755 --- a/0-preliminary-do-not-run/unaries/old-sets/1-create_unaries_structures_group-set1.py +++ b/0-preliminary-do-not-run/unaries/old-sets/1-create_unaries_structures_group-set1.py @@ -112,7 +112,7 @@ def get_aiida_structures(alats): print(f"# {len(existing)} structures already in the group") print(f"# {len(missing)} structures that I will add to the group") - group, _ = Group.objects.get_or_create(label=AIIDA_GROUP_LABEL) + group, _ = Group.collection.get_or_create(label=AIIDA_GROUP_LABEL) structures_to_add = [all_structures[extras] for extras in missing] # I need to store all these structures first for structure in structures_to_add: diff --git a/1-preliminary/create_starting_subgroup.py b/1-preliminary/create_starting_subgroup.py index 44583a85..b5272e1b 100644 --- a/1-preliminary/create_starting_subgroup.py +++ b/1-preliminary/create_starting_subgroup.py @@ -39,8 +39,8 @@ def get_plugin_name(): STRUCTURES_FULL_GROUP_LABEL = f'acwf-verification/{SET_NAME}/structures' STRUCTURES_GROUP_LABEL = f'acwf-verification/{SET_NAME}/structures/{PLUGIN_NAME}' - group = orm.Group.objects.get(label=STRUCTURES_FULL_GROUP_LABEL) - subgroup, _ = orm.Group.objects.get_or_create(label=STRUCTURES_GROUP_LABEL) + group = orm.Group.collection.get(label=STRUCTURES_FULL_GROUP_LABEL) + subgroup, _ = orm.Group.collection.get_or_create(label=STRUCTURES_GROUP_LABEL) ##################################################################################### ## PLUGIN-SPECIFIC PART: ADD THE ELIF FOR YOUR CODE diff --git a/2-submit/launch_calculations_qe.py b/2-submit/launch_calculations_qe.py index 107764b3..8bb568d1 100755 --- a/2-submit/launch_calculations_qe.py +++ b/2-submit/launch_calculations_qe.py @@ -74,7 +74,7 @@ def get_inputs_and_processclass_from_extras(self, extras_values): 'sub_process' : { # optional code-dependent overrides 'base': { 'pw': { - 'settings' : orm.Dict(dict= { + 'settings' : orm.Dict({ 'cmdline': ['-nk', '32'], }) } diff --git a/3-analyze/get_results.py b/3-analyze/get_results.py index d19115a4..30433791 100755 --- a/3-analyze/get_results.py +++ b/3-analyze/get_results.py @@ -32,7 +32,7 @@ def extract_from_failed(node): streses=[] num_atoms = None num_attempt_vols = 0 - for i in node.get_outgoing(link_type=LinkType.CALL_WORK).all(): + for i in node.base.links.get_outgoing(link_type=LinkType.CALL_WORK).all(): num_attempt_vols = num_attempt_vols + 1 if i.node.is_finished_ok: if num_atoms is None: @@ -109,8 +109,8 @@ def get_plugin_name(): progress_bar = tqdm.tqdm(wf_nodes) for node in progress_bar: structure = node.inputs.structure - element = structure.extras['element'] - configuration = structure.extras['configuration'] + element = structure.base.extras.all['element'] + configuration = structure.base.extras.all['configuration'] uuid_mapping[f'{element}-{configuration}'] = { 'structure': structure.uuid, @@ -141,7 +141,7 @@ def get_plugin_name(): # For successfully finished workflows, collect the data from outputs if node.process_state.value == 'finished' and node.exit_status == 0: # Extract volumes and energies for this system - outputs = node.get_outgoing(link_type=LinkType.RETURN).nested() + outputs = node.base.links.get_outgoing(link_type=LinkType.RETURN).nested() for index, sub_structure in sorted(outputs['structures'].items()): if num_atoms is None: num_atoms = len(sub_structure.sites) @@ -152,7 +152,7 @@ def get_plugin_name(): volumes.append(sub_structure.get_cell_volume()) energy_node = outputs['total_energies'][index] energies.append(energy_node.value) - parent_workflows_links = energy_node.get_incoming(link_type=LinkType.RETURN).all() + parent_workflows_links = energy_node.base.links.get_incoming(link_type=LinkType.RETURN).all() parent_workflows = [ triple.node for triple in parent_workflows_links if issubclass(triple.node.process_class, CommonRelaxWorkChain)] @@ -214,8 +214,13 @@ def get_plugin_name(): bulk_modulus_GPa = bulk_modulus_internal * echarge * 1.0e21 #1 eV/Angstrom3 = 160.21766208 GPa bulk_modulus_ev_ang3 = bulk_modulus_GPa / 160.21766208 - data_to_print[(structure.extras['element'], structure.extras['configuration'])] = ( - min_volume, E0, bulk_modulus_GPa, bulk_deriv) + data_to_print[ + ( + structure.base.extras.all['element'], structure.base.extras.all['configuration'] + ) + ] = ( + min_volume, E0, bulk_modulus_GPa, bulk_deriv + ) BM_fit_data = { 'min_volume': min_volume, 'E0': E0, @@ -224,11 +229,16 @@ def get_plugin_name(): 'residuals': residuals[0] } if residuals[0] > 1.e-3: - warning_lines.append(f"WARNING! High fit residuals: {residuals[0]} for {structure.extras['element']} {structure.extras['configuration']}") + warning_lines.append( + f"WARNING! High fit residuals: {residuals[0]} for {structure.base.extras.all['element']} " + f"{structure.base.extras.all['configuration']}" + ) except ValueError: # If we cannot find a minimum # Note that BM_fit_data was already set to None at the top - warning_lines.append(f"WARNING! Unable to fit for {structure.extras['element']} {structure.extras['configuration']}") + warning_lines.append( + f"WARNING! Unable to fit for {structure.base.extras.all['element']} {structure.base.extras.all['configuration']}" + ) all_eos_data[f'{element}-{configuration}'] = eos_data num_atoms_in_sim_cell[f'{element}-{configuration}'] = num_atoms