From d13884b0f869c0a328ac443df893fce830597c83 Mon Sep 17 00:00:00 2001 From: Christine Simpson Date: Wed, 11 Oct 2023 11:01:57 -0500 Subject: [PATCH] updates --- workflows/README.md | 4 ++++ workflows/globus_compute/0_remote_adder.py | 4 +++- workflows/globus_compute/1_register_function.py | 15 +++++++++------ .../globus_compute/2_call_registered_function.py | 2 +- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/workflows/README.md b/workflows/README.md index e69de29..169384e 100644 --- a/workflows/README.md +++ b/workflows/README.md @@ -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. \ No newline at end of file diff --git a/workflows/globus_compute/0_remote_adder.py b/workflows/globus_compute/0_remote_adder.py index 572c6a5..774de47 100644 --- a/workflows/globus_compute/0_remote_adder.py +++ b/workflows/globus_compute/0_remote_adder.py @@ -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 = '' @@ -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()) \ No newline at end of file + print(future.result()) diff --git a/workflows/globus_compute/1_register_function.py b/workflows/globus_compute/1_register_function.py index bb105a8..445c70d 100644 --- a/workflows/globus_compute/1_register_function.py +++ b/workflows/globus_compute/1_register_function.py @@ -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. @@ -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}") diff --git a/workflows/globus_compute/2_call_registered_function.py b/workflows/globus_compute/2_call_registered_function.py index d6fa7d0..1236236 100644 --- a/workflows/globus_compute/2_call_registered_function.py +++ b/workflows/globus_compute/2_call_registered_function.py @@ -31,4 +31,4 @@ # Print task execution details gcc = Client() for t in tasks: - print(gcc.get_task(t.task_id),"\n") \ No newline at end of file + print(gcc.get_task(t.task_id),"\n")