ProtocolGraph

class propertyestimator.workflow.ProtocolGraph[source]

A graph of connected protocols which may be executed together.

__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

Methods

__init__()

Initialize self.

add_protocols(*protocols[, …])

Adds a set of protocols to the graph.

execute([root_directory, …])

Execute the protocol graph in the specified directory, and either using a CalculationBackend, or using a specified set of compute resources.

Attributes

dependants_graph

A dictionary of which stores which grouped protocols are dependant on other grouped protocols.

protocols

The protocols in this graph.

root_protocols

The ids of the protocols in the group which do not take input from the other grouped protocols.

property protocols

The protocols in this graph.

Type

dict of str and Protocol

property root_protocols

The ids of the protocols in the group which do not take input from the other grouped protocols.

Type

list of str

property dependants_graph

A dictionary of which stores which grouped protocols are dependant on other grouped protocols. Each key in the dictionary is the id of a grouped protocol, and each value is the id of a protocol which depends on the protocol by the key.

Type

dict of str and str

add_protocols(*protocols, allow_external_dependencies=False)[source]

Adds a set of protocols to the graph.

Parameters
  • protocols (tuple of Protocol) – The protocols to add.

  • allow_external_dependencies (bool) – If False, an exception will be raised if a protocol has a dependency outside of this graph.

Returns

A mapping between the original protocols and protocols which were merged over the course of adding the new protocols.

Return type

dict of str and str

execute(root_directory='', calculation_backend=None, compute_resources=None, enable_checkpointing=True, safe_exceptions=True)[source]

Execute the protocol graph in the specified directory, and either using a CalculationBackend, or using a specified set of compute resources.

Parameters
  • root_directory (str) – The directory to execute the graph in.

  • calculation_backend (CalculationBackend, optional.) – The backend to execute the graph on. This parameter is mutually exclusive with compute_resources.

  • compute_resources (CalculationBackend, optional.) – The compute resources to run using. This parameter is mutually exclusive with calculation_backend.

  • enable_checkpointing (bool) – If enabled, protocols will not be executed more than once if the output from their previous execution is found.

  • safe_exceptions (bool) – If true, exceptions will be serialized into the results file rather than directly raised, otherwise, the exception will be raised as normal.

Returns

The paths to the JSON serialized outputs of the executed protocols. If executed using a calculation backend, these will be Future objects which will return the output paths on calling future.result().

Return type

dict of str and str or Future