Skip to content

feat(cli): improve multi-context UX and Config.write API - #1072

Merged
anastasia-nesterenko merged 2 commits into
mainfrom
anesterenko/aircore-931-document-nemo-config-cli-command-for-remote-access
Aug 7, 2026
Merged

feat(cli): improve multi-context UX and Config.write API#1072
anastasia-nesterenko merged 2 commits into
mainfrom
anesterenko/aircore-931-document-nemo-config-cli-command-for-remote-access

Conversation

@anastasia-nesterenko

@anastasia-nesterenko anastasia-nesterenko commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Improves the nemo config multi-context workflow and refactors Config.write() so the CLI can report configuration changes precisely.

Creating the first context makes it current automatically. Creating additional named contexts preserves the existing current context unless --activate is supplied.

CLI behavior changes

  • Predictable context activation

    • The first context becomes current automatically.
    • Additional named contexts do not change the current context.
    • --activate explicitly creates or updates a context and makes it current.
  • Context-specific output

    • Context 'staging' created and set as current
    • Context 'staging' created, followed by a use-context hint
    • Configuration updated for context 'staging' and set as current
    • Switched to context 'staging'
    • Configuration updated for context 'staging'
  • Effective current context

    • nemo config current-context now follows the documented precedence:
      1. Global --context
      2. NMP_CURRENT_CONTEXT
      3. Saved current_context
  • Safer environment overrides

    • An implicit NMP_CURRENT_CONTEXT must reference an existing context.
    • A misspelled context now fails without modifying the configuration.
    • Explicit --context <name> still permits creating a new context.
  • Safe context-switch hints

    • Leading-hyphen context names use the safe form:
      nemo config use-context -- <name>

Config.write() API

  • Adds Config.write_with_result(), returning a frozen ConfigWriteResult containing:
    • config
    • context_name
    • created
  • Keeps Config.write() backward-compatible by delegating to write_with_result().
  • Adds set_current_if_unset to control whether a write establishes the initial current context.
  • Preserves set_current_on_create for existing callers.
  • Uses Generic and TypeVar to preserve Python 3.11 compatibility.

Documentation and maintenance

  • Rewrites docs/cli/configuration.mdx around single- and multi-deployment workflows.
  • Adds a setup-guide link to the nemo config documentation.
  • Removes unsupported config commands from the CLI runbook.
  • Updates README and runbook examples to use consistent context names.
  • Consolidates config group help in config_help.py so the command and manifest registry share one source of truth.
  • Vendors the implementation and tests into the Python SDK package.

Test plan

  • Source config tests: 108 passed
  • Vendored SDK config tests: 108 passed
  • Ruff passed for changed source files
  • git diff --check passed
  • Regression coverage verifies:
    • the first context becomes current
    • additional contexts do not switch the current context
    • --activate switches explicitly
    • unknown NMP_CURRENT_CONTEXT values fail without modifying config
    • current-context follows CLI > environment > saved precedence

Summary by CodeRabbit

  • New Features

    • Added support for managing multiple local and remote deployment contexts.
    • Added context activation, switching, per-command overrides, JSON inspection, and environment-variable selection with clear precedence.
    • Improved configuration commands with status messages for creating, updating, and activating contexts.
  • Documentation

    • Updated setup guides, examples, and runbooks for context-based configuration and remote access.
    • Added deployment connection guidance covering prerequisites, authentication, verification, troubleshooting, and local deployments.
    • Added the deployment connection guide to the CLI reference navigation.

@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 8f0968b0-ecb2-44aa-ab93-f29698e032d9

📥 Commits

Reviewing files that changed from the base of the PR and between f9d9fc6 and 945a2e2.

⛔ Files ignored due to path filters (1)
  • sdk/python/nemo-platform/tests/vendored/nemo_platform_ext/cli/commands/test_config.py is excluded by !sdk/**
📒 Files selected for processing (4)
  • docs/cli/configuration.mdx
  • docs/fern/versions/latest.yml
  • packages/nemo_platform/pyproject.toml
  • packages/nemo_platform_ext/README.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • docs/fern/versions/latest.yml

📝 Walkthrough

Walkthrough

The PR adds context-aware configuration writes, context-selection precedence, write-result reporting, shared CLI help, expanded tests, and deployment documentation.

Changes

Context-aware configuration

Layer / File(s) Summary
Configuration write results and context resolution
packages/nemo_platform_ext/src/nemo_platform_ext/config/config.py, packages/nemo_platform_ext/tests/config/test_config.py
Config.write_with_result reports the selected context and creation status. Context resolution handles runtime, stored, environment-selected, and default contexts.
Context-aware CLI commands
packages/nemo_platform_ext/src/nemo_platform_ext/cli/commands/*, packages/nemo_platform_ext/tests/cli/commands/test_config.py
The CLI applies context overrides, uses shared help text, reports context states, quotes context names, and tests precedence and failure cases.
Context configuration documentation
docs/cli/*, docs/get-started/setup.mdx, packages/nemo_platform_ext/README.md, packages/nemo_platform_ext/docs/runbook.md
Documentation covers remote setup, named contexts, activation, per-command overrides, inspection, environment precedence, and updated deployment examples.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant ConfigCLI
  participant Config
  participant ConfigFile
  User->>ConfigCLI: Invoke config command with optional --context
  ConfigCLI->>Config: Resolve runtime or persisted context
  Config->>ConfigFile: Read and write selected context
  Config-->>ConfigCLI: Return context name and creation status
  ConfigCLI-->>User: Report context state
Loading

Suggested labels: docs

Suggested reviewers: tylersbray, ironcommit, anubhutivyas

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 36.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main changes to multi-context CLI behavior and the Config.write API.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch anesterenko/aircore-931-document-nemo-config-cli-command-for-remote-access

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 4

🧹 Nitpick comments (1)
packages/nemo_platform_ext/src/nemo_platform_ext/config/config.py (1)

597-601: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use a concrete Config bound.

Config is defined before this declaration. Replace bound="Config" with bound=Config.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/nemo_platform_ext/src/nemo_platform_ext/config/config.py` around
lines 597 - 601, Update the _T TypeVar declaration used by ConfigWriteResult to
bind directly to the already-defined Config class, replacing the string forward
reference with the concrete Config symbol.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/cli/configuration.mdx`:
- Around line 7-77: Split the connection workflows from the configuration
reference: move the remote and multi-deployment setup instructions, including
authentication, context switching, and verification commands, into a dedicated
HOW-TO page. Keep this reference page focused on configuration fields,
precedence, telemetry, and completion content; add a prerequisites section at
the top and a Next Steps section at the end, following the documentation
structure guidelines.

In `@packages/nemo_platform_ext/README.md`:
- Line 89: Update the README command examples so creating the production context
does not first modify the current context; remove the preceding context-setting
command or present it as an alternative to the production creation command.

In `@packages/nemo_platform_ext/src/nemo_platform_ext/cli/commands/config.py`:
- Around line 137-139: Update the config command help text describing
current-context selection to state that the first context becomes current only
when no current context is already saved, while preserving that additional
contexts do not switch the current context and can be selected with --activate
or use-context.

In `@packages/nemo_platform_ext/src/nemo_platform_ext/config/config.py`:
- Around line 379-381: Update the missing-config branch in the config creation
flow to preserve the context selected by Config.create(): prefer
config.current_context when assigning context_name, and only fall back to
DEFAULT_CONTEXT when it is unset. Add a regression test covering a first write
with NMP_CURRENT_CONTEXT set and no explicit context, verifying the
configuration is persisted under and resolves through that environment-selected
context.

---

Nitpick comments:
In `@packages/nemo_platform_ext/src/nemo_platform_ext/config/config.py`:
- Around line 597-601: Update the _T TypeVar declaration used by
ConfigWriteResult to bind directly to the already-defined Config class,
replacing the string forward reference with the concrete Config symbol.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: c68cd8fb-a9c1-431a-8522-4ecae96a1756

📥 Commits

Reviewing files that changed from the base of the PR and between 997172c and 1c110ba.

⛔ Files ignored due to path filters (7)
  • sdk/python/nemo-platform/src/nemo_platform/cli/commands/auth.py is excluded by !sdk/**
  • sdk/python/nemo-platform/src/nemo_platform/cli/commands/config.py is excluded by !sdk/**
  • sdk/python/nemo-platform/src/nemo_platform/cli/commands/config_help.py is excluded by !sdk/**
  • sdk/python/nemo-platform/src/nemo_platform/cli/commands/manifest_registry.py is excluded by !sdk/**
  • sdk/python/nemo-platform/src/nemo_platform/config/config.py is excluded by !sdk/**
  • sdk/python/nemo-platform/tests/vendored/nemo_platform_ext/cli/commands/test_config.py is excluded by !sdk/**
  • sdk/python/nemo-platform/tests/vendored/nemo_platform_ext/config/test_config.py is excluded by !sdk/**
📒 Files selected for processing (11)
  • docs/cli/configuration.mdx
  • docs/get-started/setup.mdx
  • packages/nemo_platform_ext/README.md
  • packages/nemo_platform_ext/docs/runbook.md
  • packages/nemo_platform_ext/src/nemo_platform_ext/cli/commands/auth.py
  • packages/nemo_platform_ext/src/nemo_platform_ext/cli/commands/config.py
  • packages/nemo_platform_ext/src/nemo_platform_ext/cli/commands/config_help.py
  • packages/nemo_platform_ext/src/nemo_platform_ext/cli/commands/manifest_registry.py
  • packages/nemo_platform_ext/src/nemo_platform_ext/config/config.py
  • packages/nemo_platform_ext/tests/cli/commands/test_config.py
  • packages/nemo_platform_ext/tests/config/test_config.py

Comment thread docs/cli/configuration.mdx Outdated
Comment thread packages/nemo_platform_ext/README.md
Comment thread packages/nemo_platform_ext/src/nemo_platform_ext/cli/commands/config.py Outdated
Comment thread packages/nemo_platform_ext/src/nemo_platform_ext/config/config.py Outdated
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor
Suite Lines Covered Line Rate Branch Rate
Unit Tests 31501/40120 78.5% 63.1%
Integration Tests 18334/38055 48.2% 20.8%

@anastasia-nesterenko
anastasia-nesterenko force-pushed the anesterenko/aircore-931-document-nemo-config-cli-command-for-remote-access branch from 1c110ba to afc0e37 Compare August 5, 2026 20:54
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/cli/reference.mdx`:
- Line 143: The example was edited directly in generated CLI documentation.
Locate its generator source, move or update the example there, then regenerate
docs/cli/reference.mdx using the designated documentation generation command; do
not hand-edit the generated page.

In `@packages/nemo_platform_ext/tests/cli/commands/test_config.py`:
- Around line 335-346: Update
test_set_rejects_unknown_context_selected_by_environment to load and snapshot
the full configuration before invoking the failing command, then assert the
configuration loaded afterward equals that snapshot. Keep the existing exit-code
and error-output assertions while replacing the narrow absence check with
verification that no configuration fields or contexts changed.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 6b1be2b0-36c8-4e48-be7f-84aa364b4e64

📥 Commits

Reviewing files that changed from the base of the PR and between 73670d7 and afc0e37.

⛔ Files ignored due to path filters (7)
  • sdk/python/nemo-platform/src/nemo_platform/cli/commands/auth.py is excluded by !sdk/**
  • sdk/python/nemo-platform/src/nemo_platform/cli/commands/config.py is excluded by !sdk/**
  • sdk/python/nemo-platform/src/nemo_platform/cli/commands/config_help.py is excluded by !sdk/**
  • sdk/python/nemo-platform/src/nemo_platform/cli/commands/manifest_registry.py is excluded by !sdk/**
  • sdk/python/nemo-platform/src/nemo_platform/config/config.py is excluded by !sdk/**
  • sdk/python/nemo-platform/tests/vendored/nemo_platform_ext/cli/commands/test_config.py is excluded by !sdk/**
  • sdk/python/nemo-platform/tests/vendored/nemo_platform_ext/config/test_config.py is excluded by !sdk/**
📒 Files selected for processing (14)
  • docs/cli/configuration.mdx
  • docs/cli/connect-to-deployments.mdx
  • docs/cli/reference.mdx
  • docs/fern/versions/latest.yml
  • docs/get-started/setup.mdx
  • packages/nemo_platform_ext/README.md
  • packages/nemo_platform_ext/docs/runbook.md
  • packages/nemo_platform_ext/src/nemo_platform_ext/cli/commands/auth.py
  • packages/nemo_platform_ext/src/nemo_platform_ext/cli/commands/config.py
  • packages/nemo_platform_ext/src/nemo_platform_ext/cli/commands/config_help.py
  • packages/nemo_platform_ext/src/nemo_platform_ext/cli/commands/manifest_registry.py
  • packages/nemo_platform_ext/src/nemo_platform_ext/config/config.py
  • packages/nemo_platform_ext/tests/cli/commands/test_config.py
  • packages/nemo_platform_ext/tests/config/test_config.py
🚧 Files skipped from review as they are similar to previous changes (10)
  • packages/nemo_platform_ext/src/nemo_platform_ext/cli/commands/config_help.py
  • packages/nemo_platform_ext/README.md
  • docs/get-started/setup.mdx
  • packages/nemo_platform_ext/src/nemo_platform_ext/cli/commands/manifest_registry.py
  • packages/nemo_platform_ext/src/nemo_platform_ext/cli/commands/config.py
  • packages/nemo_platform_ext/src/nemo_platform_ext/cli/commands/auth.py
  • docs/cli/configuration.mdx
  • packages/nemo_platform_ext/src/nemo_platform_ext/config/config.py
  • packages/nemo_platform_ext/docs/runbook.md
  • packages/nemo_platform_ext/tests/config/test_config.py

Comment thread docs/cli/reference.mdx
Comment thread packages/nemo_platform_ext/tests/cli/commands/test_config.py Outdated
@anastasia-nesterenko
anastasia-nesterenko force-pushed the anesterenko/aircore-931-document-nemo-config-cli-command-for-remote-access branch from afc0e37 to 64416fb Compare August 5, 2026 23:23
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@coderabbitai coderabbitai Bot 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.

🧹 Nitpick comments (1)
packages/nemo_platform_ext/tests/cli/commands/test_config.py (1)

304-305: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Assert the persisted switch for -qa.

Lines 304-305 only assert successful command execution. Load the configuration and assert current_context == "-qa" to verify that the separator command switches context.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/nemo_platform_ext/tests/cli/commands/test_config.py` around lines
304 - 305, Update the test around the use-context command invocation to load the
persisted configuration after the successful switch and assert that
current_context equals "-qa", using the existing configuration-loading helper
and preserving the exit-code assertion.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@packages/nemo_platform_ext/tests/cli/commands/test_config.py`:
- Around line 304-305: Update the test around the use-context command invocation
to load the persisted configuration after the successful switch and assert that
current_context equals "-qa", using the existing configuration-loading helper
and preserving the exit-code assertion.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 617c01e1-434f-41bb-a3ad-0c3e4e865cb9

📥 Commits

Reviewing files that changed from the base of the PR and between b3041f2 and 64416fb.

⛔ Files ignored due to path filters (7)
  • sdk/python/nemo-platform/src/nemo_platform/cli/commands/auth.py is excluded by !sdk/**
  • sdk/python/nemo-platform/src/nemo_platform/cli/commands/config.py is excluded by !sdk/**
  • sdk/python/nemo-platform/src/nemo_platform/cli/commands/config_help.py is excluded by !sdk/**
  • sdk/python/nemo-platform/src/nemo_platform/cli/commands/manifest_registry.py is excluded by !sdk/**
  • sdk/python/nemo-platform/src/nemo_platform/config/config.py is excluded by !sdk/**
  • sdk/python/nemo-platform/tests/vendored/nemo_platform_ext/cli/commands/test_config.py is excluded by !sdk/**
  • sdk/python/nemo-platform/tests/vendored/nemo_platform_ext/config/test_config.py is excluded by !sdk/**
📒 Files selected for processing (14)
  • docs/cli/configuration.mdx
  • docs/cli/connect-to-deployments.mdx
  • docs/cli/reference.mdx
  • docs/fern/versions/latest.yml
  • docs/get-started/setup.mdx
  • packages/nemo_platform_ext/README.md
  • packages/nemo_platform_ext/docs/runbook.md
  • packages/nemo_platform_ext/src/nemo_platform_ext/cli/commands/auth.py
  • packages/nemo_platform_ext/src/nemo_platform_ext/cli/commands/config.py
  • packages/nemo_platform_ext/src/nemo_platform_ext/cli/commands/config_help.py
  • packages/nemo_platform_ext/src/nemo_platform_ext/cli/commands/manifest_registry.py
  • packages/nemo_platform_ext/src/nemo_platform_ext/config/config.py
  • packages/nemo_platform_ext/tests/cli/commands/test_config.py
  • packages/nemo_platform_ext/tests/config/test_config.py
🚧 Files skipped from review as they are similar to previous changes (13)
  • docs/cli/reference.mdx
  • packages/nemo_platform_ext/src/nemo_platform_ext/cli/commands/auth.py
  • docs/fern/versions/latest.yml
  • packages/nemo_platform_ext/src/nemo_platform_ext/cli/commands/config_help.py
  • docs/cli/connect-to-deployments.mdx
  • packages/nemo_platform_ext/src/nemo_platform_ext/cli/commands/manifest_registry.py
  • docs/get-started/setup.mdx
  • packages/nemo_platform_ext/README.md
  • packages/nemo_platform_ext/src/nemo_platform_ext/cli/commands/config.py
  • packages/nemo_platform_ext/docs/runbook.md
  • packages/nemo_platform_ext/tests/config/test_config.py
  • packages/nemo_platform_ext/src/nemo_platform_ext/config/config.py
  • docs/cli/configuration.mdx

@anastasia-nesterenko
anastasia-nesterenko force-pushed the anesterenko/aircore-931-document-nemo-config-cli-command-for-remote-access branch from 64416fb to f9d9fc6 Compare August 6, 2026 18:54
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@ironcommit ironcommit 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.

LGTM

Comment thread packages/nemo_platform_ext/README.md Outdated
@anastasia-nesterenko
anastasia-nesterenko force-pushed the anesterenko/aircore-931-document-nemo-config-cli-command-for-remote-access branch from f4f56eb to b844036 Compare August 7, 2026 16:15
Signed-off-by: anastasia-nesterenko <anesterenko@nvidia.com>
@anastasia-nesterenko
anastasia-nesterenko force-pushed the anesterenko/aircore-931-document-nemo-config-cli-command-for-remote-access branch from b844036 to 945a2e2 Compare August 7, 2026 16:25
…-cli-command-for-remote-access

Signed-off-by: anastasia-nesterenko <anesterenko@nvidia.com>
@anastasia-nesterenko
anastasia-nesterenko force-pushed the anesterenko/aircore-931-document-nemo-config-cli-command-for-remote-access branch from 8082972 to 3d10c86 Compare August 7, 2026 17:22
@anastasia-nesterenko
anastasia-nesterenko added this pull request to the merge queue Aug 7, 2026
Merged via the queue into main with commit 9f9d33b Aug 7, 2026
54 checks passed
@anastasia-nesterenko
anastasia-nesterenko deleted the anesterenko/aircore-931-document-nemo-config-cli-command-for-remote-access branch August 7, 2026 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants