Status Enums

melissa.server.simulation.SimulationDataStatus

Bases: Enum

Enum class representing the possible statuses of simulation data.

melissa.server.simulation.SimulationStatus

Bases: Enum

Enum class representing the possible statuses of a simulation's state.

Simulation Data types

melissa.server.simulation.SimulationData

Stores data related to a specific simulation.

Attributes
  • simulation_id (int): The id of the simulation.
  • time_step (int): The time step for the simulation.
  • data (Dict[str, Any]): The data associated with the simulation per field.
  • parameters (list): The list of parameters for the simulation.

__repr__()

Returns a string representation of the SimulationData object.

melissa.server.simulation.PartialSimulationData

Stores partial data for a specific simulation, including information on time step, client rank, and field.

Attributes
  • time_step (int): The time step for the simulation.
  • simulation_id (int): The id of the simulation.
  • client_rank (int): The rank of the client submitting the data.
  • data_size (int): The size of the data associated with the simulation.
  • field (str): The field to which the data belongs.
  • data (Any): The actual data associated with the simulation.

from_msg(msg, learning) classmethod

Class method to deserialize a message and create an instance of the class.

Parameters
  • msg (bytes): The serialized message in bytes format to be deserialized.
  • learning (int): A flag or parameter used during the deserialization process.
Returns
  • PartialSimulationData: A new instance of the class created from the deserialized message.

__repr__()

Returns a string representation of the PartialSimulationData object.

Main Classes

melissa.server.simulation.Simulation

Represents a single simulation with associated metadata. Each object corresponds to a unique simulation or client and contains information necessary for tracking the simulation's state, parameters, and fault tolerance.

Attributes
  • id_ (int): The unique identifier for the simulation.
  • nb_time_steps (int): The total number of time steps for the simulation.
  • fields (List[str]): A list of fields that will be sent.
  • parameters (List[Any]): A list of parameters used in the simulation.

init_structures(client_rank, time_steps_known=True)

Initializes data structures to track received simulation data for a given client rank.

Parameters
  • client_rank (int): The rank of the client whose data is being tracked.
  • time_steps_known (bool, optional): if the total number of time steps is known in advance. Default is True.

init_data_storage(client_rank, time_step)

Prepares storage for tracking field-level data for a specific time step of a client rank.

Parameters
  • client_rank (int): The rank of the client whose data is being tracked.
  • time_step (int): The time step for which data storage is initialized.

time_step_expansion(client_rank, time_step)

Dynamically expands the received_time_steps matrix for a client rank if the time step exceeds current capacity.

Parameters
  • client_rank (int): The rank of the client whose matrix needs expansion.
  • time_step (int): The time step that triggered the need for expansion.

update(client_rank, time_step, field, data)

Updates the data associated with a specific field and time step for a client rank.

Parameters
  • client_rank (int): The rank of the client whose data is being updated.
  • time_step (int): The time step associated with the data.
  • field (str): The specific field being updated.
  • data (Optional[Union[int, PartialSimulationData]]): The new data to store for the field.

get_data(client_rank, time_step)

Retrieves the data for all fields associated with a specific time step of a client rank.

Parameters
  • client_rank (int): The rank of the client whose data is being retrieved.
  • time_step (int): The time step for which data is being fetched.
Returns
  • Dict[str, Optional[Union[int, PartialSimulationData]]]: A dictionary containing field names as keys and their corresponding data as values.

clear_data(client_rank, time_step)

Clears the data for all fields associated with a specific time step of a client rank. Useful when the complete data is given to the server for post-processing and no longer needs to be in this object. This is to avoid duplications in checkpointing.

Parameters
  • client_rank (int): The rank of the client whose data is being cleaned.
  • time_step (int): The time step for which data is being cleaned.

crashed()

Unused.

has_already_received(client_rank, time_step, field)

Checks if the given time step has already been received for the specified client and field, helping to avoid duplication of data.

Parameters
  • client_rank (int): The rank of the client whose data is being retrieved.
  • time_step (int): The time step for which the data is being checked.
  • field (str): The field associated with the data being checked.
Returns
  • bool: if the data has already been received.

is_complete(time_step)

Checks if the given time step has data for all the defined fields.

Parameters
  • time_step (int): The time step to check for completeness.
Returns
  • bool: if data has been received for all defined fields.

mark_as_received(client_rank, time_step, field)

Marks the given time step as received for the specified field.

Parameters
  • client_rank (int): The rank of the client sending the data.
  • time_step (int): The time step for which the data is received.
  • field (str): The field associated with the data being marked as received.

finished()

Checks whether all time steps for the simulation have been received.

Returns
  • bool: True if all time steps have been received.

melissa.server.simulation.Group

Represents a Sobol group with all the relevant simulations.

This class maintains a caching mechanism for storing corresponding time steps received for the current group.

Attributes
  • group_id (int): The id of the group.
  • sobol_ (bool): A flag indicating whether the group uses Sobol cache. (default is False).

__len__()

Returns length of the current group.

cache(pdata)

Caches the received simulation data for the specified field, simulation id, client rank, and time step.

Parameters
  • pdata (PartialSimulationData): The simulation data to be cached.

get_cached(field, client_rank, time_step)

Retrieves cached group data for the specified field, client rank, and time step.

Parameters
  • field (str): The field associated with the simulation data.
  • client_rank (int): The rank of the client whose data is being retrieved.
  • time_step (int): The time step of the simulation.
Returns
  • NDArray[np.float64]: The cached data sorted by simulation ids.