Skip to content

Conversation

@bennyz
Copy link
Member

@bennyz bennyz commented Dec 2, 2025

Summary by CodeRabbit

New Features

  • Added --lease-id option to the lease creation command, allowing users to specify a custom lease ID when creating leases.

✏️ Tip: You can customize this high-level summary in your review settings.

@bennyz bennyz requested a review from mangelajo December 2, 2025 11:29
@netlify
Copy link

netlify bot commented Dec 2, 2025

Deploy Preview for jumpstarter-docs ready!

Name Link
🔨 Latest commit 6d6c9fc
🔍 Latest deploy log https://app.netlify.com/projects/jumpstarter-docs/deploys/692ee89b5408480008fc57d8
😎 Deploy Preview https://deploy-preview-763--jumpstarter-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 2, 2025

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

Adds an optional lease_id parameter to the lease creation workflow, propagating it from the CLI through the config layer, gRPC service, and lease logic. Includes minor formatting improvements for code consistency.

Changes

Cohort / File(s) Change Summary
Lease ID Parameter Addition
packages/jumpstarter-cli/jumpstarter_cli/create.py, packages/jumpstarter/jumpstarter/config/client.py, packages/jumpstarter/jumpstarter/client/grpc.py, packages/jumpstarter/jumpstarter/client/lease.py
Adds optional lease_id parameter to lease creation API. Parameter is threaded through CLI --lease-id option, config method signature, gRPC CreateLease call, and into lease creation request.
Code Formatting & Consistency
packages/jumpstarter/jumpstarter/client/client.py, packages/jumpstarter/jumpstarter/client/decorators.py
Standardizes string quoting from single to double quotes in attribute names and dictionary keys; refactors one-liner expressions for readability.
Test Updates
packages/jumpstarter/jumpstarter/client/grpc_test.py, packages/jumpstarter/jumpstarter/client/lease_test.py
Reformats Exporter constructor calls to single-line style, expands create_test_lease with effective_end_time parameter, and standardizes patch syntax.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

  • Parameter propagation is straightforward across the stack with no complex logic changes
  • Formatting changes are trivial and repetitive in nature
  • Test updates follow consistent patterns without introducing new business logic
  • Worth noting: Verify that the lease_id parameter defaults correctly to None throughout the call chain and that the gRPC request properly serializes empty/None values

Possibly related PRs

Suggested reviewers

  • mangelajo
  • kirkbrauer

Poem

🐰 A lease gets a name, whispered through the stack,
From CLI to gRPC, there and back,
Parameters hop through the layers so spry,
Custom IDs granted—no need to ask why!
Formatted quotes in their doubles now gleam,
A hop forward for the jumpstarter dream!

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'cli: add support for requesting custom lease name' directly matches the PR's purpose of adding CLI support for custom lease naming.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@bennyz
Copy link
Member Author

bennyz commented Dec 2, 2025

@coderabbitai review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 2, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
packages/jumpstarter/jumpstarter/client/grpc_test.py (1)

63-126: Test helpers now cover broader lease shapes

create_test_exporter and create_test_lease provide clearer, keyword-based setup for exporter/lease mocks, including effective_begin_time, effective_duration, begin_time, duration, and effective_end_time. This makes the later tests easier to understand and keeps them aligned with the Lease model fields.

If you want closer realism with production semantics, consider defaulting effective_duration to a partial elapsed time when effective_begin_time is set, mirroring how it behaves in Lease.monitor_async. Based on learnings, effective_duration is “elapsed so far”, not total.

packages/jumpstarter/jumpstarter/client/lease.py (1)

65-75: Passing lease_id=self.name cleanly supports custom lease IDs

In _create, forwarding lease_id=self.name to CreateLease allows a pre-set name (from env flag or CLI-supplied ID) to drive the requested lease ID, while the existing “no name” path still results in lease_id="" and server-generated IDs. Combined with the fallback that resets self.name = None when selector mismatches, this looks correct and backward compatible.

You might consider logging the requested lease_id when it’s non-empty to aid debugging around custom lease-name collisions.

packages/jumpstarter-cli/jumpstarter_cli/create.py (1)

25-35: CLI wiring for --lease-id looks correct and backwards compatible

The new @click.option("--lease-id", ...) plus the updated create_lease signature order (config, selector, duration, begin_time, lease_id, output) match the decorator ordering and correctly forward lease_id into config.create_lease. When --lease-id is omitted, None propagates and the backend will generate an ID as before.

Consider adding a short CLI test that invokes jmp create lease ... --lease-id foo and asserts that the resulting lease name/id contains or equals foo, to lock in this new behavior.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 312a389 and e9a02db.

📒 Files selected for processing (8)
  • packages/jumpstarter-cli/jumpstarter_cli/create.py (2 hunks)
  • packages/jumpstarter/jumpstarter/client/client.py (1 hunks)
  • packages/jumpstarter/jumpstarter/client/decorators.py (3 hunks)
  • packages/jumpstarter/jumpstarter/client/grpc.py (4 hunks)
  • packages/jumpstarter/jumpstarter/client/grpc_test.py (12 hunks)
  • packages/jumpstarter/jumpstarter/client/lease.py (2 hunks)
  • packages/jumpstarter/jumpstarter/client/lease_test.py (15 hunks)
  • packages/jumpstarter/jumpstarter/config/client.py (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

📄 CodeRabbit inference engine (.cursor/rules/project-structure.mdc)

Ruff should be used for code formatting and linting, excluding jumpstarter-protocol package

Files:

  • packages/jumpstarter/jumpstarter/client/client.py
  • packages/jumpstarter/jumpstarter/client/decorators.py
  • packages/jumpstarter/jumpstarter/client/lease.py
  • packages/jumpstarter/jumpstarter/client/grpc.py
  • packages/jumpstarter-cli/jumpstarter_cli/create.py
  • packages/jumpstarter/jumpstarter/client/grpc_test.py
  • packages/jumpstarter/jumpstarter/client/lease_test.py
  • packages/jumpstarter/jumpstarter/config/client.py
🧠 Learnings (3)
📚 Learning: 2025-11-27T09:58:55.346Z
Learnt from: CR
Repo: jumpstarter-dev/jumpstarter PR: 0
File: .cursor/rules/project-structure.mdc:0-0
Timestamp: 2025-11-27T09:58:55.346Z
Learning: Applies to packages/jumpstarter-driver-*/jumpstarter_driver_*/ : Driver packages must implement a `client.py` file containing the client implementation

Applied to files:

  • packages/jumpstarter/jumpstarter/client/client.py
📚 Learning: 2025-10-14T17:43:07.788Z
Learnt from: michalskrivanek
Repo: jumpstarter-dev/jumpstarter PR: 704
File: packages/jumpstarter/jumpstarter/client/grpc.py:100-107
Timestamp: 2025-10-14T17:43:07.788Z
Learning: In the Jumpstarter client lease model (packages/jumpstarter/jumpstarter/client/grpc.py), `effective_duration` represents the elapsed time for an active lease so far, not the total duration. To calculate expected release time, use `effective_begin_time + duration` (where `duration` is the configured/requested duration), not `effective_begin_time + effective_duration`.

Applied to files:

  • packages/jumpstarter/jumpstarter/client/lease.py
  • packages/jumpstarter/jumpstarter/client/grpc.py
  • packages/jumpstarter/jumpstarter/client/grpc_test.py
  • packages/jumpstarter/jumpstarter/config/client.py
📚 Learning: 2025-11-27T09:58:41.875Z
Learnt from: CR
Repo: jumpstarter-dev/jumpstarter PR: 0
File: .cursor/rules/creating-new-drivers.mdc:0-0
Timestamp: 2025-11-27T09:58:41.875Z
Learning: Applies to packages/jumpstarter-driver-**/jumpstarter_driver_**/*.py : Driver implementations should follow existing code style validated with `make lint` (fix with `make lint-fix`), perform static type checking with `make ty-pkg-${package_name}`, add comprehensive tests, and verify all tests pass with `make test-pkg-${package_name}` or `make test`

Applied to files:

  • packages/jumpstarter/jumpstarter/client/lease_test.py
🧬 Code graph analysis (6)
packages/jumpstarter/jumpstarter/client/client.py (2)
packages/jumpstarter-driver-composite/jumpstarter_driver_composite/driver.py (1)
  • report (42-45)
packages/jumpstarter/jumpstarter/driver/base.py (1)
  • report (198-213)
packages/jumpstarter/jumpstarter/client/lease.py (1)
packages/jumpstarter/jumpstarter/common/metadata.py (1)
  • name (13-14)
packages/jumpstarter-cli/jumpstarter_cli/create.py (2)
packages/jumpstarter/jumpstarter/config/client.py (2)
  • create_lease (199-212)
  • lease (135-143)
packages/jumpstarter-cli/jumpstarter_cli/config.py (1)
  • config (8-12)
packages/jumpstarter/jumpstarter/client/grpc_test.py (5)
packages/jumpstarter/jumpstarter/client/grpc.py (1)
  • Exporter (79-118)
packages/jumpstarter/jumpstarter/common/metadata.py (1)
  • name (13-14)
packages/jumpstarter-cli/jumpstarter_cli/get_test.py (1)
  • create_test_lease (248-263)
packages/jumpstarter/jumpstarter/exporter/exporter.py (1)
  • status (167-186)
packages/jumpstarter/jumpstarter/config/client.py (1)
  • lease (135-143)
packages/jumpstarter/jumpstarter/client/lease_test.py (1)
packages/jumpstarter/jumpstarter/client/lease.py (2)
  • LeaseAcquisitionSpinner (326-396)
  • _is_terminal_available (343-350)
packages/jumpstarter/jumpstarter/config/client.py (1)
packages/jumpstarter/jumpstarter/client/grpc.py (1)
  • CreateLease (380-409)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
  • GitHub Check: pytest-matrix (macos-15, 3.12)
  • GitHub Check: pytest-matrix (macos-15, 3.13)
  • GitHub Check: pytest-matrix (macos-15, 3.11)
  • GitHub Check: pytest-matrix (ubuntu-24.04, 3.13)
  • GitHub Check: pytest-matrix (ubuntu-24.04, 3.11)
  • GitHub Check: pytest-matrix (ubuntu-24.04, 3.12)
  • GitHub Check: e2e
🔇 Additional comments (17)
packages/jumpstarter/jumpstarter/client/client.py (1)

62-63: Field access remains safe and backward compatible

Using getattr with defaults for description and methods_description keeps the client resilient to older reports that may not define these fields and normalizes empty values to None/{} as before. The change to double-quoted attribute names is style-only and consistent with Ruff/formatter usage.

packages/jumpstarter/jumpstarter/client/decorators.py (3)

38-52: Help text resolution and click param transfer remain correct

Logic for deriving help from kwargs, docstring, and client.description, plus copying __click_params__, is unchanged apart from style; behavior looks correct and backwards compatible.


77-81: Single-command decorator description override is intact

driver_click_command still correctly lets client.description override Click’s default help; style-only change.


91-101: Command name normalization and server help override unchanged

The group command decorator still normalizes names via lower().replace("_", "-") and overrides help from methods_description when present; this remains consistent and safe.

packages/jumpstarter/jumpstarter/client/grpc.py (2)

268-289: ExporterList dump helpers still apply excludes correctly

The comprehension-based construction for "exporters" still honors exclude_fields for lease/online and preserves the JSON and dict shapes; this is a safe readability improvement.


380-407: lease_id propagation into CreateLeaseRequest looks correct

Adding lease_id: str | None = None and forwarding it as lease_id=lease_id or "" ensures the field is always a string and remains optional. This aligns with the config and Lease._create callers, and keeps the API backward compatible when lease_id is omitted. Verify there are no legacy direct stub usages of CreateLease() elsewhere in the codebase.

packages/jumpstarter/jumpstarter/client/grpc_test.py (4)

137-207: Exporter lease table tests remain consistent with display behavior

The refactored Exporter constructions and assertions (with and without lease, and with show_leases=True/False) still validate column counts and basic content, including the “Available” fallback when no lease is attached. These tests continue to exercise the key branches in Exporter.rich_add_rows.


210-283: Online status and combined-feature tests match rich_add_rows output

Tests around online/offline exporters and the “all features” scenario now use concise Exporter(...) calls and verify presence of yes/no, labels, and lease-related fields. This gives good coverage of the show_online and show_leases options together.


285-321: Ended lease info extraction aligns with exporter display logic

test_exporter_lease_info_extraction mirrors the logic in Exporter.rich_add_rows for choosing effective_end_time when present, and checks that the resulting lease_info tuple contains the expected client, status, and "2023-01-01 11:00:00" end time. This correctly exercises the “Ended” path.


323-376: Scheduled and no-lease scenarios correctly exercise expected release computation

The tests for no-lease exporters and scheduled leases validate that “Available” status is used when lease is None, and that scheduled leases display begin_time + duration as the expected release time. This matches the intended semantics of using configured duration rather than effective_duration for future end times (consistent with earlier learnings).

packages/jumpstarter/jumpstarter/client/lease.py (1)

371-388: Spinner log throttling condition remains equivalent and clearer

The consolidated should_log expression preserves the previous behavior: always log when force=True, on the first message, or when the throttle interval has elapsed. Tests in lease_test.py cover first/within/after-interval and forced cases, so this refactor looks safe.

packages/jumpstarter/jumpstarter/client/lease_test.py (4)

33-59: TTY detection tests unchanged apart from formatting

The multi-line with contexts patching sys.stdout.isatty / sys.stderr.isatty are just style changes; the tests still correctly cover all TTY combinations (True/True, False/False, mixed) for _is_terminal_available().


60-88: Context manager tests still validate spinner start/stop behavior

Refactored with patch.object(...) blocks around _is_terminal_available and console.status maintain the same assertions: spinner starts/stops only when a terminal is available, and start_time is set in both console and non-console paths. Behavior is preserved.


90-205: Console vs non-console status and tick behavior remain well covered

All tests that patch _is_terminal_available for update_status, tick, elapsed time formatting, async integration, and message preservation still match the implementation branches (spinner path vs logging path). The expectations around _current_message and spinner.update call counts look consistent with the current LeaseAcquisitionSpinner logic.


238-336: Throttling tests align with new should_log condition

The throttling suite—first update logged, within-interval suppressed, after-interval logged, forced updates, multiple rapid updates, and “no throttling when console is available”—all exercise the new should_log logic in the logging branch. This gives strong regression protection for the refactor in update_status.

packages/jumpstarter-cli/jumpstarter_cli/create.py (1)

59-64: Documentation clearly introduces custom lease ID usage

The added example for --lease-id my-custom-lease-id integrates well into the existing help text and accurately reflects the new option.

packages/jumpstarter/jumpstarter/config/client.py (1)

197-212: Unable to verify create_lease signature extension without repository access

The review approves threading lease_id: str | None = None through to ClientService.CreateLease with proper decorator handling. However, verification of call sites, signature compatibility, and code style adherence could not be completed due to repository access failure. Manual verification is needed to confirm all callers handle the new optional parameter correctly and that the code meets Ruff formatting standards.

@bennyz bennyz force-pushed the custom-lease-name branch from e9a02db to 6d6c9fc Compare December 2, 2025 13:24
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.

1 participant