# ProtocolReplicator

class `propertyestimator.workflow.schemas.``ProtocolReplicator`(replicator_id='')

  A protocol replicator contains the information necessary to replicate parts of a property estimation workflow.

  Any protocol whose id includes $(replicator.id) (where replicator.id is the id of a replicator) will be cloned for each value present in template_values. Protocols that are being replicated will also have any ReplicatorValue inputs replaced with the actual value taken from template_values.

  When the protocol is replicated, the $(replicator.id) placeholder in the protocol id will be replaced an integer which corresponds to the index of a value in the template_values array.

  Any protocols which take input from a replicated protocol will be updated to instead take a list of value, populated by the outputs of the replicated protocols.

  Notes

  - The template_values property must be a list of either constant values, or ProtocolPath objects which take their value from the global scope.

  - If children of replicated protocols are also flagged as to be replicated, they will only have their ids changed to match the index of the parent protocol, as opposed to being fully replicated.

  `__init__`(replicator_id='')

    Constructs a new ProtocolReplicator object.

    Parameters

      replicator_id (str) – The id of this replicator.

  Methods

  `__init__`([replicator_id]) | Constructs a new ProtocolReplicator object.
  `apply`(protocols[, template_values, …]) | Applies this replicator to the provided set of protocols and any of their children.
  `json`() | Creates a JSON representation of this class.
  `parse_json`(string_contents[, encoding]) | Parses a typed json string into the corresponding class structure.
  `update_references`(protocols, …) | Redirects the input references of protocols to the replicated versions.

  Attributes

  `placeholder_id` | The string which protocols to be replicated should include in their ids.

  property `placeholder_id`

    The string which protocols to be replicated should include in their ids.

  `apply`(protocols, template_values=None, template_index=-1, template_value=None)

    Applies this replicator to the provided set of protocols and any of their children.

    This protocol should be followed by a call to update_references to ensure that all protocols which take their input from a replicated protocol get correctly updated.

    Parameters

      - protocols (dict of str and BaseProtocol) – The protocols to apply the replicator to.

      - 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 this 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 this 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.

    Returns

      - dict of str and BaseProtocol – The replicated protocols.

      - dict of ProtocolPath and list of tuple of ProtocolPath and int – 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.

  `update_references`(protocols, replication_map, template_values)

    Redirects the input references of protocols to the replicated versions.

    Parameters

      - protocols (dict of str and BaseProtocol) – The protocols which have had this replicator applied to them.

      - replication_map (dict of ProtocolPath and list of tuple of ProtocolPath and int) – 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.

      - template_values (List of Any) – A list of the values which will be inserted into the newly replicated protocols.

  `json`()

    Creates a JSON representation of this class.

    Returns

      The JSON representation of this class.

    Return type

      str

  classmethod `parse_json`(string_contents, encoding='utf8')

    Parses a typed json string into the corresponding class structure.

    Parameters

      - string_contents (str or bytes) – The typed json string.

      - encoding (str) – The encoding of the string_contents.

    Returns

      The parsed class.

    Return type

      Any