Skip to content

Commit

Permalink
Removing floats
Browse files Browse the repository at this point in the history
  • Loading branch information
henricasanova committed Oct 22, 2024
1 parent 60d40ff commit e1dd6fa
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 45 deletions.
4 changes: 2 additions & 2 deletions tests/compound_job_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"

Expand Down
6 changes: 3 additions & 3 deletions wrench/cloud_compute_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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”)
Expand Down
8 changes: 4 additions & 4 deletions wrench/compound_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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)

Expand Down
8 changes: 4 additions & 4 deletions wrench/compute_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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

Expand Down
10 changes: 5 additions & 5 deletions wrench/file_read_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
"""
Expand Down Expand Up @@ -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

Expand Down
46 changes: 23 additions & 23 deletions wrench/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
"""
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -1283,17 +1283,17 @@ 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
:type service: CloudComputeService
: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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions wrench/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions wrench/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit e1dd6fa

Please sign in to comment.