Skip to content

feat(cli): connect setup to remote platforms - #835

Merged
tylersbray merged 8 commits into
mainfrom
aircore-934-nemo-cli-setup-remote-configuration/tbray
Jul 23, 2026
Merged

feat(cli): connect setup to remote platforms#835
tylersbray merged 8 commits into
mainfrom
aircore-934-nemo-cli-setup-remote-configuration/tbray

Conversation

@tylersbray

@tylersbray tylersbray commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Summary

  • extend the unreachable-platform prompt with local start, remote connect, and manual-start choices
  • persist remote URLs in the active CLI context and reuse the existing OIDC login flow
  • authenticate direct demo-agent requests, document remote setup, and vendor the extension changes
  • add command-level CliRunner coverage for local, remote, and manual-start variants

Linear: https://linear.app/nvidia/issue/AIRCORE-934/nemo-cli-setup-command-should-offer-remote-configuration

Test plan

  • uv run --frozen pytest packages/nemo_platform_ext/tests/cli/commands/test_setup.py packages/nemo_platform_ext/tests/cli/commands/test_setup_cli.py packages/nemo_platform_ext/tests/cli/commands/test_auth.py -q (229 passed)
  • uv run --frozen pytest sdk/python/nemo-platform/tests/vendored/nemo_platform_ext/cli/commands/test_setup.py sdk/python/nemo-platform/tests/vendored/nemo_platform_ext/cli/commands/test_setup_cli.py -q (201 passed)
  • Ruff lint and format checks
  • ty check for modified setup/auth modules
  • pre-commit hooks
  • Bugbot review (no findings)

Summary by CodeRabbit

  • New Features
    • nemo setup can now connect to an existing remote Platform when local services are unreachable.
    • Interactive wizard supports choosing remote vs starting services, including saving the remote base URL/workspace and continuing authentication when needed.
    • Added non-interactive remote setup via --auto with NMP_BASE_URL/NMP_ACCESS_TOKEN and --no-start-services.
    • CLI auth supports env-provided OIDC username/password.
  • Documentation
    • Updated setup wizard steps, reference docs, and examples for remote connection.
  • Bug Fixes
    • Improved setup cancellation behavior and prevented starting local services for remote URLs.
    • Config/quickstart saves now tolerate permission errors when adjusting file permissions.
  • Tests
    • Expanded coverage for remote/local selection, remote auth flows, and retry/persistence behavior.

@tylersbray
tylersbray requested review from a team as code owners July 21, 2026 21:56
@github-actions github-actions Bot added the feat label Jul 21, 2026
@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

nemo setup now supports remote deployment connections, context authentication, authenticated setup requests, permission-tolerant configuration writes, and documented interactive or automated remote setup flows.

Changes

Remote setup and authentication

Layer / File(s) Summary
Centralized OIDC authentication
packages/nemo_platform_ext/src/nemo_platform_ext/cli/commands/auth.py
OIDC discovery, grant selection, scope validation, token persistence, and login output are consolidated in _login_with_oidc.
Remote connection flow
packages/nemo_platform_ext/src/nemo_platform_ext/cli/commands/setup.py, packages/nemo_platform_ext/tests/cli/commands/test_setup.py, packages/nemo_platform_ext/tests/cli/commands/test_setup_cli.py
The wizard probes local and hosted health endpoints, offers remote connection when needed, persists URL and workspace settings, authenticates the context, handles cancellation, and validates local and remote branches.
Authenticated downstream setup requests
packages/nemo_platform_ext/src/nemo_platform_ext/cli/commands/setup.py
Demo-agent requests use context-derived headers, and provider secret naming is conditional on API-key presence.
Setup documentation and help
docs/cli/configuration.mdx, docs/get-started/setup.mdx, docs/cli/reference.mdx, packages/nemo_platform_ext/src/nemo_platform_ext/cli/commands/manifest_registry.py, packages/nemo_platform_ext/tests/cli/commands/test_agent.py, packages/nemo_platform_ext/tests/cli/test_app.py
Documentation and CLI help describe remote connections, local startup, and authenticated non-interactive setup.
Permission-tolerant configuration writes
packages/nemo_platform_ext/src/nemo_platform_ext/config/config.py, packages/nemo_platform_ext/src/nemo_platform_ext/quickstart/config.py, packages/nemo_platform_ext/tests/config/test_config.py
Configuration saves retain owner-only permission attempts while tolerating PermissionError from unowned directories.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant setup_command
  participant Platform
  participant Config
  participant OIDC
  User->>setup_command: Select remote connection
  setup_command->>Platform: Probe remote reachability
  setup_command->>Config: Save base URL and workspace
  setup_command->>OIDC: Ensure platform authentication
  OIDC->>Platform: Request tokens
  OIDC->>Config: Persist credentials
  setup_command->>Platform: Continue setup with auth headers
Loading

Suggested labels: docs, test

Suggested reviewers: benmccown, ironcommit, marcusds, mckornfield

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% 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 matches the main change: enabling CLI setup to connect to remote platforms.
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 aircore-934-nemo-cli-setup-remote-configuration/tbray

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

@github-actions

github-actions Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor
Suite Lines Covered Line Rate Branch Rate
Unit Tests 27140/34858 77.9% 62.1%
Integration Tests 15925/33570 47.4% 19.9%

@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: 1

🤖 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`:
- Around line 45-50: Update the source CLI help text that produces the affected
“Set up NeMo Platform” documentation instead of editing docs/cli/reference.mdx
directly, then regenerate the reference with make generate-cli-reference-docs so
the generated file reflects the change.
🪄 Autofix (Beta)

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: 66858791-2e66-44b1-828f-0cc3f34e2582

📥 Commits

Reviewing files that changed from the base of the PR and between c22a419 and 78ace30.

⛔ Files ignored due to path filters (3)
  • sdk/python/nemo-platform/src/nemo_platform/cli/commands/manifest_registry.py is excluded by !sdk/**
  • sdk/python/nemo-platform/tests/vendored/nemo_platform_ext/cli/commands/test_agent.py is excluded by !sdk/**
  • sdk/python/nemo-platform/tests/vendored/nemo_platform_ext/cli/test_app.py is excluded by !sdk/**
📒 Files selected for processing (4)
  • docs/cli/reference.mdx
  • packages/nemo_platform_ext/src/nemo_platform_ext/cli/commands/manifest_registry.py
  • packages/nemo_platform_ext/tests/cli/commands/test_agent.py
  • packages/nemo_platform_ext/tests/cli/test_app.py

Comment thread docs/cli/reference.mdx
Let collaborative users configure the local CLI against an existing deployment while preserving the default local setup path. Reuse the established OIDC flow and persist the selected deployment in the active context.

AIRCORE-934

Signed-off-by: Tyler Bray <tbray@nvidia.com>
Keep TopLevelEntry.help aligned with setup_command so
test_manifest_help_matches_loaded_manual_entry passes after the
remote-connect wording change.

AIRCORE-934

Signed-off-by: Tyler Bray <tbray@nvidia.com>
@tylersbray
tylersbray force-pushed the aircore-934-nemo-cli-setup-remote-configuration/tbray branch from 78ace30 to 4169615 Compare July 22, 2026 01:29

@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: 1

🤖 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 `@packages/nemo_platform_ext/src/nemo_platform_ext/cli/commands/setup.py`:
- Around line 1786-1789: Update the connect_remote branch in the setup command
to determine whether the workspace parameter was explicitly provided via
ctx.get_parameter_source("workspace"). Reuse the currently configured workspace
when the flag was not explicit, and pass the explicit workspace value only when
supplied to _configure_remote_connection, preserving the active workspace during
reconnects.
🪄 Autofix (Beta)

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: 547b5d67-d964-419d-8450-647244eebafb

📥 Commits

Reviewing files that changed from the base of the PR and between 78ace30 and 4169615.

⛔ 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/manifest_registry.py is excluded by !sdk/**
  • sdk/python/nemo-platform/src/nemo_platform/cli/commands/setup.py is excluded by !sdk/**
  • sdk/python/nemo-platform/tests/vendored/nemo_platform_ext/cli/commands/test_agent.py is excluded by !sdk/**
  • sdk/python/nemo-platform/tests/vendored/nemo_platform_ext/cli/commands/test_setup.py is excluded by !sdk/**
  • sdk/python/nemo-platform/tests/vendored/nemo_platform_ext/cli/commands/test_setup_cli.py is excluded by !sdk/**
  • sdk/python/nemo-platform/tests/vendored/nemo_platform_ext/cli/test_app.py is excluded by !sdk/**
📒 Files selected for processing (10)
  • docs/cli/configuration.mdx
  • docs/cli/reference.mdx
  • docs/get-started/setup.mdx
  • packages/nemo_platform_ext/src/nemo_platform_ext/cli/commands/auth.py
  • packages/nemo_platform_ext/src/nemo_platform_ext/cli/commands/manifest_registry.py
  • packages/nemo_platform_ext/src/nemo_platform_ext/cli/commands/setup.py
  • packages/nemo_platform_ext/tests/cli/commands/test_agent.py
  • packages/nemo_platform_ext/tests/cli/commands/test_setup.py
  • packages/nemo_platform_ext/tests/cli/commands/test_setup_cli.py
  • packages/nemo_platform_ext/tests/cli/test_app.py
🚧 Files skipped from review as they are similar to previous changes (6)
  • docs/cli/configuration.mdx
  • packages/nemo_platform_ext/tests/cli/commands/test_agent.py
  • packages/nemo_platform_ext/tests/cli/test_app.py
  • packages/nemo_platform_ext/src/nemo_platform_ext/cli/commands/manifest_registry.py
  • docs/cli/reference.mdx
  • packages/nemo_platform_ext/src/nemo_platform_ext/cli/commands/auth.py

Only overwrite the configured workspace during remote setup when
--workspace was passed explicitly.

AIRCORE-934

Signed-off-by: Tyler Bray <tbray@nvidia.com>
Signed-off-by: Tyler Bray <tbray@nvidia.com>

@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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/nemo_platform_ext/tests/cli/commands/test_setup.py (1)

2564-2573: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Assert remote setup ordering.

This test verifies that configuration, authentication, and interactive setup each run, but not their order. It would pass if setup continued before authentication. Record the calls or attach the mocks to one parent and assert configure → authenticate → run.

Also applies to: 2577-2606

🤖 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_setup.py` around lines
2564 - 2573, Update test_cancelling_initial_connection_prompt_exits_cleanly and
the related setup tests to track the configuration, authentication, and
interactive setup calls through a shared parent mock or call recorder. Assert
they execute in the required configure → authenticate → run order while
preserving the existing cancellation and exit-code assertions.
🧹 Nitpick comments (1)
packages/nemo_platform_ext/tests/config/test_config.py (1)

870-889: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick win

Cover file-level chmod failure.

This test exercises only parent-directory failure; it would pass even if config-file chmod were silently skipped. Add a case where chmod fails for the target file and assert the intended secure behavior.

🤖 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/config/test_config.py` around lines 870 -
889, Extend test_save_tolerates_unowned_parent_directory to make os.chmod fail
when called for config_path, not only tmp_path, and assert the intended secure
behavior for the written configuration file. Keep the existing parent-directory
scenario intact while ensuring the test verifies file-level chmod failures are
handled correctly.
🤖 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 `@packages/nemo_platform_ext/src/nemo_platform_ext/cli/commands/setup.py`:
- Around line 448-450: Update the setup health-reporting flow around
_verify_platform_health so the detail "Hosted deployment does not publish
/status." is treated as informational rather than a health failure. Keep the
existing warning output for genuine health verification failures, while
preserving successful hosted setup behavior.

In `@packages/nemo_platform_ext/src/nemo_platform_ext/config/config.py`:
- Around line 33-38: Credential-file permission failures must remain fatal while
parent-directory permission failures remain tolerated. In
packages/nemo_platform_ext/src/nemo_platform_ext/config/config.py lines 33-38,
update _secure_chmod to suppress PermissionError only for directory chmod
operations; retain tolerant parent-directory handling at line 277, but enforce
secure 600 file creation/replacement and abort before writing when that cannot
be guaranteed at line 290. Apply the same separation in
packages/nemo_platform_ext/src/nemo_platform_ext/quickstart/config.py lines
22-27, retaining parent-directory tolerance at line 240 and enforcing secure
file creation/replacement at line 262.

In `@packages/nemo_platform_ext/tests/cli/commands/test_setup.py`:
- Around line 167-176: Update test_reachable_via_status and the /cluster-info
fallback test to patch client_verify_from_env() with a known TLS verification
value, then assert that exact value in each httpx.get call. Remove the
tautological mock_get.call_args.kwargs["verify"] assertion while preserving the
existing endpoint and timeout checks.
- Around line 2744-2751: Update _check_controller_health so a 404 from /status
is considered healthy only when the URL is verified as a supported
hosted-platform endpoint, preserving the existing hosted deployment test. Add a
negative test using a local or unknown host to assert that its 404 result is
unhealthy, and ensure reachability through another endpoint cannot make that
case pass.

---

Outside diff comments:
In `@packages/nemo_platform_ext/tests/cli/commands/test_setup.py`:
- Around line 2564-2573: Update
test_cancelling_initial_connection_prompt_exits_cleanly and the related setup
tests to track the configuration, authentication, and interactive setup calls
through a shared parent mock or call recorder. Assert they execute in the
required configure → authenticate → run order while preserving the existing
cancellation and exit-code assertions.

---

Nitpick comments:
In `@packages/nemo_platform_ext/tests/config/test_config.py`:
- Around line 870-889: Extend test_save_tolerates_unowned_parent_directory to
make os.chmod fail when called for config_path, not only tmp_path, and assert
the intended secure behavior for the written configuration file. Keep the
existing parent-directory scenario intact while ensuring the test verifies
file-level chmod failures are handled correctly.
🪄 Autofix (Beta)

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: d30eb464-3bf1-4821-8725-22d597554998

📥 Commits

Reviewing files that changed from the base of the PR and between 2ee6505 and 3b98a01.

⛔ Files ignored due to path filters (2)
  • sdk/python/nemo-platform/src/nemo_platform/cli/commands/setup.py is excluded by !sdk/**
  • sdk/python/nemo-platform/src/nemo_platform/config/config.py is excluded by !sdk/**
📒 Files selected for processing (5)
  • packages/nemo_platform_ext/src/nemo_platform_ext/cli/commands/setup.py
  • packages/nemo_platform_ext/src/nemo_platform_ext/config/config.py
  • packages/nemo_platform_ext/src/nemo_platform_ext/quickstart/config.py
  • packages/nemo_platform_ext/tests/cli/commands/test_setup.py
  • packages/nemo_platform_ext/tests/config/test_config.py

Comment thread packages/nemo_platform_ext/src/nemo_platform_ext/cli/commands/setup.py Outdated
Comment thread packages/nemo_platform_ext/src/nemo_platform_ext/config/config.py Outdated
Comment thread packages/nemo_platform_ext/tests/cli/commands/test_setup.py
Comment thread packages/nemo_platform_ext/tests/cli/commands/test_setup.py

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

Tested end to end and it works well for me both locally and remotely.

Address CodeRabbit review and lint-sdk-vendored drift: gate /status 404
on /cluster-info evidence, keep parent-dir chmod tolerant while enforcing
600 credential files, and re-vendor the SDK copy from source.

Signed-off-by: Tyler Bray <tbray@nvidia.com>
…934)

When setup finds a reachable remote URL, offer continue, start local, or
connect to a different host instead of silently continuing. Document URL
override escape hatches in help and prefill the remote URL prompt.

Signed-off-by: Tyler Bray <tbray@nvidia.com>
Comment thread packages/nemo_platform_ext/tests/cli/commands/test_setup.py Fixed
Comment thread docs/cli/reference.mdx
Comment thread packages/nemo_platform_ext/src/nemo_platform_ext/cli/commands/setup.py Outdated
Comment thread packages/nemo_platform_ext/src/nemo_platform_ext/config/config.py Outdated
Comment thread packages/nemo_platform_ext/tests/cli/commands/test_setup.py Outdated
- Fix CodeQL "incomplete URL substring sanitization" by asserting the
  full prompt message instead of a hostname substring check.
- Use a StrEnum for the reachable-remote connection choices.
- Reword the secure-config-write docstring.
- Re-vendor SDK copies so lint-sdk-vendored/lint-cli stay in sync.

Signed-off-by: Tyler Bray <tbray@nvidia.com>
Collapse the repeated typer Context / CLIContext and with-patch stacks in
TestNonTtyEarlyExit and TestSetupCommandRemoteFlow into shared helpers.

Signed-off-by: Tyler Bray <tbray@nvidia.com>
@tylersbray
tylersbray added this pull request to the merge queue Jul 23, 2026
Merged via the queue into main with commit fa70107 Jul 23, 2026
60 checks passed
@tylersbray
tylersbray deleted the aircore-934-nemo-cli-setup-remote-configuration/tbray branch July 23, 2026 20:07
AnuradhaKaruppiah pushed a commit to AnuradhaKaruppiah/nemo-platform that referenced this pull request Jul 24, 2026
* feat(cli): connect setup to remote platforms

Let collaborative users configure the local CLI against an existing deployment while preserving the default local setup path. Reuse the established OIDC flow and persist the selected deployment in the active context.

AIRCORE-934

Signed-off-by: Tyler Bray <tbray@nvidia.com>

* fix(cli): sync setup help text in manifest registry

Keep TopLevelEntry.help aligned with setup_command so
test_manifest_help_matches_loaded_manual_entry passes after the
remote-connect wording change.

AIRCORE-934

Signed-off-by: Tyler Bray <tbray@nvidia.com>

* fix(cli): preserve active workspace on remote reconnect

Only overwrite the configured workspace during remote setup when
--workspace was passed explicitly.

AIRCORE-934

Signed-off-by: Tyler Bray <tbray@nvidia.com>

* fix(cli): support hosted setup endpoints (NVIDIA-NeMo#934)

Signed-off-by: Tyler Bray <tbray@nvidia.com>

* fix(cli): harden hosted setup probes and config file perms

Address CodeRabbit review and lint-sdk-vendored drift: gate /status 404
on /cluster-info evidence, keep parent-dir chmod tolerant while enforcing
600 credential files, and re-vendor the SDK copy from source.

Signed-off-by: Tyler Bray <tbray@nvidia.com>

* feat(cli): re-prompt when remote platform is reachable during setup (NVIDIA-NeMo#934)

When setup finds a reachable remote URL, offer continue, start local, or
connect to a different host instead of silently continuing. Document URL
override escape hatches in help and prefill the remote URL prompt.

Signed-off-by: Tyler Bray <tbray@nvidia.com>

* fix(cli): address setup review nits and CodeQL alert (NVIDIA-NeMo#934)

- Fix CodeQL "incomplete URL substring sanitization" by asserting the
  full prompt message instead of a hostname substring check.
- Use a StrEnum for the reachable-remote connection choices.
- Reword the secure-config-write docstring.
- Re-vendor SDK copies so lint-sdk-vendored/lint-cli stay in sync.

Signed-off-by: Tyler Bray <tbray@nvidia.com>

* refactor(cli): extract setup_command test helpers (NVIDIA-NeMo#934)

Collapse the repeated typer Context / CLIContext and with-patch stacks in
TestNonTtyEarlyExit and TestSetupCommandRemoteFlow into shared helpers.

Signed-off-by: Tyler Bray <tbray@nvidia.com>

---------

Signed-off-by: Tyler Bray <tbray@nvidia.com>
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.

4 participants