From e1dd6faadc6e6eb3be7f3e941b56bff035d4661a Mon Sep 17 00:00:00 2001 From: Henri Casanova Date: Tue, 22 Oct 2024 11:48:27 -1000 Subject: [PATCH] Removing floats --- tests/compound_job_test.py | 4 +-- wrench/cloud_compute_service.py | 6 ++--- wrench/compound_job.py | 8 +++--- wrench/compute_action.py | 8 +++--- wrench/file_read_action.py | 10 +++---- wrench/simulation.py | 46 ++++++++++++++++----------------- wrench/task.py | 4 +-- wrench/workflow.py | 4 +-- 8 files changed, 45 insertions(+), 45 deletions(-) diff --git a/tests/compound_job_test.py b/tests/compound_job_test.py index 3f40a6f..569d289 100755 --- a/tests/compound_job_test.py +++ b/tests/compound_job_test.py @@ -68,7 +68,6 @@ assert fwa.get_state() == wrench.Action.ActionState.READY, "FileWriteAction1 should be in the READY state" - assert fwa.get_file() == file1, "FileWriteAction1 doesn't have the correct file" assert fwa.get_file_location() == ss1, "FileWriteAction1 doesn't have the correct file location" assert not fwa.uses_scratch(), "FileWriteAction1 doesn't have the correct use of scratch" @@ -82,9 +81,10 @@ assert fra.get_state() == wrench.Action.ActionState.NOT_READY, "FileReadAction1 should be in the READY state" - assert fra.get_file() == file1, "FileReadAction1 doesn't have the correct file" assert fra.get_file_location() == ss1, "FileReadAction1 doesn't have the correct file location" + print(fra.get_num_bytes_to_read()) + print(file1.get_size()) assert fra.get_num_bytes_to_read() == file1.get_size(), "FileReadAction1 doesn't have the correct number of bytes" assert not fra.uses_scratch(), "FileReadAction1 doesn't have the correct use of scratch" diff --git a/wrench/cloud_compute_service.py b/wrench/cloud_compute_service.py index 850d18a..fb9257e 100644 --- a/wrench/cloud_compute_service.py +++ b/wrench/cloud_compute_service.py @@ -28,15 +28,15 @@ def __init__(self, simulation, name: str) -> None: """ super().__init__(simulation, name) - def create_vm(self, num_cores: int, ram_memory: float, property_list: dict[str, str], - message_payload_list: dict[str, float]) -> VirtualMachine: + def create_vm(self, num_cores: int, ram_memory: int, property_list: dict[str, str], + message_payload_list: dict[str, int]) -> VirtualMachine: """ Create a new virtual machine instance on the compute service :param num_cores: number of cores in the virtual machine :type num_cores: int :param ram_memory: RAM size in bytes - :type ram_memory: float + :type ram_memory: int :param property_list: a property list ({} means “use all defaults”) :type property_list: dict :param message_payload_list: a message payload list ({} means “use all defaults”) diff --git a/wrench/compound_job.py b/wrench/compound_job.py index f7d1566..a012116 100644 --- a/wrench/compound_job.py +++ b/wrench/compound_job.py @@ -53,7 +53,7 @@ def get_actions(self) -> List[Action]: """ return self.actions - def add_compute_action(self, name: str, flops: float, ram: float, + def add_compute_action(self, name: str, flops: float, ram: int, max_num_cores: int, min_num_cores: int, parallel_model: Tuple[str, float]) -> ComputeAction: """ Add a sleep action to the compound job @@ -63,7 +63,7 @@ def add_compute_action(self, name: str, flops: float, ram: float, :param flops: flops associated with this action :type flops: float :param ram: minimum amount of ram needed - :type ram: float + :type ram: int :param min_num_cores: minimum amount of cores this action needs :type min_num_cores: int :param max_num_cores: maximum amount of cores this action can use @@ -119,7 +119,7 @@ def add_file_write_action(self, name: str, file: File, storage_service: StorageS return self._simulation._add_file_write_action(self, name, file, storage_service) def add_file_read_action(self, name: str, file: File, storage_service: StorageService, - num_bytes_to_read=0.0) -> FileReadAction: + num_bytes_to_read: int = 0) -> FileReadAction: """ Add a file write action to the compound job @@ -130,7 +130,7 @@ def add_file_read_action(self, name: str, file: File, storage_service: StorageSe :param storage_service: storage service to write the file to :type storage_service: StorageService :param num_bytes_to_read: number of bytes to read in file - :type num_bytes_to_read: float + :type num_bytes_to_read: int """ return self._simulation._add_file_read_action(self, name, file, storage_service, num_bytes_to_read) diff --git a/wrench/compute_action.py b/wrench/compute_action.py index ae5512f..66bbd42 100644 --- a/wrench/compute_action.py +++ b/wrench/compute_action.py @@ -17,7 +17,7 @@ class ComputeAction(Action): WRENCH Action class """ - def __init__(self, simulation, compound_job: CompoundJob, name: str, flops: float, ram: float, min_num_cores: int, + def __init__(self, simulation, compound_job: CompoundJob, name: str, flops: float, ram: int, min_num_cores: int, max_num_cores: int, parallel_model: tuple) -> None: """ Constructor @@ -30,7 +30,7 @@ def __init__(self, simulation, compound_job: CompoundJob, name: str, flops: floa :param flops: amount of flops this action has :type flops: float :param ram: minimum amount of ram this action needs - :type ram: float + :type ram: int :param min_num_cores: minimum amount of cores this action needs :type min_num_cores: int :param max_num_cores: maximum amount of cores this action can use @@ -72,12 +72,12 @@ def get_min_num_cores(self) -> int: """ return self.min_num_cores - def get_min_ram_footprint(self) -> float: + def get_min_ram_footprint(self) -> int: """ Minimum amount of ram needed for this action :return: Minimum amount of ram needed - :rtype: float + :rtype: int """ return self.ram diff --git a/wrench/file_read_action.py b/wrench/file_read_action.py index 054622c..9832c47 100644 --- a/wrench/file_read_action.py +++ b/wrench/file_read_action.py @@ -18,7 +18,7 @@ class FileReadAction(Action): """ def __init__(self, simulation, compound_job: CompoundJob, name: str, file: File, storage_service: StorageService, - num_bytes_to_read: float, uses_scratch: bool) -> None: + num_bytes_to_read: int, uses_scratch: bool) -> None: """ Constructor :param simulation: simulation object @@ -32,7 +32,7 @@ def __init__(self, simulation, compound_job: CompoundJob, name: str, file: File, :param storage_service: storage service containing file :type storage_service: StorageService :param num_bytes_to_read: number of bytes to read - :type num_bytes_to_read: float + :type num_bytes_to_read: int :param uses_scratch: whether action uses scratch :type uses_scratch: bool """ @@ -61,11 +61,11 @@ def get_file_location(self) -> StorageService: """ return self.storage_service - def get_num_bytes_to_read(self) -> float: + def get_num_bytes_to_read(self) -> int: """ Get number of bytes to read from file - :return: amount of bytes being read - :rtype: float + :return: number of bytes being read + :rtype: int """ return self.num_bytes_to_read diff --git a/wrench/simulation.py b/wrench/simulation.py index 3183278..52f4e18 100644 --- a/wrench/simulation.py +++ b/wrench/simulation.py @@ -298,10 +298,10 @@ def get_simulated_time(self) -> float: return response["time"] def create_bare_metal_compute_service(self, hostname: str, - resources: dict[str, [int, float]], + resources: dict[str, [int, int]], scratch_space: str, property_list: dict[str, str], - message_payload_list: dict[str, float]) -> BareMetalComputeService: + message_payload_list: dict[str, int]) -> BareMetalComputeService: """ Create a bare metal compute service @@ -467,7 +467,7 @@ def get_all_hostnames(self) -> List[str]: def create_workflow_from_json(self, json_object: json, reference_flop_rate: str, ignore_machine_specs: bool, redundant_dependencies: bool, ignore_cycle_creating_dependencies: bool, - min_cores_per_task: float, max_cores_per_task: float, enforce_num_cores: 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 @@ -482,10 +482,10 @@ def create_workflow_from_json(self, json_object: json, reference_flop_rate: str, :type redundant_dependencies: bool :param ignore_cycle_creating_dependencies: whether to ignore cycles when creating task dependencies :type ignore_cycle_creating_dependencies: bool - :param min_cores_per_task: the minimum cores for a task if not specified in the JSON - :type min_cores_per_task: float - :param max_cores_per_task: the maximum cores for a task if not specified in the JSON - :type max_cores_per_task: float + :param min_cores_per_task: the minimum number of cores for a task if not specified in the JSON + :type min_cores_per_task: int + :param max_cores_per_task: the maximum number of cores for a task if not specified in the JSON + :type max_cores_per_task: int :param enforce_num_cores: whether to enforce the number of cores for a task even if specified in the JSON :type enforce_num_cores: bool :param ignore_avg_cpu: whether to ignore the average CPU time information in the JSON to compute @@ -808,14 +808,14 @@ def _task_get_max_num_cores(self, task: Task) -> int: return response["max_num_cores"] raise WRENCHException(response["failure_cause"]) - def _task_get_memory(self, task: Task) -> float: + def _task_get_memory(self, task: Task) -> int: """ - Get the task's memory requirement + Get the task's memory requirement in bytes :param task: the task :type task: Task :return: a memory footprint in bytes - :rtype: float + :rtype: int :raises WRENCHException: if there is any error in the response """ @@ -829,7 +829,7 @@ def _task_get_memory(self, task: Task) -> float: return response["memory"] raise WRENCHException(response["failure_cause"]) - def _task_get_number_of_children(self, task: Task) -> float: + def _task_get_number_of_children(self, task: Task) -> int: """ Get the task's number of children :param task: the task @@ -850,7 +850,7 @@ def _task_get_number_of_children(self, task: Task) -> float: return response["number_of_children"] raise WRENCHException(response["failure_cause"]) - def _task_get_bottom_level(self, task: Task) -> float: + def _task_get_bottom_level(self, task: Task) -> int: """ Get the task's bottom-level :param task: the task @@ -913,7 +913,7 @@ def _task_get_end_date(self, task: Task) -> float: return response["time"] raise WRENCHException(response["failure_cause"]) - def _add_compute_action(self, compound_job: CompoundJob, name: str, flops: float, ram: float, + def _add_compute_action(self, compound_job: CompoundJob, name: str, flops: float, ram: int, max_num_cores: int, min_num_cores: int, parallel_model: tuple) -> Action: """ Add a compute action @@ -924,8 +924,8 @@ def _add_compute_action(self, compound_job: CompoundJob, name: str, flops: float :type name: str :param flops: number of flops this action has :type flops: float - :param ram: amount of ram this action has - :type ram: float + :param ram: amount of ram this action has in bytes + :type ram: int :param max_num_cores: maximum number of cores this action can have :type max_num_cores: long :param min_num_cores: minimum number of cores this action can have @@ -1076,7 +1076,7 @@ def _add_file_write_action(self, compound_job: CompoundJob, name: str, file: Fil raise WRENCHException(response["failure_cause"]) def _add_file_read_action(self, compound_job: CompoundJob, name: str, file: File, storage_service: StorageService, - num_bytes_to_read: float) -> Action: + num_bytes_to_read: int) -> Action: """ Add a file read action :param compound_job: the action's compound job @@ -1088,7 +1088,7 @@ def _add_file_read_action(self, compound_job: CompoundJob, name: str, file: File :param storage_service: the storage service the file is stored in :type storage_service: StorageService :param num_bytes_to_read: the number of bytes to read from the file - :type num_bytes_to_read: float + :type num_bytes_to_read: int :return: the action name :rtype: Action @@ -1283,9 +1283,9 @@ def _add_parent_job(self, compound_job: CompoundJob, parent_compound_job: Compou def _create_vm(self, service: CloudComputeService, num_cores: int, - ram_memory: float, + ram_memory: int, property_list: dict[str, str], - message_payload_list: dict[str, float]) -> VirtualMachine: + message_payload_list: dict[str, int]) -> VirtualMachine: """ Create a VM instance :param service: the cloud compute service @@ -1293,7 +1293,7 @@ def _create_vm(self, :param num_cores: the number of cores for the VM :type num_cores: int :param ram_memory: the VM’s RAM memory_manager_service capacity - :type ram_memory: float + :type ram_memory: int :param property_list: a property list for the CloudComputeService that will run on the VM ({} means “use all defaults”) :type property_list: dict @@ -1522,7 +1522,7 @@ def _get_core_flop_rates(self, cs: ComputeService) -> Dict[str, float]: to_return[response["hostnames"][i]] = response["flop_rates"][i] return to_return - def _get_core_counts(self, cs: ComputeService) -> Dict[str, float]: + def _get_core_counts(self, cs: ComputeService) -> Dict[str, int]: """ Get the map of core counts, keyed by host name :param cs: the compute service @@ -1541,7 +1541,7 @@ def _get_core_counts(self, cs: ComputeService) -> Dict[str, float]: return to_return def _workflow_create_task(self, workflow: Workflow, name: str, flops: float, min_num_cores: int, max_num_cores: int, - memory: float) -> Task: + memory: int) -> Task: """ Add a task to the workflow :param workflow: the workflow @@ -1555,7 +1555,7 @@ def _workflow_create_task(self, workflow: Workflow, name: str, flops: float, min :param max_num_cores: maximum number of cores :type max_num_cores: int :param memory: memory requirement in bytes - :type memory: float + :type memory: int :return: A task object :rtype: Task diff --git a/wrench/task.py b/wrench/task.py index 234e466..7a59855 100644 --- a/wrench/task.py +++ b/wrench/task.py @@ -117,11 +117,11 @@ def get_max_num_cores(self) -> int: """ return self._simulation._task_get_max_num_cores(self) - def get_memory(self) -> float: + def get_memory(self) -> int: """ Get the task's memory requirement :return: A memory size in bytes - :rtype: float + :rtype: int """ return self._simulation._task_get_memory(self) diff --git a/wrench/workflow.py b/wrench/workflow.py index bb4c62e..563be07 100644 --- a/wrench/workflow.py +++ b/wrench/workflow.py @@ -38,7 +38,7 @@ def __init__(self, simulation: Simulation, name: str) -> None: self.tasks = {} super().__init__(simulation, name) - def add_task(self, name: str, flops: float, min_num_cores: int, max_num_cores: int, memory: float) -> Task: + def add_task(self, name: str, flops: float, min_num_cores: int, max_num_cores: int, memory: int) -> Task: """ Add a task to the workflow @@ -51,7 +51,7 @@ def add_task(self, name: str, flops: float, min_num_cores: int, max_num_cores: i :param max_num_cores: maximum number of cores :type max_num_cores: int :param memory: memory requirement in bytes - :type memory: float + :type memory: int :return: A task object :rtype: Task