Skip to content

[core] add model metadata parser to ome agent#172

Merged
slin1237 merged 1 commit into
mainfrom
pvc-storage-support-03
Jul 12, 2025
Merged

[core] add model metadata parser to ome agent#172
slin1237 merged 1 commit into
mainfrom
pvc-storage-support-03

Conversation

@slin1237
Copy link
Copy Markdown
Collaborator

@slin1237 slin1237 commented Jul 12, 2025

What type of PR is this?

/kind feature

What this PR does / why we need it:

This PR implements the model metadata extraction agent as part of OEP-0004 (PVC Storage Support). The new model-metadata agent enables OME to
extract metadata from models stored in Kubernetes PVCs without requiring the model to be downloaded or accessible via object storage.

Key changes:

  • Added new model-metadata agent to the ome-agent framework that can be run as a Kubernetes Job
  • Implemented metadata extraction using the existing hfutil/modelconfig parser for robust support of 20+ model types
  • Created internal business logic module following established ome-agent patterns
  • Added support for both BaseModel and ClusterBaseModel CRs with proper namespace handling
  • Implemented automatic capability inference (text-generation, vision, embeddings) based on model architecture

Architecture decisions:

  • The agent is designed to be invoked by the BaseModel controller as a Job with the PVC mounted
  • Uses command-line flags for parameters since it runs as a Job (not a long-running service)
  • Leverages existing model config parsing infrastructure for consistency and maintainability
  • Only updates CR fields that are not already set, preserving user-specified values

Which issue(s) this PR fixes:

Related to OEP-0004: PVC Storage Support implementation

Special notes for your reviewer:

  1. Configuration approach: Unlike other agents that read from static YAML config, this agent uses command-line flags because it's designed to be
    run as a Kubernetes Job with dynamic parameters from the BaseModel controller.

  2. Code organization: Following reviewer feedback, the implementation:

    • Uses pkg/hfutil/modelconfig instead of custom parsing logic
    • Follows the internal module pattern used by other agents (enigma, replica)
    • Maintains k8sclient.go in cmd/ome-agent as a shared utility
  3. Testing: Comprehensive unit tests cover config extraction, metadata parsing, and CR updates for both BaseModel and ClusterBaseModel
    scenarios.

  4. Files structure:

    • Agent wrapper: cmd/ome-agent/model_metadata_agent.go
    • Business logic: internal/ome-agent/model-metadata/
    • Config template: config/ome-agent/model-metadata.yaml

address

#163 #160

Does this PR introduce a user-facing change?

Add model-metadata agent to extract metadata from PVC-stored models for BaseModel and ClusterBaseModel CRs

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @slin1237, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a new model-metadata agent to the OME framework, designed to automatically extract crucial metadata from machine learning models stored in Kubernetes Persistent Volume Claims (PVCs). This enhancement is a key part of the OEP-0004 PVC Storage Support initiative, enabling OME to enrich BaseModel and ClusterBaseModel Custom Resources with details like model type, architecture, parameter count, and capabilities, without requiring the models to be downloaded or accessed via object storage.

Highlights

  • New Agent Introduction: I've added a new model-metadata agent to the ome-agent framework, specifically designed to run as a Kubernetes Job. This agent is a key component for enabling PVC Storage Support (OEP-0004).
  • Automated Metadata Extraction: The agent automatically extracts comprehensive metadata from machine learning models stored in Kubernetes PVCs. It leverages the robust hfutil/modelconfig parser, supporting over 20 model types, eliminating the need to download models for metadata retrieval.
  • CR Update Logic: It updates BaseModel and ClusterBaseModel Custom Resources with the extracted metadata. A crucial design choice is that it only populates fields that are not already set, preserving any user-specified values.
  • Capability Inference: The agent includes intelligent logic to infer model capabilities (e.g., text-generation, vision, embeddings) based on the model's architecture and type, enriching the CRs with valuable functional information.
  • Kubernetes Client Utility: A new shared Kubernetes client utility (k8sclient.go) has been introduced, providing a consistent way for ome-agent components to interact with the Kubernetes API.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a valuable model-metadata agent for extracting metadata from models stored in PVCs. The review focuses on improving robustness and maintainability by addressing a potential panic, removing duplicated code, and eliminating a redundant validation call.

Comment thread cmd/ome-agent/k8sclient.go
Comment thread internal/ome-agent/model-metadata/metadata.go Outdated
Comment thread internal/ome-agent/model-metadata/module.go
@slin1237 slin1237 force-pushed the pvc-storage-support-03 branch from d7ae3d3 to 49f3b79 Compare July 12, 2025 07:46
@slin1237 slin1237 merged commit 0fc82aa into main Jul 12, 2025
21 checks passed
@slin1237 slin1237 deleted the pvc-storage-support-03 branch July 15, 2025 03:03
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.

1 participant