Utility Functions

Module Initialization

orchestrator.utils.setup_input.supported_modules = ['augmentor', 'descriptor', 'oracle', 'potential', 'score', 'simulator', 'storage', 'target_property', 'trainer', 'workflow']

list of modules supported for automated setup. setup_orch_modules() returns modules in this order.

orchestrator.utils.setup_input.required_args_dict = {'augmentor': ['augmentor_type', 'augmentor_args'], 'descriptor': ['descriptor_type', 'descriptor_args'], 'oracle': ['oracle_type', 'oracle_args'], 'potential': ['potential_type', 'potential_args'], 'score': ['score_type', 'score_args'], 'simulator': ['simulator_type', 'simulator_args'], 'storage': ['storage_type', 'storage_args'], 'target_property': ['target_property_type'], 'trainer': ['trainer_type', 'trainer_args'], 'workflow': ['workflow_type', 'workflow_args']}

dict of required args for each module type

orchestrator.utils.setup_input.read_input(input_file)[source]

Reads a JSON input file to specify details of orchestrator modules.

Parameters:

input_file (str) – Path to the input JSON file.

Returns:

Parsed input parameters as a dictionary.

Return type:

dict

orchestrator.utils.setup_input.setup_orch_modules(jsondict)[source]

Initialize the main classes from Orchestrator

Given the flexibility of the orchestrator, setup only instantiate modules which are given in the input file. This setup currently supports the Augmentor, DescriptorBase, Oracle and AiidaOracle, Potential, ScoreBase, Simulator, Storage, TargetProperty, Trainer, and Workflow modules.

Parameters:

jsonfile (dict) – Input arguments parsed by read_input() from the JSON file.

Returns:

tuple of modules, set to None if not in input and a dict of like-modules if multiple sections are present in the input, i.e. ‘workflow1’, ‘workflow2’, ‘default_workflow’, …

Return type:

list of modules in order of supported modules

orchestrator.utils.setup_input.init_and_validate_module_type(module_name, input_args, single_input_dict=False)[source]

Initialize Orchestrator classes from their sections of the input file

This function both builds an Orchestrator module(s) and also ensures that the minimum keywords are provided.

Parameters:
  • module_name (str) – name of any Orchestrator module which has a builder

  • input_args (dict) – full input dictionary to initialize module_name from. Multilpe classes can be specified as long as their token includes the base module name.

  • single_input_dict (bool) – Optional flag if the input arguments are a dict of _type and _arg keywords for a single class instance instead of a full input dict.

    Default: False

Returns:

instantiated Orchestrator class or dictionary of multiply specified classes.

Return type:

Orchestrator class or dict of Orchestrator classes

Input File Templates

class orchestrator.utils.templates.Templates(template_file, output_path, output_file_name=None)[source]

Bases: object

Class for populating an external code input file with templated patterns.

This class reads a template file, replaces specified patterns with corresponding values, and writes the modified content to an output file. If a file with the same name already exists, a numeric suffix is appended to avoid overwriting.

Parameters:
  • template_file (str) – Filename (including path) of the template file.

  • output_path (str) – Path where the constructed file should be saved.

  • output_file_name (str, optional) – Optional name for the output file. If not provided, the name of the template file will be used.

__init__(template_file, output_path, output_file_name=None)[source]

Initialize the Templates class.

Sets up the template file, output path, and output file name. If an output file name is not provided, the name of the template file will be used.

Parameters:
  • template_file (str) – Filename (including path) of the template file.

  • output_path (str) – Path where the constructed file should be saved.

  • output_file_name (str, optional) – Optional name for the output file. If not provided, the name of the template file will be used.

replace(patterns, replacements)[source]

Replace <templated> values in the template file with specific data.

Patterns and replacements are ordered lists, where each pattern in the template file is replaced with the corresponding value from the replacements list. For example, patterns[0] will be replaced with replacements[0]. If a file with the same name already exists, a numeric suffix (_n, where n is an integer starting at 1) will be appended to the file name to avoid overwriting.

Parameters:
  • patterns (list of str) – List of patterns to replace in the template file.

  • replacements (list of str) – List of values to replace the patterns with.

Returns:

Name of the generated file (not including the full path).

Return type:

str

Raises:

ValueError – If the lengths of patterns and replacements do not match.

Non-class Utility

Data Keys

Keys for standardizing access to common properties/fields in an ASE.Atoms object. These are usually taken to match existing ColabFit property-definition names.

orchestrator.utils.data_standard.ENERGY_KEY = 'energy_energy'

key for accessing energies from internal Atoms info dicts

orchestrator.utils.data_standard.FORCES_KEY = 'atomic_forces_forces'

key for accessing forces from internal Atoms arrays

orchestrator.utils.data_standard.STRESS_KEY = 'cauchy_stress_stress'

key for accessing stresses from internal Atoms info dicts

orchestrator.utils.data_standard.DESCRIPTORS_KEY = 'descriptors'

key for accessing descriptors from internal Atoms arrays

orchestrator.utils.data_standard.ENERGY_WEIGHT_KEY = 'structure_weight'

key for accessing per-structure weights from internal Atoms info dicts

orchestrator.utils.data_standard.FORCES_WEIGHTS_KEY = 'atomic_weights'

key for accessing per-atom weights from internal Atoms arrays

orchestrator.utils.data_standard.METADATA_KEY = '_metadata'

key for accessing the metadata dict from internal Atoms info dicts

orchestrator.utils.data_standard.SELECTION_MASK_KEY = 'selection_mask'

key for accessing per-atom selector boolean from internal Atoms arrays

Data Inspection

orchestrator.utils.data_utils.inspect_configs(configs)[source]

Prints useful information about a set of ase.Atoms objects

Parameters:

configs (list[ase.Atoms]) – list of ase.Atoms objects to inspect

Convenience Parsing

orchestrator.utils.input_output.ase_glob_read(root_dir, file_ext='.xyz', file_format='extxyz')[source]

Reads all ASE atoms objects in root_dir with the matching` file_ext.