Skip to content

fix(logging): stop configuring the root logger on import - #4748

Merged
cmunley1 merged 1 commit into
mainfrom
iguehring/no-root-logging-on-import
Oct 19, 2026
Merged

cmunley1 merged 1 commit into
mainfrom
iguehring/no-root-logging-on-import

Conversation

@iguehring-nvidia

@iguehring-nvidia iguehring-nvidia commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Stops import nemo_gym from configuring the root logger, so applications that import Gym keep control of their own logging.

nemo_gym/__init__.py calls logging.debug(...) at import time (_augment_sys_path). The module-level logging.debug / logging.warning helpers log to the root logger, and when the root logger has no handlers yet they call logging.basicConfig() first. Importing nemo_gym therefore attaches a stderr handler to the root logger, which stays at its default WARNING level. Since logging.basicConfig() does nothing once the root logger has a handler, an application that imports nemo_gym and then calls logging.basicConfig(level=logging.INFO, ...) silently keeps WARNING: all of its own INFO logs are dropped, with no error.

import logging, nemo_gym
logging.basicConfig(level=logging.INFO)
logging.getLogger("app").info("started")  # main: not printed

This PR logs through module loggers instead:

  • nemo_gym/__init__.py: the sys.path debug message.
  • nemo_gym/global_config.py: the openai version skew warning, which used the root logger although the module already has logger.

Gym's own output does not change: the debug message stays hidden by default, and the warning still reaches stderr through logging.lastResort when nothing is configured.

Validation

  • The example above, against the current code and with this change: on main the INFO line is dropped; with this change it prints INFO:app:started.
  • pytest tests/unit_tests (8,581 passed): the same 36 tests fail with and without this change, all in areas unrelated to logging (sandbox provider, launcher and optional-dependency tests that fail in my local environment).
  • An application that imports nemo_gym, plans a benchmark and runs a task in-process, then configures logging at INFO: its INFO logs now appear; the task result is unchanged.
  • Standalone CLI, with and without this change: gym eval prepare and gym eval run --benchmark ifeval --model-type openai_model --split benchmark --limit 2 against an OpenAI-compatible endpoint. Both exit 0 with 2 rollouts, and the console output has the same 323 lines; the only differences are process ids, timings, the order of interleaved server lines, and the sampled model answers.
  • pre-commit run on the changed files: passed.

@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Importing nemo_gym called logging.debug() on the root logger. With no
handlers configured yet, that call runs logging.basicConfig() implicitly
and attaches a stderr handler at WARNING level. Any later
logging.basicConfig() in the importing application then does nothing, so
its INFO logs are silently dropped.

Log through module loggers instead, in nemo_gym/__init__.py and in the
openai version skew warning in global_config.py.

Signed-off-by: Ingo Guehring <[email protected]>
@iguehring-nvidia

Copy link
Copy Markdown
Contributor Author

/review

@iguehring-nvidia iguehring-nvidia added bug Something isn't working area:core Shared APIs, servers, telemetry, health, and registries needs-review PR is ready for code review and waiting on a reviewer labels Oct 19, 2026

@svcnvidia-nemo-ci svcnvidia-nemo-ci 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.

SHIP

LGTM — no reliability concerns. The import-time debug message and OpenAI version-skew warning now use module loggers without implicitly configuring root handlers. Dependency-resolution behavior is unchanged, and CLI verbose logging remains explicitly configured.

Reviewed both changed files and the directly affected callers and existing tests. Static review only; tests were not executed.

Note: formal approval is not available for this request, so this review is posted as a comment only.

Review generated by codex

@cmunley1
cmunley1 disabled auto-merge October 19, 2026 19:09
@cmunley1
cmunley1 merged commit 113c8d9 into main Oct 19, 2026
52 of 57 checks passed
@cmunley1
cmunley1 deleted the iguehring/no-root-logging-on-import branch October 19, 2026 19:09
iguehring-nvidia added a commit that referenced this pull request Oct 19, 2026

This branch was previously deployed

1 inactive deployment
public — f421a879 Deployed Oct 19, 2026 by copy-pr-bot[bot] via release / finalize / notify #5773
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:core Shared APIs, servers, telemetry, health, and registries bug Something isn't working needs-review PR is ready for code review and waiting on a reviewer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants