Skip to content
This repository was archived by the owner on Jan 23, 2026. It is now read-only.

treewide: use str typed selector directly#353

Merged
NickCao merged 1 commit intomainfrom
selector-only
Mar 20, 2025
Merged

treewide: use str typed selector directly#353
NickCao merged 1 commit intomainfrom
selector-only

Conversation

@NickCao
Copy link
Copy Markdown
Collaborator

@NickCao NickCao commented Mar 17, 2025

Summary by CodeRabbit

  • Documentation

    • Updated descriptions and examples to use the term “selector” when configuring lease requests.
  • Refactor

    • Streamlined lease configuration by replacing the previous label-based approach with a simpler string-based selector.
  • Tests

    • Adjusted test examples to reflect the updated selector syntax for identifying testing targets.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 17, 2025

Walkthrough

This pull request standardizes lease acquisition by replacing the use of a dictionary-based filter (named “filter_labels”) with a string-based “selector”. The changes update documentation, examples, tests, client shell logic, and core lease-related modules. In doing so, functionality related to metadata filtering – including helper functions and the MetadataFilter class – has been removed, and method signatures have been updated accordingly. The overall control flow remains similar but now relies on a simplified selector mechanism for lease requests.

Changes

File(s) Change Summary
docs/source/cli/run-tests.md Updated documentation to replace "filter_labels" with "selector" in lease request instructions.
examples/soc-pytest/.../test_on_rpi4.py, packages/jumpstarter-driver-tftp/examples/tftp_test.py, packages/jumpstarter-testing/jumpstarter_testing/pytest.py Updated test classes: replaced filter_labels (dictionary) with a string-based selector for board targeting.
packages/jumpstarter-cli-client/jumpstarter_cli_client/client_shell.py, packages/jumpstarter-driver-dutlink/examples/dutlink.py Modified lease creation process: removed metadata filtering via MetadataFilter/selector_to_labels and now call lease methods directly with selector.
packages/jumpstarter-cli-client/jumpstarter_cli_client/common.py Removed the selector_to_labels function that converted a selector string into a dictionary.
packages/jumpstarter/jumpstarter/client/lease.py Changed the Lease class: replaced the metadata_filter attribute with a selector string and updated the lease creation logic and logs.
packages/jumpstarter/jumpstarter/common/__init__.py, packages/jumpstarter/jumpstarter/common/metadata.py Removed MetadataFilter from the public API and deleted its class declaration from the module.
packages/jumpstarter/jumpstarter/config/client.py Updated method signatures in ClientConfigV1Alpha1: replaced metadata_filter parameters with a selector parameter across lease and lease request methods (synchronous and asynchronous).

Sequence Diagram(s)

sequenceDiagram
    participant TR as Test Resource
    participant TS as Test Suite
    participant CS as Client Shell
    participant CC as Client Config
    participant LS as Lease Service

    TR->>TS: Initiate lease request (using selector)
    TS->>CS: Pass selector parameter to client shell
    CS->>CC: Call lease(selector, lease_name)
    CC->>LS: Process lease request with selector
    LS-->>CC: Return lease confirmation
    CC-->>CS: Forward lease details
    CS-->>TS: Confirm lease granted
Loading

Poem

I’m a rabbit in the codey glen,
Hopping through changes now and then.
From filters to selectors, light and free,
Metadata’s gone—simplicity is key.
With a skip and a hop, our tests delight,
Bounding into the future, coding bright! 🐰✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c119d30 and b9e3528.

📒 Files selected for processing (11)
  • docs/source/cli/run-tests.md (1 hunks)
  • examples/soc-pytest/jumpstarter_example_soc_pytest/test_on_rpi4.py (1 hunks)
  • packages/jumpstarter-cli-client/jumpstarter_cli_client/client_shell.py (2 hunks)
  • packages/jumpstarter-cli-client/jumpstarter_cli_client/common.py (0 hunks)
  • packages/jumpstarter-driver-dutlink/examples/dutlink.py (1 hunks)
  • packages/jumpstarter-driver-tftp/examples/tftp_test.py (1 hunks)
  • packages/jumpstarter-testing/jumpstarter_testing/pytest.py (3 hunks)
  • packages/jumpstarter/jumpstarter/client/lease.py (3 hunks)
  • packages/jumpstarter/jumpstarter/common/__init__.py (1 hunks)
  • packages/jumpstarter/jumpstarter/common/metadata.py (0 hunks)
  • packages/jumpstarter/jumpstarter/config/client.py (6 hunks)
💤 Files with no reviewable changes (2)
  • packages/jumpstarter/jumpstarter/common/metadata.py
  • packages/jumpstarter-cli-client/jumpstarter_cli_client/common.py
🧰 Additional context used
🧬 Code Definitions (3)
packages/jumpstarter-testing/jumpstarter_testing/pytest.py (3)
packages/jumpstarter/jumpstarter/common/utils.py (1) (1)
  • env (64-73)
packages/jumpstarter/jumpstarter/config/client.py (3) (3)
  • ClientConfigV1Alpha1 (37-308)
  • load (254-259)
  • lease (64-67)
packages/jumpstarter/jumpstarter/config/exporter.py (1) (1)
  • load (106-109)
packages/jumpstarter/jumpstarter/common/__init__.py (1)
packages/jumpstarter/jumpstarter/common/metadata.py (1) (1)
  • Metadata (8-14)
packages/jumpstarter/jumpstarter/config/client.py (1)
packages/jumpstarter/jumpstarter/client/base.py (1) (1)
  • call (36-46)
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: e2e
  • GitHub Check: pytest-matrix (3.13)
  • GitHub Check: pytest-matrix (3.12)
  • GitHub Check: pytest-matrix (3.11)
  • GitHub Check: build-and-push-image (jumpstarter-dev/jumpstarter-dev .devfile/Containerfile)
  • GitHub Check: build-and-push-image (jumpstarter-dev/jumpstarter Dockerfile)
  • GitHub Check: build-and-push-image (jumpstarter-dev/jumpstarter-devspace .devfile/Containerfile.client)
  • GitHub Check: build-and-push-image (jumpstarter-dev/jumpstarter-utils Dockerfile.utils)
🔇 Additional comments (25)
docs/source/cli/run-tests.md (1)

49-49: Documentation updated to reflect API change.

The documentation has been correctly updated to use "selector" instead of the previous "filter_labels" terminology, which aligns with the codebase changes.

packages/jumpstarter-driver-dutlink/examples/dutlink.py (1)

12-12: Example updated to use string-based selector.

The commented example code has been properly updated to use the new selector-based approach instead of the previous MetadataFilter class, maintaining the same functionality with a simpler syntax.

examples/soc-pytest/jumpstarter_example_soc_pytest/test_on_rpi4.py (1)

17-17: Test class updated to use string-based selector.

The TestResource class has been correctly updated to use the new selector attribute with a string value instead of the dictionary-based filter_labels, which aligns with the PR objectives.

packages/jumpstarter-driver-tftp/examples/tftp_test.py (1)

11-11: Test class updated to use string-based selector.

The TestResource class has been properly updated to use the string-based selector attribute, which is consistent with the changes made across the codebase.

packages/jumpstarter-cli-client/jumpstarter_cli_client/client_shell.py (3)

6-6: Simplified import aligned with new selector approach.

The import statement has been updated to reflect the removal of the MetadataFilter and selector_to_labels function, now only importing the necessary options.


15-15: Function signature now explicitly types selector as a string.

The parameter type annotation has been added to clearly indicate that selector is expected to be a string type, improving type safety.


20-20: Simplified lease acquisition with direct selector parameter.

The code now directly passes the string selector to the lease method instead of first converting it to labels via selector_to_labels and then creating a MetadataFilter. This simplification makes the code more concise and maintainable.

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

21-21: Streamlined imports following MetadataFilter removal.

The import line has been simplified to reflect the codebase-wide removal of the MetadataFilter class, keeping only the necessary imports.


34-34: Updated Lease class to use string selector instead of MetadataFilter.

The attribute has been changed from a complex MetadataFilter object to a simple string selector, which aligns with the PR objective of using string typed selectors directly.


56-56: Updated logging to reference the new selector attribute.

Debug logging statement has been updated to use the self.selector instead of the previous metadata filter, maintaining proper logging information while reflecting the new implementation.


60-61: Simplified lease creation by passing selector directly.

The CreateLease call now directly uses the string selector instead of constructing one from metadata filter labels, reducing code complexity while maintaining the same functionality.


64-64: Updated lease creation info logging to use selector attribute.

Info logging statement has been updated to reference the new self.selector field, ensuring consistency in the logging throughout the lease lifecycle.

packages/jumpstarter/jumpstarter/common/__init__.py (2)

1-1: Removed MetadataFilter from import statement.

The import statement has been simplified to only import Metadata, removing the now unused MetadataFilter class, which aligns with the PR's objective of transitioning to string selectors.


4-4: Removed MetadataFilter from all exports.

MetadataFilter has been removed from the __all__ list, correctly updating the module's public API to reflect the removal of this class from the codebase.

packages/jumpstarter-testing/jumpstarter_testing/pytest.py (5)

21-22: Updated documentation to reference selector instead of filter labels.

The documentation has been updated to mention "selector annotation" instead of the previous filter labels, maintaining consistency with the new implementation approach.


35-35: Simplified example code with string selector.

The example code now uses a string selector ("board=rpi4") instead of the previous dictionary-based filter, making it more concise and easier to understand.


51-51: Changed class variable type from dictionary to string.

The class variable has been updated from filter_labels: ClassVar[dict[str, str]] to selector: ClassVar[str], properly reflecting the transition to string-based selectors.


59-59: Updated attribute reference in client fixture.

The code now correctly references the new selector attribute instead of the previous filter_labels, ensuring the fixture works with the new implementation.


61-61: Updated lease acquisition to use string selector.

The lease creation now directly uses the string selector instead of creating a metadata filter, completing the transition to the new approach.

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

64-67: Simplification of API by using string-based selector.

The method signature has been updated to use a string-based selector instead of the more complex MetadataFilter class, aligning with the PR objective. The default value of None for the selector parameter maintains backward compatibility.


82-84: String-based selector simplifies the request_lease API.

The method signature has been updated consistently to use a string-based selector. Unlike the lease method, this parameter doesn't have a default value, suggesting that a selector is required when requesting a lease.


147-150: Consistent parameter update in request_lease_async method.

The method signature has been updated to accept a string-based selector instead of a MetadataFilter object, maintaining consistency with the other lease-related method changes.


159-160: Updated Lease constructor with string-based selector.

The Lease constructor call has been updated to use the new selector parameter, consistent with the parameter changes in the method signature.


186-188: Simplified parameter type in lease_async method.

The method signature has been updated to use a string-based selector instead of a MetadataFilter object, consistent with the changes in other lease-related methods.


202-203: Updated Lease constructor in lease_async consistent with parameter changes.

The Lease constructor call in the context manager has been updated to use the selector parameter, maintaining consistency with the method signature changes.

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@netlify
Copy link
Copy Markdown

netlify Bot commented Mar 17, 2025

Deploy Preview for jumpstarter-docs ready!

Name Link
🔨 Latest commit b9e3528
🔍 Latest deploy log https://app.netlify.com/sites/jumpstarter-docs/deploys/67dc25c9cdfac00008637489
😎 Deploy Preview https://deploy-preview-353--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 site configuration.

@NickCao NickCao marked this pull request as ready for review March 20, 2025 14:28
@NickCao NickCao merged commit d4c2c76 into main Mar 20, 2025
18 checks passed
@NickCao NickCao deleted the selector-only branch March 20, 2025 14:41
@mangelajo mangelajo added this to the 0.6.0 milestone May 8, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants