Skip to content

Removed unusable log options and add new section to user_config_template#2121

Open
LeiGlobus wants to merge 2 commits into
mainfrom
lei/add-log-config-sc-39546
Open

Removed unusable log options and add new section to user_config_template#2121
LeiGlobus wants to merge 2 commits into
mainfrom
lei/add-log-config-sc-39546

Conversation

@LeiGlobus

Copy link
Copy Markdown
Contributor

Description

Removed several log related options that do not work, and added a new log section where one can specify the user log path.

This new log path is passed as an environment variable to the UEP called GLOBUS_COMPUTE_LOG_PATH though it's debatable whether we want to use direct parameters fed via stdin instead which then in turn sets the env var in the UEP.

Need to move a few fixtures around as they are shared by new test.

Also wrapped cli.py so Exceptions are printed instead of being swallowed by Click and merely printing the --help message.

(TBD adding another test will remove this sentence after addition)

[sc-39546]

Type of change

  • New feature (non-breaking change that adds functionality)
  • Documentation update
  • Code maintenance/cleanup

Comment thread changelog.d/20260511_105026_lei_add_log_config_sc_39546.rst Outdated
Comment thread changelog.d/20260511_105026_lei_add_log_config_sc_39546.rst
Comment thread compute_endpoint/globus_compute_endpoint/endpoint/config/config.py Outdated
Comment thread compute_endpoint/globus_compute_endpoint/endpoint/config/config.py Outdated
Comment thread compute_endpoint/globus_compute_endpoint/endpoint/config/config.py Outdated
Comment thread compute_endpoint/globus_compute_endpoint/logging_config.py Outdated
Comment thread compute_endpoint/globus_compute_endpoint/logging_config.py Outdated
Comment thread compute_endpoint/globus_compute_endpoint/logging_config.py Outdated
Comment thread compute_endpoint/globus_compute_endpoint/logging_config.py Outdated
Comment thread compute_endpoint/globus_compute_endpoint/logging_config.py Outdated
@LeiGlobus LeiGlobus force-pushed the lei/add-log-config-sc-39546 branch 2 times, most recently from f090783 to f5abd40 Compare May 28, 2026 17:25
@LeiGlobus LeiGlobus force-pushed the lei/add-log-config-sc-39546 branch 10 times, most recently from 29d8e15 to 88f7836 Compare June 15, 2026 18:56
@LeiGlobus LeiGlobus force-pushed the lei/add-log-config-sc-39546 branch from 88f7836 to 031197d Compare June 16, 2026 22:50
@LeiGlobus LeiGlobus requested a review from khk-globus June 16, 2026 22:54

@chris-janidlo chris-janidlo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven't tested this yet, but looks good overall. Mostly small comments except for maybe some missing tests

Comment thread compute_endpoint/globus_compute_endpoint/endpoint/config/model.py Outdated
Comment thread changelog.d/20260511_105026_lei_add_log_config_sc_39546.rst Outdated
Comment thread changelog.d/20260511_105026_lei_add_log_config_sc_39546.rst Outdated
Comment thread compute_endpoint/tests/unit/test_endpoint_unit.py Outdated
Comment thread docs/endpoints/config_reference.rst Outdated
Comment on lines +1204 to +1211
if path_info := _conf.get("paths"):
if log_path_val := path_info.get("endpoint_log"):
env["GLOBUS_COMPUTE_LOG_PATH"] = log_path_val
ep_log = ensure_log_path(None)
log.info(f"Setting custom endpoint log path to {ep_log}")
if gc_dir_val := path_info.get("gc_dir"):
log.info(f"Setting Compute base path to {gc_dir_val}")
env["GLOBUS_COMPUTE_USER_DIR"] = gc_dir_val

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there any tests verifying this new endpoint_manager behavior?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No tests for this yet, but the logic is fairly simple, and any errors will be fairly obvious (e.g. the UEP will ignore the config altogether). I'll look into whether it can be added to an existing test.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logic/errors aside, if these env vars are a contractual invariant we want the CEP to always set---and we do, because of the fact that UEPs always expect them---we should have a test that verifies it actually happens.

Comment thread compute_endpoint/globus_compute_endpoint/endpoint/endpoint_manager.py Outdated
Comment thread compute_endpoint/tests/unit/test_endpoint_config.py Outdated
@LeiGlobus LeiGlobus requested a review from chris-janidlo June 24, 2026 20:00
@LeiGlobus LeiGlobus force-pushed the lei/add-log-config-sc-39546 branch 6 times, most recently from 0a29789 to 7777ad1 Compare June 25, 2026 18:14
Comment thread changelog.d/20260511_105026_lei_add_log_config_sc_39546.rst Outdated
Comment thread changelog.d/20260511_105026_lei_add_log_config_sc_39546.rst Outdated
Comment thread changelog.d/20260511_105026_lei_add_log_config_sc_39546.rst Outdated
Comment on lines +1206 to +1207
env["GLOBUS_COMPUTE_LOG_PATH"] = log_path_val
ep_log = ensure_log_path(None)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • It is a subtle detail here to rely on the environment variable for the next function call. It's not wrong, just unexpected in the usual course, especially in context of the other branch, which sets its environment variable at the end of the block. A simple comment (inline, if feasible) might help.
  • I also observe that GLOBUS_COMPUTE_LOG_PATH is used in variable form within ensure_log_path. For single-point-of-authority, this should do similar.
  • You may or may not like a stylistic choice to unindent a block, but I offer it as an option:
    if gc_dir_val := _conf.get("paths", {}).get("gc_dir"):
        ...
    ...
    if log_path_val := _conf.get("paths", {}).get("endpoint_log"):
        ...

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the common case where endpoint_log is not specified, this represents a slight Shlemiel approach; consider ensure_log_path() to after ensure_compute_dir() has been invoked.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rewrote the order in this section to make it flow better with the dependency necessary

Comment on lines +285 to +293
log_dir = os.environ.get(LOG_PATH_ENV)
if log_dir and log_dir.strip():
# This expands both ~/... and $X e.g. ~/$MY_SUB_DIR/abc.log
log_path = pathlib.Path(os.path.expandvars(log_dir)).expanduser()
if log_path.is_dir():
raise ValueError(f"{LOG_PATH_ENV} can not be a directory: {log_path}")
else:
assert ep_dir, "ep_dir must be provided if LOG_PATH_ENV is not set"
log_path = ep_dir / "endpoint.log"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • In the first branch, log_path is basically just the pathlib-ization of log_dir. That's unexpected, then, in line 289 that requires that log_path be not a directory.
  • A simplification of the if-conditional might be:
    if log_dir := os.environ.get(LOG_PATH_ENV, "").strip():
  • I find it unexpected that one branch relies on an environment variable while the other does not. Consider making this function take no arguments and only rely on environment variables. (Especially since we're nominally always setting GLOBUS_COMPUTE_USER_DIR now, yeah?)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs a bit more discussion offline.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rewritten

Comment thread compute_endpoint/globus_compute_endpoint/endpoint/endpoint_manager.py Outdated
Comment thread compute_endpoint/tests/unit/test_endpoint_config.py Outdated
Comment thread docs/endpoints/config_reference.rst
@LeiGlobus LeiGlobus force-pushed the lei/add-log-config-sc-39546 branch 4 times, most recently from cd0f685 to 20be140 Compare July 6, 2026 18:14
@LeiGlobus LeiGlobus force-pushed the lei/add-log-config-sc-39546 branch 7 times, most recently from 18c141d to c1eec28 Compare July 9, 2026 07:46
Comment thread compute_endpoint/globus_compute_endpoint/logging_config.py Outdated

# Use the environment value set from default or customized log path
ep_log = ensure_log_path()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given recent iterations, GLOBUS_COMPUTE_USER_DIR is no longer modifiable from the configuration. Thus, this section could be simplified with an else: branch. Consider:

if log_path_val := _conf.get("paths", {}).get("endpoint_log"):
    # Overrides the default in ensure_log_path()
    env[LOG_PATH_ENV] = log_path_val

if ep_dir_val := _conf.get("paths", {}).get("endpoint_dir"):
    log.info(f"Setting endpoint directory to {ep_dir_val}")
    ep_dir = pathlib.Path(ep_dir_val)
else:
    ep_dir = ensure_compute_dir() / ep_name

ep_dir.mkdir(mode=0o700, parents=True, exist_ok=True)
env[COMPUTE_EP_DIR_ENV] = str(ep_dir.resolve())

ep_log = ensure_log_path()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that ensure_log_path could change the value given to it by the environment variable (c.f., expandvars() and expanduser()), we should similarly update the environment variable.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated, but needs some discussion as to where the updating should be done.

Comment on lines +290 to +297
log_dir = os.environ.get(LOG_PATH_ENV, "").strip()
ep_dir = os.environ.get(COMPUTE_EP_DIR_ENV, "").strip()
if log_dir:
# This expands both ~/... and $X e.g. ~/$MY_SUB_DIR/abc.log
log_path = pathlib.Path(os.path.expandvars(log_dir)).expanduser()
if log_path.is_dir():
raise ValueError(f"{LOG_PATH_ENV} can not be a directory: {log_path}")
logger.info(f"Setting custom endpoint log path to {log_path}")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please address the incongruence of log_dir.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Same comment as made in previous review iteration.)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rewrote and simplified the logic

Comment thread compute_endpoint/tests/unit/conftest.py Outdated
Comment thread compute_endpoint/tests/unit/test_config_utils.py
Comment thread docs/endpoints/config_reference.rst Outdated
Comment thread docs/endpoints/config_reference.rst Outdated
Comment thread docs/endpoints/templates.rst Outdated
Comment thread docs/endpoints/templates.rst Outdated
Comment thread docs/endpoints/templates.rst Outdated
@LeiGlobus LeiGlobus force-pushed the lei/add-log-config-sc-39546 branch 5 times, most recently from b153118 to f70c28d Compare July 14, 2026 20:50
@LeiGlobus LeiGlobus force-pushed the lei/add-log-config-sc-39546 branch from f70c28d to a13d358 Compare July 15, 2026 19:59
@LeiGlobus LeiGlobus force-pushed the lei/add-log-config-sc-39546 branch from a13d358 to a345b15 Compare July 15, 2026 20:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants