pydcop.distribution.objects

class Distribution(mapping: Dict[str, List[str]])

This object is a convenient representation of a distribution with methods for querying it (has_computation, agent_for, etc.)

Parameters:

mapping (mapping: Dict[str, List[str]]) – A dict agent name: [computation names]. Basic validity checks are performed to ensure that the same computation is not hosted on several agents.

agent_for(computation: str) str

Agent hosting one given computation :param computation: a computation’s name :type computation: str

Returns:

the name of the agent hosting this computation.

Return type:

str

property agents: List[str]

Agents used in this distribution

Returns:

The list of the names of agents used in this distribution.

Return type:

agents list

property computations: List[str]

Distributed computations

Returns:

A list containing the names of the computations distributed in this distribution.

Return type:

computations list

computations_hosted(agent: str) List[str]

Computations hosted on an agent.

If the agent is not used in the distribution (its name is not known), returns an empty list.

Parameters:

agent (str) – the name of the agent

Returns:

The list of computations hosted by this agent.

Return type:

List[str]

has_computation(computation: str)
Parameters:

computation (str) – computation name

Returns:

True if this computation is part of the distribution

Return type:

Boolean

host_on_agent(agent: str, computations: List[str])

Host several computations on an agent.

Modify the distribution by adding computations to be hosted on agent. If this agent name is unknown, it is added, otherwise the list of computations is added to the computations already hosted by this agent.

Parameters:
  • agent (str) – an agent name

  • computations (List[str]) – A list of computation names

is_hosted(computations: str | Iterable[str])

Indicates if some computations are hosted.

This method does not care on which agent the computations are hosted.

Parameters:

computations (List[str]) – A list of computation names

Returns:

True if all computations are hosted.

Return type:

Boolean

mapping() Dict[str, List[str]]

The distribution represented as a dict.

Returns:

A dict associating a list of computation names to each agent name.

Return type:

Dict[str, List[str]]

exception ImpossibleDistributionException