Globus Compute Executor

Overview || Base Executor || MPI Executor || Globus Compute Executor

The GlobusComputeExecutor submits Python callables to a remote Globus Compute endpoint instead of launching local subprocesses. It can be used inside simulator functions in the same way as the MPI Executor, retrieving it from libE_info["executor"].

See Globus Compute - Remote User Functions for an overview of the two GC integration modes (manager-side GC-only and user-facing executor).

Note

globus-compute-sdk must be installed to use this executor:

pip install globus-compute-sdk

Users must also authenticate via Globus and have an active Globus Compute endpoint running on the target system.

GlobusComputeExecutor

class libensemble.executors.globus_compute_executor.GlobusComputeExecutor(endpoint_id)

Bases: Executor

An Executor that submits Python callables to Globus Compute instead of launching local subprocesses.

Usage in a top-level script:

from libensemble.executors.globus_compute_executor import GlobusComputeExecutor

exctr = GlobusComputeExecutor(endpoint_id="...")

Inside a simulator function:

task = info["executor"].submit(func=my_remote_func, app_args=...)
while not task.finished:
    task.poll()
    if info["executor"].manager_kill_received():
        task.kill()
        break
    time.sleep(0.1)
Parameters:

endpoint_id (str)

__init__(endpoint_id)

Instantiate a new Executor instance.

Returns:

A new Executor object is created. This is typically created in the user calling script.

Return type:

Executor

Parameters:

endpoint_id (str)

register_app(full_path, app_name=None, calc_type=None, desc=None, precedent='', pyobj=None)

Register an application.

If pyobj is provided the application is treated as a remote Python callable. Otherwise the base-class behaviour applies (local executable).

Parameters:
  • full_path (str)

  • app_name (str | None)

  • calc_type (str | None)

  • desc (str | None)

  • precedent (str)

  • pyobj (Any | None)

Return type:

None

submit(calc_type=None, app_name=None, app_args=None, func=None, stdout=None, stderr=None, dry_run=False, wait_on_start=False, **kwargs)

Submit a function or registered application to Globus Compute.

Parameters:
  • calc_type (str, optional) – Calculation type ("sim" or "gen"). Used with app_name.

  • app_name (str, optional) – Name of a previously registered application.

  • app_args (str, optional) – Arguments passed alongside the function.

  • func (Callable, optional) – A Python callable to execute remotely. Takes precedence over app_name / calc_type.

  • stdout (str, optional) – Ignored (stubs for API compatibility).

  • stderr (str, optional) – Ignored (stubs for API compatibility).

  • dry_run (bool, optional) – If True, return a task without actually submitting.

  • wait_on_start (bool, optional) – If True, block until the task is reported as started.

Return type:

GlobusComputeTask

set_workerID(workerid)

Sets the worker ID for this executor.

Return type:

None

set_worker_info(comm=None, workerid=None)

Sets worker info for this executor.

Return type:

None

GlobusComputeTask

Tasks are created and returned by GlobusComputeExecutor.submit(). Each task wraps a concurrent.futures.Future from the Globus Compute SDK and exposes the same polling interface as other libEnsemble tasks.

class libensemble.executors.globus_compute_executor.GlobusComputeTask(future, app=None, app_args=None, workerid=None)

A Task wrapping a concurrent.futures.Future returned by Globus Compute.

Instead of managing a local subprocess, this task polls a remote computation via the future’s done() / result() APIs.

poll()

Polls and updates the status attributes of the task

wait(timeout=None)

Waits on completion of the task or raises TimeoutExpired exception

Status attributes of task are updated on completion.

Parameters:

timeout (int or float, Optional) – Time in seconds after which a TimeoutExpired exception is raised. If not set, then simply waits until completion. Note that the task is not automatically killed on timeout.

kill(wait_time=None)

Kills or cancels the supplied task

Parameters:

wait_time (int, Optional) – Time in seconds to wait for termination between sending SIGTERM and a SIGKILL signals.

Sends SIGTERM, waits for a period of <wait_time> for graceful termination, then sends a hard kill with SIGKILL. If <wait_time> is 0, we go immediately to SIGKILL; if <wait_time> is none, we never do a SIGKILL.

result(timeout=None)

Wrapper for task.wait() that also returns the task’s status on completion.

Parameters:

timeout (int or float, Optional) – Time in seconds after which a TimeoutExpired exception is raised. If not set, then simply waits until completion. Note that the task is not automatically killed on timeout.

running()

Return True if task is currently running.

done()

Return True if task is finished.

cancelled()

Return `True if task successfully cancelled.

Task states: RUNNING | FINISHED | FAILED | USER_KILLED

Key attributes:

task.state:

(string) Current task state - one of the values above.

task.finished:

(bool) True once the task has completed (successfully or not).

task.success:

(bool) True if the remote callable returned without raising.

task.runtime:

(float) Elapsed wall-clock seconds since submission.

task.submit_time:

(float) Time since epoch at submission.