Skip to content

Commit

Permalink
Improved Python API and its Implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
henricasanova committed Jan 19, 2024
1 parent adff927 commit c70df48
Show file tree
Hide file tree
Showing 20 changed files with 2,741 additions and 227 deletions.
2 changes: 1 addition & 1 deletion example/simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
file2 = simulation.add_file("file2", 1024)
print(f"Created file {file2}")

print("Creating a copy of the file on the storage service")
print(f"Creating a copy of {file1} on the storage service")
ss.create_file_copy(file1)

print("Sleeping for 10 seconds...")
Expand Down
22 changes: 11 additions & 11 deletions tests/bare_metal_compute_service_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,20 @@
print("Creating a 2-task chain workflow as a single job, which will fail due to missing file locations...")
workflow = simulation.create_workflow()

file1 = simulation.add_file(workflow, "file1", 1024)
file1 = simulation.add_file("file1", 1024)
ss.create_file_copy(file1)
file2 = simulation.add_file(workflow, "file2", 1024)
file3 = simulation.add_file(workflow, "file3", 1024)
file2 = simulation.add_file("file2", 1024)
file3 = simulation.add_file("file3", 1024)

task1 = workflow.add_task(workflow, "task1", 10000000000, 1, 1, 0)
task1.add_input_file(workflow, file1)
task1.add_output_file(workflow, file2)
task2 = workflow.add_task(workflow, "task2", 200000000000, 1, 1, 0)
task2.add_input_file(workflow, file2)
task2.add_output_file(workflow, file3)
task1 = workflow.add_task("task1", 10000000000, 1, 1, 0)
task1.add_input_file(file1)
task1.add_output_file(file2)
task2 = workflow.add_task("task2", 200000000000, 1, 1, 0)
task2.add_input_file(file2)
task2.add_output_file(file3)

print("Creating a standard job with both tasks, but that doesn't specify file locations")
job = simulation.create_standard_job(workflow, [task1, task2], {})
job = simulation.create_standard_job([task1, task2], {})

print("Submitting the standard job to the compute service...")
cs.submit_standard_job(job)
Expand All @@ -78,7 +78,7 @@
raise wrench.WRENCHException("Was expecting a job failure event but instead got a: " + event["event_type"])

print("Trying again, but giving file locations for first and last file (second file will be on scratch!)...")
job = simulation.create_standard_job(workflow, [task1, task2], {file1: ss, file3: ss})
job = simulation.create_standard_job([task1, task2], {file1: ss, file3: ss})
cs.submit_standard_job(job)
print("Getting simulation events...")
event = simulation.wait_for_next_event()
Expand Down
22 changes: 11 additions & 11 deletions tests/batch_compute_service_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,20 @@

workflow = simulation.create_workflow()
print("Creating a 2-task chain workflow as a single job, which will fail due to missing file locations...")
file1 = simulation.add_file(workflow, "file1", 1024)
file1 = simulation.add_file("file1", 1024)
ss.create_file_copy(file1)
file2 = simulation.add_file(workflow, "file2", 1024)
file3 = simulation.add_file(workflow, "file3", 1024)
file2 = simulation.add_file("file2", 1024)
file3 = simulation.add_file("file3", 1024)

task1 = workflow.add_task(workflow, "task1", 10000000000, 1, 1, 0)
task1.add_input_file(workflow, file1)
task1.add_output_file(workflow, file2)
task2 = workflow.add_task(workflow, "task2", 200000000000, 1, 1, 0)
task2.add_input_file(workflow, file2)
task2.add_output_file(workflow, file3)
task1 = workflow.add_task("task1", 10000000000, 1, 1, 0)
task1.add_input_file(file1)
task1.add_output_file(file2)
task2 = workflow.add_task("task2", 200000000000, 1, 1, 0)
task2.add_input_file(file2)
task2.add_output_file(file3)

print("Creating a standard job with both tasks, but that doesn't specify file locations")
job = simulation.create_standard_job(workflow, [task1, task2], {})
job = simulation.create_standard_job([task1, task2], {})

print("Random select args for job")
host = random.randint(1,2)
Expand All @@ -83,7 +83,7 @@
raise wrench.WRENCHException("Was expecting a job failure event but instead got a: " + event["event_type"])

print("Trying again, but giving file locations for first and last file (second file will be on scratch!)...")
job = simulation.create_standard_job(workflow, [task1, task2], {file1: ss, file3: ss})
job = simulation.create_standard_job([task1, task2], {file1: ss, file3: ss})
cs.submit_standard_job(job, service_specific_args)
print("Getting simulation events...")
event = simulation.wait_for_next_event()
Expand Down
8 changes: 4 additions & 4 deletions tests/cloud_compute_service_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@
print(f"Submitting a job do the VM's bare metal compute service")
workflow = simulation.create_workflow()
print(f"Created {workflow.name}")
task1 = workflow.add_task(workflow, "task1", 10000000000.0, 1, 1, 0)
job = simulation.create_standard_job(workflow, [task1], {})
task1 = workflow.add_task("task1", 10000000000.0, 1, 1, 0)
job = simulation.create_standard_job([task1], {})
vm_cs.submit_standard_job(job)
print(f"Simulation, time is {simulation.get_simulated_time()}")
print(f"Waiting for job completion...")
Expand All @@ -110,8 +110,8 @@
raise wrench.WRENCHException("VM should be running")

print(f"Submitting another job do the VM's bare metal compute service")
task2 = workflow.add_task(workflow, "task2", 10000000000.0, 1, 1, 0)
job = simulation.create_standard_job(workflow, [task2], {})
task2 = workflow.add_task("task2", 10000000000.0, 1, 1, 0)
job = simulation.create_standard_job([task2], {})
vm_cs.submit_standard_job(job)
print(f"Simulation, time is {simulation.get_simulated_time()}")
print(f"Waiting for job completion...")
Expand Down
Loading

0 comments on commit c70df48

Please sign in to comment.