ConditionalGroup

class propertyestimator.protocols.groups.ConditionalGroup(protocol_id)[source]

A collection of protocols which are to execute until a given condition is met.

__init__(protocol_id)[source]

Constructs a new ConditionalGroup

Methods

__init__(protocol_id)

Constructs a new ConditionalGroup

add_condition(condition_to_add)

Adds a condition to this groups list of conditions if it not already in the condition list.

add_protocols(*protocols)

apply_replicator(replicator, template_values)

Applies a ProtocolReplicator to this protocol.

can_merge(other)

Determines whether this protocol group can be merged with another.

execute(directory, available_resources)

Executes the protocols within this groups

get_attribute_type(reference_path)

Returns the type of one of the protocol input/output attributes.

get_value(reference_path)

Returns the value of one of this protocols parameters / inputs.

get_value_references(input_path)

Returns a dictionary of references to the protocols which one of this protocols inputs (specified by input_path) takes its value from.

merge(other)

Merges another ProtocolGroup with this one.

replace_protocol(old_id, new_id)

Finds each input which came from a given protocol

set_uuid(value)

Store the uuid of the calculation this protocol belongs to

set_value(reference_path, value)

Sets the value of one of this protocols parameters / inputs.

Attributes

allow_merging

If true, this protocol is allowed to merge with other identical protocols.

conditions

dependants_graph

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

dependencies

A list of pointers to the protocols which this protocol takes input from.

execution_order

The ids of the protocols in the group, in the order in which they will be internally executed.

id

The unique id of this protocol.

max_iterations

The maximum number of iterations to run for to try and satisfy the groups conditions.

protocols

A dictionary of the protocols in this groups, where the dictionary key is the protocol id, and the value the protocol itself.

root_protocols

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

schema

A serializable schema for this object.

class ConditionType[source]

The acceptable conditions to place on the group

max_iterations

The maximum number of iterations to run for to try and satisfy the groups conditions.

execute(directory, available_resources)[source]

Executes the protocols within this groups

Parameters
  • directory (str) – The root directory in which to run the protocols

  • available_resources (ComputeResources) – The resources available to execute on.

Returns

True if all the protocols execute correctly.

Return type

bool

can_merge(other)[source]

Determines whether this protocol group can be merged with another.

Parameters

other (ProtocolGroup) – The protocol group to compare against.

Returns

True if the two protocols are safe to merge.

Return type

bool

merge(other)[source]

Merges another ProtocolGroup with this one. The id of this protocol will remain unchanged.

It is assumed that can_merge has already returned that these protocol groups are compatible to be merged together.

Parameters

other (ConditionalGroup) – The protocol to merge into this one.

add_condition(condition_to_add)[source]

Adds a condition to this groups list of conditions if it not already in the condition list.

Parameters

condition_to_add (ConditionalGroup.Condition) – The condition to add.

set_uuid(value)[source]

Store the uuid of the calculation this protocol belongs to

Parameters

value (str) – The uuid of the parent calculation.

replace_protocol(old_id, new_id)[source]
Finds each input which came from a given protocol

and redirects it to instead take input from a different one.

Parameters
  • old_id (str) – The id of the old input protocol.

  • new_id (str) – The id of the new input protocol.

get_attribute_type(reference_path)[source]

Returns the type of one of the protocol input/output attributes.

Parameters

reference_path (ProtocolPath) – The path pointing to the value whose type to return.

Returns

The type of the attribute.

Return type

type

get_value(reference_path)[source]

Returns the value of one of this protocols parameters / inputs.

Parameters

reference_path (ProtocolPath) – The path pointing to the value to return.

Returns

The value of the input

Return type

object

set_value(reference_path, value)[source]

Sets the value of one of this protocols parameters / inputs.

Parameters
  • reference_path (ProtocolPath) – The path pointing to the value to return.

  • value (Any) – The value to set.

get_value_references(input_path)[source]

Returns a dictionary of references to the protocols which one of this protocols inputs (specified by input_path) takes its value from.

Notes

Currently this method only functions correctly for an input value which is either currently a ProtocolPath, or a list / dict which contains at least one ProtocolPath.

Parameters

input_path (propertyestimator.workflow.utils.ProtocolPath) – The input value to check.

Returns

A dictionary of the protocol paths that the input targeted by input_path depends upon.

Return type

dict of ProtocolPath and ProtocolPath

allow_merging

If true, this protocol is allowed to merge with other identical protocols.

Type

bool

apply_replicator(replicator, template_values, template_index=-1, template_value=None, update_input_references=False)

Applies a ProtocolReplicator to this protocol. This method should clone any protocols whose id contains the id of the replicator (in the format $(replicator.id)).

Parameters
  • replicator (ProtocolReplicator) – The replicator to apply.

  • template_values (list of Any) –

    A list of the values which will be inserted into the newly replicated protocols.

    This parameter is mutually exclusive with template_index and template_value

  • template_index (int, optional) –

    A specific value which should be used for any protocols flagged as to be replicated by the replicator. This option is mainly used when replicating children of an already replicated protocol.

    This parameter is mutually exclusive with template_values and must be set along with a template_value.

  • template_value (Any, optional) –

    A specific index which should be used for any protocols flagged as to be replicated by the replicator. This option is mainly used when replicating children of an already replicated protocol.

    This parameter is mutually exclusive with template_values and must be set along with a template_index.

  • update_input_references (bool) –

    If true, any protocols which take their input from a protocol which was flagged for replication will be updated to take input from the actually replicated protocol. This should only be set to true if this protocol is not nested within a workflow or a protocol group.

    This option cannot be used when a specific template_index or template_value is providied.

Returns

A dictionary of references to all of the protocols which have been replicated, with keys of original protocol ids. Each value is comprised of a list of the replicated protocol ids, and their index into the template_values array.

Return type

dict of ProtocolPath and list of tuple of ProtocolPath and int

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[str, str]

property dependencies

A list of pointers to the protocols which this protocol takes input from.

Type

list of ProtocolPath

property execution_order

The ids of the protocols in the group, in the order in which they will be internally executed.

Type

List[str]

property id

The unique id of this protocol.

Type

str

property protocols

A dictionary of the protocols in this groups, where the dictionary key is the protocol id, and the value the protocol itself.

Type

Dict[str, BaseProtocol]

property root_protocols

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

Type

List[str]

property schema

A serializable schema for this object.

Type

ProtocolSchema