Skip to content

Commit

Permalink
Make Executor.endpoint_id a property
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-janidlo committed Jan 22, 2024
1 parent 0ed4a5e commit 6c9b459
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions compute_sdk/globus_compute_sdk/sdk/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,47 @@ def __repr__(self) -> str:
bs = f"bs:{self.batch_size}"
return f"{name}<{label}{ep_id}{c_id}{tg_id}{bs}>"

@property
def endpoint_id(self):
"""
The ID of the endpoint currently associated with this instance. This
determines where tasks are sent for execution, and since tasks have to go
somewhere, the Executor will not run unless it has an endpoint_id set.
Must be a UUID, valid uuid-like string, or None. Set by simple assignment::
>>> import uuid
>>> from globus_compute_sdk import Executor
>>> ep_id = uuid.uuid4() # IRL: some *known* endpoint id
>>> gce = Executor(endpoint_id=ep_id)
# Alternatively, may use a stringified uuid:
>>> gce = Executor(endpoint_id=str(ep_id))
# May also alter after construction:
>>> gce.endpoint_id = ep_id
>>> gce.endpoint_id = str(ep_id)
# Internally, it is always stored as a UUID (or None):
>>> gce.endpoint_id
UUID('11111111-2222-4444-8888-000000000000')
# Executors only run if they have an endpoint_id set:
>>> gce = Executor(endpoint_id=None)
Traceback (most recent call last):
...
ValueError: No endpoint_id set. Did you forget to set it at construction?
Hint:
gce = Executor(endpoint_id=<ep_id>)
gce.endpoint_id = <ep_id> # alternative
"""
return self._endpoint_id

@endpoint_id.setter
def endpoint_id(self, endpoint_id: UUID_LIKE_T | None):
self._endpoint_id = as_optional_uuid(endpoint_id)

@property
def task_group_id(self):
"""
Expand Down

0 comments on commit 6c9b459

Please sign in to comment.