wrench.simulation

class wrench.simulation.Simulation(daemon_host: Optional[str] = 'localhost', daemon_port: Optional[int] = 8101)

Bases: object

WRENCH Simulation class. This class implements a simulation “client” that connects to a local wrench-daemon that implements the WRENCH REST API (and which must be started independently). It provides top-level methods for instantiating and running a simulation.

Parameters:
  • daemon_host (str) – name of the host on which the WRENCH daemon is running

  • daemon_port (int) – port number on which the WRENCH daemon is listening

add_file(name: str, size: int) File

Add a file to the simulation

Parameters:
  • name (str) – file name

  • size (int) – file size in bytes

Returns:

A file object

Return type:

File

Raises:

WRENCHException – if there is any error in the response

create_bare_metal_compute_service(hostname: str, resources: dict[str, [<class 'int'>, <class 'int'>]], scratch_space: str, property_list: dict[str, str], message_payload_list: dict[str, int]) BareMetalComputeService

Create a bare metal compute service

Parameters:
  • hostname (str) – name of the (simulated) host on which the compute service should run

  • resources – compute resources as a dict of hostnames where values are tuples of #cores and ram in bytes (negative values mean: use everything available)

  • scratch_space (str) – the compute service’s scratch space’s mount point (”” means none)

  • property_list (dict) – a property list ({} means “use all defaults”)

  • message_payload_list (dict) – a message payload list ({} means “use all defaults”)

Returns:

the service name

Return type:

BareMetalComputeService

Raises:

WRENCHException – if there is any error in the response

create_batch_compute_service(hostname: str, resources: list, scratch_space: str, property_list: dict[str, str], message_payload_list: dict[str, int]) BatchComputeService

Create a batch compute service

Parameters:
  • hostname (str) – name of the (simulated) host on which the compute service should run

  • resources – compute resources as a list of hostnames

  • scratch_space (str) – the compute service’s scratch space’s mount point (”” means none)

  • property_list (dict) – a property list ({} means “use all defaults”)

  • message_payload_list (dict) – a message payload list ({} means “use all defaults”)

Returns:

the service name

Return type:

BatchComputeService

Raises:

WRENCHException – if there is any error in the response

create_cloud_compute_service(hostname: str, execution_host: list, scratch_space: str, property_list: dict[str, str], message_payload_list: dict[str, int]) CloudComputeService

Create a cloud compute service

Parameters:
  • hostname (str) – name of the (simulated) host on which the compute service should run

  • execution_host – compute resources as a list of hostnames

  • scratch_space (str) – the compute service’s scratch space’s mount point (”” means none)

  • property_list (dict) – a property list ({} means “use all defaults”)

  • message_payload_list (dict) – a message payload list ({} means “use all defaults”)

Returns:

the service name

Return type:

CloudComputeService

Raises:

WRENCHException – if there is any error in the response

create_compound_job(name: str) CompoundJob

Create a Compound job

Parameters:

name (str) – Name of job

Returns:

A CompoundJob object

Return type:

CompoundJob

Raises:

WRENCHException – if there is any error in the response

create_file_registry_service(hostname: str) FileRegistryService

Create a file registry service

Parameters:

hostname (str) – name of the (simulated) host on which the file registry service should run

Returns:

the service name

Return type:

FileRegistryService

Raises:

WRENCHException – if there is any error in the response

create_simple_storage_service(hostname: str, mount_points: List[str]) StorageService

Create a simple storage service

Parameters:
  • hostname (str) – name of the (simulated) host on which the storage service should run

  • mount_points (List[str]) – list of mount points (i.e., disks) that the storage service should use

Returns:

the service name

Return type:

StorageService

Raises:

WRENCHException – if there is any error in the response

create_standard_job(tasks: List[Task], file_locations: dict[wrench.file.File, wrench.storage_service.StorageService]) StandardJob

Create a standard job

Parameters:
  • tasks (List[Task]) – list of tasks

  • file_locations (List[FileLocation]) – list of file locations

Returns:

A StandardJob object

Return type:

StandardJob

Raises:

WRENCHException – if there is any error in the response

create_workflow() Workflow

Create a workflow

Returns:

A workflow object

Return type:

Workflow

create_workflow_from_json(json_object: <module 'json' from '/home/docs/.asdf/installs/python/3.11.12/lib/python3.11/json/__init__.py'>, reference_flop_rate: str, ignore_machine_specs: bool, redundant_dependencies: bool, ignore_cycle_creating_dependencies: bool, min_cores_per_task: int, max_cores_per_task: int, enforce_num_cores: bool, ignore_avg_cpu: bool, show_warnings: bool) Workflow

Create a workflow from a JSON file

Parameters:
  • json_object (json) – A JSON object created from a WfCommons JSON file

  • reference_flop_rate (str) – reference flop rate (e.g., “100Mf”)

  • ignore_machine_specs (bool) – whether to ignore machine specifications in the JSON

  • redundant_dependencies (bool) – whether to take into account redundant task dependencies

  • ignore_cycle_creating_dependencies (bool) – whether to ignore cycles when creating task dependencies

  • min_cores_per_task (int) – the minimum number of cores for a task if not specified in the JSON

  • max_cores_per_task (int) – the maximum number of cores for a task if not specified in the JSON

  • enforce_num_cores (bool) – whether to enforce the number of cores for a task even if specified in the JSON

  • ignore_avg_cpu (bool) – whether to ignore the average CPU time information in the JSON to compute sequential task execution times

  • show_warnings (bool) – whether to show warnings when importing the JSON (displayed on the wrench-daemon console)

Returns:

A workflow

Return type:

Workflow

get_all_files() dict[str, wrench.file.File]

Get the list of all files

Returns:

A dictionary of File objects where ta names are keys

Return type:

dict[str, File]

get_all_hostnames() List[str]

Get the list of hostnames in the simulated platform

Returns:

list of hostnames

Return type:

List[str]

get_events() List[Dict[str, Union[str, StandardJob, ComputeService]]]

Get all simulation events since last time we checked

Returns:

A list of events

Return type:

List[Dict[str, Union[str, StandardJob, ComputeService]]]

get_simulated_time() float

Get the current simulation date :return: the simulation date :rtype: float

sleep(seconds: float) None

Sleep (in simulation) for a number of seconds

Parameters:

seconds (float) – number of seconds

start(platform_xml: str, controller_hostname: str) None

Start a new simulation (will do nothing if simulation has already started)

Parameters:
  • platform_xml (str) – platform description string in XML

  • controller_hostname (str) – the name of the (simulated) host in the platform on which the simulation controller will run

Raises:

WRENCHException – if there is any error during the simulation instantiation

terminate() None

Terminate the simulation

wait_for_next_event() Dict[str, Union[str, StandardJob, ComputeService]]

Wait for the next simulation event to occur

Returns:

A JSON object

Return type:

Dict[str, Union[str, StandardJob, ComputeService]]