Skip to content

feat: Add updated ModelRegistry kinds #2405

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 29, 2025
Merged

feat: Add updated ModelRegistry kinds #2405

merged 1 commit into from
May 29, 2025

Conversation

myakove
Copy link
Collaborator

@myakove myakove commented May 29, 2025

Summary by CodeRabbit

  • New Features
    • Introduced new Model Registry resource types for enhanced integration with OpenDataHub, supporting expanded configuration options and improved serialization.
  • Deprecation Notice
    • Added a warning that the existing model registry module will be removed in the next release; users are advised to use the new resource types.
  • Chores
    • Updated internal references to support the new API group for platform components.

Copy link

coderabbitai bot commented May 29, 2025

Walkthrough

This update introduces two new ModelRegistry classes in separate modules, each corresponding to different OpenDataHub API groups. The original model_registry.py now issues a deprecation warning, guiding users to the new modules. Additionally, a new API group constant is added to the Resource class to support the new resource type.

Changes

Files Change Summary
ocp_resources/model_registry.py Reordered imports; added a deprecation warning advising users to use new modules for ModelRegistry.
ocp_resources/model_registry_components_platform_opendatahub_io.py Introduced new ModelRegistry class for the components.platform.opendatahub.io API group.
ocp_resources/model_registry_modelregistry_opendatahub_io.py Introduced new ModelRegistry class for the modelregistry.opendatahub.io API group.
ocp_resources/resource.py Added COMPONENTS_PLATFORM_OPENDATAHUB_IO constant to ApiGroup inner class of Resource.

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 11dbc57 and 442a1bc.

⛔ Files ignored due to path filters (2)
  • class_generator/schema/__resources-mappings.json is excluded by !class_generator/schema/**
  • class_generator/schema/_definitions.json is excluded by !class_generator/schema/**
📒 Files selected for processing (4)
  • ocp_resources/model_registry.py (1 hunks)
  • ocp_resources/model_registry_components_platform_opendatahub_io.py (1 hunks)
  • ocp_resources/model_registry_modelregistry_opendatahub_io.py (1 hunks)
  • ocp_resources/resource.py (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
ocp_resources/model_registry.py (2)
ocp_resources/exceptions.py (1)
  • MissingRequiredArgumentError (5-10)
ocp_resources/resource.py (1)
  • NamespacedResource (1298-1408)
ocp_resources/model_registry_modelregistry_opendatahub_io.py (3)
ocp_resources/resource.py (4)
  • NamespacedResource (1298-1408)
  • ApiGroup (314-415)
  • to_dict (580-584)
  • to_dict (1406-1408)
ocp_resources/exceptions.py (1)
  • MissingRequiredArgumentError (5-10)
ocp_resources/model_registry.py (2)
  • ModelRegistry (17-96)
  • to_dict (65-94)
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: can-be-merged
  • GitHub Check: can-be-merged
  • GitHub Check: tox
  • GitHub Check: python-module-install
  • GitHub Check: conventional-title
🔇 Additional comments (7)
ocp_resources/resource.py (1)

328-328: LGTM! Properly formatted API group constant.

The new API group constant follows the established naming convention and is correctly placed in alphabetical order within the ApiGroup class.

ocp_resources/model_registry.py (1)

4-14: Well-implemented deprecation warning.

The deprecation warning is properly structured with:

  • Clear message about module removal timeline
  • Specific guidance on migration paths to the new modules
  • Correct use of DeprecationWarning category and stacklevel=2 for proper attribution

This follows best practices for deprecating modules while providing users with a clear migration path.

ocp_resources/model_registry_components_platform_opendatahub_io.py (2)

9-15: Verify resource scope: Resource vs NamespacedResource inheritance.

This ModelRegistry class inherits from Resource (cluster-scoped), while the other ModelRegistry class in model_registry_modelregistry_opendatahub_io.py inherits from NamespacedResource. Please verify that the components.platform.opendatahub.io API group resources are indeed intended to be cluster-scoped rather than namespace-scoped.


36-48: LGTM! Proper spec construction with camelCase mapping.

The to_dict method correctly:

  • Calls the parent method
  • Only constructs spec when not using external yaml/dict
  • Maps snake_case parameters to camelCase spec fields (dev_flagsdevFlags, registries_namespaceregistriesNamespace)
  • Uses proper None checks before adding optional fields

This follows Kubernetes API conventions.

ocp_resources/model_registry_modelregistry_opendatahub_io.py (3)

16-27: Enhanced parameter list with improved type annotations.

The constructor properly uses modern Python type annotations (dict[str, Any] | None instead of Optional[Dict[str, Any]]) and adds the new oauth_proxy parameter for OpenShift OAuth proxy configuration.


77-94: Improved None checking logic.

The conditional checks use is not None instead of truthiness checks, which is an improvement over the original implementation in model_registry.py. This correctly handles cases where 0 or empty collections might be valid values for optional parameters.

For example, downgrade_db_schema_version of 0 would now be properly included in the spec, whereas the original truthiness check would have skipped it.


89-91: LGTM! Proper camelCase mapping for oauth_proxy.

The mapping from oauth_proxy (snake_case parameter) to oauthProxy (camelCase spec field) follows Kubernetes API conventions correctly.

✨ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate sequence diagram to generate a sequence diagram of the changes in 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.

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.

@redhat-qe-bot1
Copy link

Report bugs in Issues

The following are automatically added:

  • Add reviewers from OWNER file (in the root of the repository) under reviewers section.
  • Set PR size label.
  • New issue is created for the PR. (Closed when PR is merged/closed)
  • Run pre-commit if .pre-commit-config.yaml exists in the repo.

Available user actions:

  • To mark PR as WIP comment /wip to the PR, To remove it from the PR comment /wip cancel to the PR.
  • To block merging of PR comment /hold, To un-block merging of PR comment /hold cancel.
  • To mark PR as verified comment /verified to the PR, to un-verify comment /verified cancel to the PR.
    verified label removed on each new commit push.
  • To cherry pick a merged PR comment /cherry-pick <target branch to cherry-pick to> in the PR.
    • Multiple target branches can be cherry-picked, separated by spaces. (/cherry-pick branch1 branch2)
    • Cherry-pick will be started when PR is merged
  • To build and push container image command /build-and-push-container in the PR (tag will be the PR number).
    • You can add extra args to the Podman build command
      • Example: /build-and-push-container --build-arg OPENSHIFT_PYTHON_WRAPPER_COMMIT=<commit_hash>
  • To add a label by comment use /<label name>, to remove, use /<label name> cancel
  • To assign reviewers based on OWNERS file use /assign-reviewers
  • To check if PR can be merged use /check-can-merge
  • to assign reviewer to PR use /assign-reviewer @<reviewer>

PR will be approved when the following conditions are met:

  • /approve from one of the approvers.
  • Minimum number of required /lgtm (0) is met.
Approvers and Reviewers
  • Approvers:

    • myakove
    • rnetser
  • Reviewers:

    • dbasunag
    • myakove
    • rnetser
Supported /retest check runs
  • /retest tox: Retest tox
  • /retest python-module-install: Retest python-module-install
  • /retest conventional-title: Retest conventional-title
  • /retest all: Retest all
Supported labels
  • hold
  • verified
  • wip
  • lgtm
  • approve

@myakove
Copy link
Collaborator Author

myakove commented May 29, 2025

/verified
/approve

@myakove myakove merged commit 013f849 into main May 29, 2025
7 checks passed
@myakove myakove deleted the ModelRegistry branch May 29, 2025 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants