Interface Utility Functions

The functions defined here are used to support the interactive and command-line interfaces for vivarium.

vivarium.interface.utilities.run_from_ipython()[source]

Taken from https://stackoverflow.com/questions/5376837/how-can-i-do-an-if-run-from-ipython-test-in-python

Return type:

bool

vivarium.interface.utilities.log_progress(sequence, every=None, size=None, name='Items')[source]

Taken from https://github.com/alexanderkuk/log-progress

Return type:

Generator[int, None, None]

Parameters:
exception vivarium.interface.utilities.InteractiveError[source]

Error raised when the Interactive context is in an inconsistent state.

vivarium.interface.utilities.raise_if_not_setup(system_type)[source]
Return type:

Callable[..., Any]

Parameters:

system_type (str)

vivarium.interface.utilities.get_output_model_name_string(artifact_path, model_spec_path)[source]

Find a good string to use as model name in output path creation.

Return type:

str

Parameters:
  • artifact_path (str | Path) – Path to the artifact file, if exists, else should be None

  • model_spec_path (str | Path) – Path to the model specification file. This must exist.

Returns:

A model name string for use in output labeling.

vivarium.interface.utilities.get_output_root(results_directory, model_specification_file, artifact_path)[source]

Create a root directory for output files.

Return type:

Path

Parameters:
  • results_directory (str | Path) – Directory to store the results in.

  • model_specification_file (str | Path) – Path to the model specification file.

  • artifact_path (str | Path) – Path to the artifact file.

Returns:

The date-stamped output root directory.