Branch and Keyspace Management

Tools for managing the parameter space of a parallel run.

class vivarium_cluster_tools.psimulate.branches.Keyspace(branches, keyspace)[source]

A representation of a collection of simulation configurations.

Parameters:
classmethod from_branch_configuration(branch_configuration_file)[source]
Parameters:

branch_configuration_file (str | Path) – Absolute path to the branch configuration file.

Return type:

Keyspace

classmethod from_previous_run(keyspace_path, branches_path)[source]
Parameters:
  • keyspace_path (Path) –

  • branches_path (Path) –

Return type:

Keyspace

classmethod from_entry_point_args(input_branch_configuration_path, keyspace_path, branches_path, extras)[source]
Parameters:
  • input_branch_configuration_path (Path | None) –

  • keyspace_path (Path) –

  • branches_path (Path) –

  • extras (Dict) –

Return type:

Keyspace

persist(keyspace_path, branches_path)[source]
Parameters:
  • keyspace_path (Path) –

  • branches_path (Path) –

Return type:

None

add_draws(num_draws)[source]
Parameters:

num_draws (int) –

Return type:

None

add_seeds(num_seeds)[source]
Parameters:

num_seeds (int) –

Return type:

None

vivarium_cluster_tools.psimulate.branches.calculate_input_draws(input_draw_count, existing_draws=None)[source]

Determines a random sample of the GBD input draws to use given a draw count and any existing draws.

Parameters:
  • input_draw_count (int) – The number of draws to pull.

  • existing_draws (List[int]) – Any draws that have already been pulled and should not be pulled again.

Returns:

A set of unique input draw numbers, guaranteed not to overlap with any existing draw numbers.

Return type:

List[int]

vivarium_cluster_tools.psimulate.branches.calculate_random_seeds(random_seed_count, existing_seeds=None)[source]

Generates random seeds to use given a count of seeds and any existing seeds.

Parameters:
  • random_seed_count (int) – The number of random seeds to generate.

  • existing_seeds (List[int]) – Any random seeds that have already been generated and should not be generated again.

Returns:

A set of unique random seeds, guaranteed not to overlap with any existing random seeds.

Return type:

List[int]

vivarium_cluster_tools.psimulate.branches.calculate_keyspace(branches)[source]
Parameters:

branches (List[Dict]) –

Return type:

Dict

vivarium_cluster_tools.psimulate.branches.load_branch_configuration(path)[source]
Parameters:

path (Path) –

Return type:

Tuple[List[Dict], int, int, List[int] | None, List[int] | None]

vivarium_cluster_tools.psimulate.branches.expand_branch_templates(templates)[source]

Take a list of dictionaries of configuration values (like the ones used in experiment branch configurations) and expand it by taking any values which are lists and creating a new set of branches which is made up of the product of all those lists plus all non-list values.

For example this:

{'a': {'b': [1,2], 'c': 3, 'd': [4,5,6]}}

becomes this:

[
    {'a': {'b': 1, 'c': 3, 'd': 4}},
    {'a': {'b': 2, 'c': 3, 'd': 5}},
    {'a': {'b': 1, 'c': 3, 'd': 6}},
    {'a': {'b': 2, 'c': 3, 'd': 4}},
    {'a': {'b': 1, 'c': 3, 'd': 5}},
    {'a': {'b': 2, 'c': 3, 'd': 6}}
]
Parameters:

templates (Dict) –

Return type:

List[Dict]

vivarium_cluster_tools.psimulate.branches.validate_artifact_path(artifact_path)[source]

Validates that the path to the data artifact from the branches file exists.

The path specified in the configuration must be absolute

Parameters:

artifact_path (str) – The path to the artifact.

Return type:

str