Skip to content

Commit 35c8d3b

Browse files
committed
Introduce two env vars for UEP customization
- `GC_USER_PYTHON_VERSION` - `GC_USER_SDK_VERSION` If the information is available in the `user_runtime` data structure, also export these two environment variables. These two bits of information have proven critical to helping administrators customize UEP installs. In particular, the latter (SDK) variable is necessary to get Parsl versions to match up on the interchange and workers. (An unfortunate detail that we must accommodate until Parsl implements a less-strict communication policy.) Setting these environment variables means that administrators don't have to go through an awkward set of steps to read stdin, parse the input, and rewrite the stdin just to get this information from the template. [sc-41149]
1 parent 826f6c6 commit 35c8d3b

File tree

4 files changed

+48
-3
lines changed

4 files changed

+48
-3
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
New Functionality
2+
^^^^^^^^^^^^^^^^^
3+
4+
- To aid potential UEP instance customization, export
5+
``GC_USER_PYTHON_VERSION`` and ``GC_USER_SDK_VERSION`` (if available from the
6+
:ref:`user_runtime <reserved-template-variables>` structure)

compute_endpoint/globus_compute_endpoint/endpoint/endpoint_manager.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,6 +1175,12 @@ def cmd_start_endpoint(
11751175
user_opts,
11761176
user_runtime,
11771177
)
1178+
1179+
if py_version := user_runtime.get("python", {}).get("version"):
1180+
env.setdefault("GC_USER_PYTHON_VERSION", py_version)
1181+
if gce_version := user_runtime.get("globus_compute_sdk_version"):
1182+
env.setdefault("GC_USER_SDK_VERSION", gce_version)
1183+
11781184
exit_code += 1
11791185
_conf = yaml.safe_load(user_config)
11801186

compute_endpoint/tests/unit/test_endpointmanager_unit.py

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,12 @@ def command_payload(ident):
338338
"name": "some_ep_name",
339339
"user_opts": {"heartbeat": 10},
340340
"amqp_creds": {},
341+
"user_runtime": {
342+
"python": {
343+
"version": "3.4.2",
344+
},
345+
"globus_compute_sdk_version": "2.90.2",
346+
},
341347
},
342348
}
343349

@@ -578,7 +584,7 @@ def test_records_user_ep_as_running(successful_exec_from_mocked_root):
578584

579585

580586
def test_caches_start_cmd_args_if_ep_already_running(
581-
successful_exec_from_mocked_root, mocker
587+
mocker, successful_exec_from_mocked_root, command_payload
582588
):
583589
*_, em = successful_exec_from_mocked_root
584590
child_pid = random.randrange(1, 32768 + 1)
@@ -592,10 +598,9 @@ def test_caches_start_cmd_args_if_ep_already_running(
592598
cached_args = em._cached_cmd_start_args.pop(child_pid)
593599
assert cached_args is not None
594600
mpi, args, kwargs = cached_args
595-
exp_kw = {"name": "some_ep_name", "user_opts": {"heartbeat": 10}, "amqp_creds": {}}
596601
assert mpi.local_user_record == _mock_localuser_rec
597602
assert args == []
598-
assert kwargs == exp_kw
603+
assert kwargs == command_payload["kwargs"]
599604

600605

601606
def test_writes_endpoint_uuid(epmanager_as_root):
@@ -1688,6 +1693,22 @@ def test_environment_default_path_set_if_not_specified(
16881693
assert "PATH" in env, "Expected PATH is always set"
16891694

16901695

1696+
def test_environment_includes_user_versions(
1697+
command_payload, successful_exec_from_mocked_root
1698+
):
1699+
mock_os, conf_dir, *_, em = successful_exec_from_mocked_root
1700+
1701+
urun = command_payload["kwargs"]["user_runtime"]
1702+
with pytest.raises(SystemExit) as pyexc:
1703+
em._event_loop()
1704+
1705+
assert pyexc.value.code == _GOOD_EC, "Q&D: verify we exec'ed, based on '+= 1'"
1706+
_, k = mock_os.execvpe.call_args
1707+
env = k["env"]
1708+
assert urun["python"]["version"] == env["GC_USER_PYTHON_VERSION"]
1709+
assert urun["globus_compute_sdk_version"] == env["GC_USER_SDK_VERSION"]
1710+
1711+
16911712
def test_warns_if_executable_not_found(
16921713
mock_log, successful_exec_from_mocked_root, randomstring
16931714
):

docs/endpoints/endpoints.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,18 @@ and writing a custom ``globus-compute-endpoint`` wrapper:
715715
716716
(The use of ``exec`` is not critical, but keeps the process tree tidy.)
717717

718+
The manager endpoint process exports the following two environment variables that
719+
shim‑authors may use to fine‑tune customizations:
720+
721+
- ``GC_USER_PYTHON_VERSION`` - A dotted-decimal Python version (e.g., ``3.13.7``) that
722+
specifies which version of Python was used to submit tasks to this endpoint
723+
724+
- ``GC_USER_SDK_VERSION`` - A dotted-decimal ``globus-compute-sdk`` version (e.g.,
725+
``4.8.0``) that specifies what version of the `Globus Compute SDK`_ the submission
726+
used
727+
728+
.. _Globus Compute SDK: https://pypi.org/project/globus-compute-sdk/
729+
718730

719731
Debugging
720732
=========

0 commit comments

Comments
 (0)