Skip to content

[recipe, test] feat: add unit tests for CometPlugin#3652

Open
lonexreb wants to merge 2 commits intoNVIDIA-NeMo:mainfrom
lonexreb:training/test-comet-plugin
Open

[recipe, test] feat: add unit tests for CometPlugin#3652
lonexreb wants to merge 2 commits intoNVIDIA-NeMo:mainfrom
lonexreb:training/test-comet-plugin

Conversation

@lonexreb
Copy link
Copy Markdown
Contributor

@lonexreb lonexreb commented May 4, 2026

Summary

run_plugins.py exports a CometPlugin for wiring Comet ML logging through a run.Script task, but test_run_plugins.py had test classes for every other plugin in the file (Wandb, Nsys, Preemption, FaultTolerance, PyTorchProfiler, PerfEnv) — except CometPlugin.

This PR adds TestCometPlugin (7 tests, +158 LoC) mirroring the TestWandbPlugin pattern. Tests-only — no production code changes.

What's covered

Test Behavior locked in
test_initialization Field storage (project, name, workspace)
test_initialization_optional_fields_default_to_none name + workspace default to None
test_setup_with_script_task Happy path: COMET_API_KEY forwarded to executor.env_vars; documented Hydra overrides (logger.comet_project, logger.comet_workspace, logger.comet_experiment_name) appended to task.args
test_setup_with_only_required_field When name/workspace are None, only the project override is emitted — the others are NOT
test_setup_without_api_key_warns_and_does_not_propagate Missing COMET_API_KEY ⇒ clear warning, no env var, no CLI overrides
test_setup_raises_for_non_script_task run.Partial task ⇒ NotImplementedError. AND the API key is still forwarded BEFORE the type check (current contract — locking this in means a future refactor that drops it fails loudly)
test_custom_script_args_converter Custom script_args_converter_fn replaces the default Hydra overrides entirely

Test plan

  • python3 -m ast parse clean
  • ruff check clean
  • ruff format --check clean
  • CI: cicd-unit-tests-core picks up the new test class automatically (file already covered)

Risk

Zero — tests only.

`run_plugins.py` exports a `CometPlugin` for wiring Comet ML logging
through a `run.Script` task, but `test_run_plugins.py` had test classes
for every other plugin (Wandb, Nsys, Preemption, FaultTolerance,
PyTorchProfiler, PerfEnv) except CometPlugin.

Add `TestCometPlugin` mirroring the `TestWandbPlugin` pattern. 7 new
tests cover:

  - field initialization (project, name, workspace) including the
    optional-field default-to-None case
  - happy-path setup with COMET_API_KEY: env var forwarded to
    executor.env_vars and the documented Hydra-style CLI overrides
    (`logger.comet_project`, `logger.comet_workspace`,
    `logger.comet_experiment_name`) appended to task.args
  - bare-project-only setup: when name and workspace are None, only
    the project override is emitted (the others are NOT)
  - missing COMET_API_KEY: a clear warning is logged, no env var is
    forwarded, and no CLI overrides are appended
  - non-Script task path: NotImplementedError with the documented
    message, AND the API key is still forwarded to the executor
    (current contract — exposing this in a test means a future
    refactor that drops it will fail loudly)
  - custom `script_args_converter_fn`: replaces the default
    Hydra-style overrides entirely (a new `--comet-*` style is emitted,
    Hydra-style is NOT)

Tests-only — no production code changes.

Signed-off-by: lonexreb <[email protected]>
@copy-pr-bot
Copy link
Copy Markdown

copy-pr-bot Bot commented May 4, 2026

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@cuichenx
Copy link
Copy Markdown
Contributor

cuichenx commented May 5, 2026

/ok to test b4c8d31

@cuichenx cuichenx added the ready-to-merge PR is approved, current, and only waiting for CI to pass before merge label May 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-request ready-to-merge PR is approved, current, and only waiting for CI to pass before merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants