netunicorn.base.experiment.Experiment

class Experiment(deployment_context=None)[source]

Bases: object

Represents an experiment that contains a mapping of execution graphs to nodes.

Parameters:

deployment_context (Optional[Dict[str, Dict[str, str]]], default: None) – deployment context to be used by connectors.

Attributes

deployment_map

a list of deployments

deployment_context

A dictionary that contains a context for deployments.

Methods

append

Append a new deployment (mapping of an execution graph to a node) to the experiment.

from_json

Creates an instance of Experiment from a JSON representation.

map

Map an execution graph to a sequence of nodes.

deployment_map: List[Deployment][source]

a list of deployments

deployment_context: Optional[Dict[str, Dict[str, str]]][source]

A dictionary that contains a context for deployments. Context is to be provided by connectors. Format: {connector_name: {key: value}}

append(node, pipeline)[source]

Append a new deployment (mapping of an execution graph to a node) to the experiment.

Parameters:
  • node (Node) – a node to deploy the execution graph to.

  • pipeline (ExecutionGraph) – a pipeline (execution graph) to deploy.

Returns:

Experiment – self.

map(pipeline, nodes)[source]

Map an execution graph to a sequence of nodes.

Parameters:
  • pipeline (ExecutionGraph) – a pipeline (execution graph) to deploy.

  • nodes (Sequence[Node]) – a sequence of nodes to deploy the execution graph to.

Returns:

Experiment – self.

classmethod from_json(data)[source]

Creates an instance of Experiment from a JSON representation.

Parameters:

data (ExperimentRepresentation) – a JSON representation of an experiment.

Returns:

Experiment – an instance of Experiment.

__getitem__(item)[source]

Returns a deployment by index.

Parameters:

item (int) – an index of a deployment.

Returns:

Deployment – a deployment.

__iter__()[source]

Returns an iterator over deployments.

Returns:

Iterator[Deployment] – an iterator over deployments.

__len__()[source]

Returns a number of deployments in the experiment.

Returns:

int – a number of deployments in the experiment.

__add__(other)[source]

Concatenates two experiments resulting in a union of deployments.

Parameters:

other (Experiment) – an experiment to concatenate with.

Returns:

Experiment – a new experiment.