Skip to content

Script to generate database.json prepends core. to transport and scheduler entries #90

@GeigerJ2

Description

@GeigerJ2

The following code:

# Prepare the config db for aiida 2.x data type entry points compatibility
def update_to_v2_entry_points(comp_setup: dict) -> dict:
"""
v1 -> v2 with attach `core.` in front for transport and scheduler.
This is a mutate function will change the value of argument `comp_setup`
"""
new_comp_setup = {}
for key, value in comp_setup.items():
if key in ['transport', 'scheduler']:
new_comp_setup[key] = f"core.{value}"
else:
new_comp_setup[key] = value
return new_comp_setup
final_dict_v2 = copy.deepcopy(final_dict)
# Loop over or the fields and update to compatible with aiida 2.x entry points name
for domain in final_dict_v2:
for computer in final_dict_v2[domain]:
if computer != 'default':
final_dict_v2[domain][computer]["computer-setup"] = update_to_v2_entry_points(final_dict_v2[domain][computer]["computer-setup"])
# Prepare the config db for aiida 2.1 data type entry points compatibility
def update_to_v2_1_entry_points(code_setup: dict) -> dict:
"""
v2 -> v2.1
orm.Code to orm.InstalledCode setup.
"""
# New parameters of InstalledCode setup
new_code_setup = {}
for key, value in code_setup.items():
if key == "input_plugin":
new_code_setup["default_calc_job_plugin"] = value
elif key == "on_computer":
continue
elif key == "remote_abs_path":
new_code_setup["filepath_executable"] = value
else:
new_code_setup[key] = value
return new_code_setup
final_dict_v2_1 = copy.deepcopy(final_dict_v2)
# Loop over or the fields and update to compatible with aiida 2.x entry points name
for domain in final_dict_v2_1:
for computer in final_dict_v2_1[domain]:
if computer != 'default':
for key in final_dict_v2_1[domain][computer]:
if key not in ['computer-setup', 'computer-configure']:
final_dict_v2_1[domain][computer][key] = update_to_v2_1_entry_points(final_dict_v2_1[domain][computer][key])
# Store the extracted information as a single JSON file.
os.mkdir(folder_path/'out')
with open(folder_path/'out/database.json', 'w') as filep:
json.dump(final_dict, filep, indent=4)
# Store the v2 compatible entry points
with open(folder_path/'out/database_v2.json', 'w') as filep:
json.dump(final_dict_v2, filep, indent=4)
# Store the v2.1 compatible code data
with open(folder_path/'out/database_v2_1.json', 'w') as filep:
json.dump(final_dict_v2_1, filep, indent=4)

automatically prepends the core. prefix to transport and scheduler endpoints for compatibility with AiiDA v2.

With my recent PR #88 in which I add the core. prefixes, this leads to entries of the form core.core.ssh in the database.json file. As AiiDA v2 has been around for long enough, I'd propose we just remove that code from the script? Better to have correct YAML files in this repo rather than doing an intransparent deployment step.

Ping @unkcpz

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions