Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
cms21 committed Oct 11, 2023
1 parent bf473a6 commit d13884b
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
4 changes: 4 additions & 0 deletions workflows/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Workflow Tools at ALCF
===============================================

This tutorial provides examples of using the workflow tools [Parsl](https://parsl.readthedocs.io/en/stable/), [Globus Compute](https://www.globus.org/compute), and [Balsam](https://balsam.readthedocs.io/en/latest/) on Polaris.
4 changes: 3 additions & 1 deletion workflows/globus_compute/0_remote_adder.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
# Scripts adapted from Globus Compute docs
# https://globus-compute.readthedocs.io/en/latest/quickstart.html


# First, define the function ...
def add_func(a, b):
return a + b


# Paste your endpoint id here, e.g.
# endpoint_id = 'c0396551-2870-45f2-a2aa-70991eb120a4'
endpoint_id = ''
Expand All @@ -19,4 +21,4 @@ def add_func(a, b):
future = gce.submit(add_func, 5, 10)

# ... and finally, wait for the result
print(future.result())
print(future.result())
15 changes: 9 additions & 6 deletions workflows/globus_compute/1_register_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,27 @@

# This script is intended to be run from your remote machine


# Define a function that calls executable on Polaris
def hello_affinity(run_directory):
import subprocess, os
import subprocess
import os

# This will create a run directory for the application to execute
os.makedirs(os.path.expandvars(run_directory), exist_ok=True)
os.chdir(os.path.expandvars(run_directory))

# This is the command that calls the compiled executable
command = f"/eagle/fallwkshp23/workflows/affinity_gpu/hello_affinity"
command = "/eagle/fallwkshp23/workflows/affinity_gpu/hello_affinity"

# This runs the application command
res = subprocess.run(command.split(" "), stdout=subprocess.PIPE, stderr=subprocess.PIPE)

# Write stdout and stderr to files on Polaris filesystem
with open("hello.stdout","w") as f:
with open("hello.stdout", "w") as f:
f.write(res.stdout.decode("utf-8"))
with open("hello.stderr","w") as f:

with open("hello.stderr", "w") as f:
f.write(res.stderr.decode("utf-8"))

# This does some error handling for safety, in case your application fails.
Expand All @@ -29,7 +31,8 @@ def hello_affinity(run_directory):
raise Exception(f"Application failed with non-zero return code: {res.returncode} stdout='{res.stdout.decode('utf-8')}' stderr='{res.stderr.decode('utf-8')}'")
else:
return res.returncode, res.stdout.decode("utf-8"), res.stderr.decode("utf-8")



gc = globus_compute_sdk.Client()
fusion_func = gc.register_function(hello_affinity)
print(f"Registered hello_affinity; id {fusion_func}")
2 changes: 1 addition & 1 deletion workflows/globus_compute/2_call_registered_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@
# Print task execution details
gcc = Client()
for t in tasks:
print(gcc.get_task(t.task_id),"\n")
print(gcc.get_task(t.task_id),"\n")

0 comments on commit d13884b

Please sign in to comment.