CloudNativeAI (CNAI) Model Registry
Relevant source files
The following files were used as context for generating this wiki page:
The CloudNativeAI (CNAI) Model Registry is a specialized component within Harbor designed to manage artificial intelligence models as standard OCI artifacts. This feature allows data scientists and DevOps engineers to store, version, and distribute machine learning models using the same robust infrastructure used for container images.
By treating models as artifacts, Harbor provides a unified interface for model governance, including vulnerability scanning, signed provenance, and metadata extraction. The registry supports specific CNAI-typed artifacts, enabling rich metadata visualization in the Harbor portal, such as model summaries and license details.
Sources: src/portal/src/app/base/project/repository/artifact/artifact-additions/summary/summary.component.ts:39, src/portal/src/i18n/lang/en-us-lang.json:841-845
Architecture and Artifact Processing
The CNAI system integrates into the Harbor artifact controller through a dedicated processor and parser. When an artifact with the CNAI media type is pushed to the registry, the cnai processor identifies the artifact type and invokes the parser to extract internal documentation and configuration.
Processing Workflow
The following diagram illustrates the lifecycle of a CNAI artifact from ingress to metadata rendering in the portal:
The CNAI processor ensures that AI-specific metadata is associated with the artifact as "additions." These additions are then accessible via the REST API for downstream consumers and the UI.
Sources: src/controller/artifact/processor/cnai/cnai.go, api/v2.0/swagger.yaml:915-925
API and Addition Links
CNAI artifacts leverage the Harbor "Additions" framework to provide supplementary data without bloating the primary manifest. These are exposed through specific endpoints that allow retrieval of localized data like documentation and licensing.
Supported Addition Types
Additions for CNAI models are categorized into several types, primarily accessed via the /projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/additions/{addition} endpoint.
| Addition Type | Description |
|---|---|
readme.md | The primary documentation for the model. |
license | Legal usage terms included within the model artifact. |
files | A manifest of all files contained within the model bundle. |
build_history | The provenance and layer history of the model artifact. |
Sources: api/v2.0/swagger.yaml:920-940, src/portal/src/i18n/lang/en-us-lang.json:841-843
Frontend Rendering and Logic
The Harbor Portal includes specific logic to handle the presentation of CNAI model artifacts. The SummaryComponent is responsible for fetching and displaying the readme.md addition, applying AI-specific formatting rules.
Metadata Parsing Logic
The portal applies a cleansing process to model documentation to ensure it renders correctly within the UI environment. This includes removing YAML front matter often found in AI model documentation (e.g., from Hugging Face or similar formats).
// Example of front matter removal in summary.component.ts
removeFrontMatter(content: string): string {
return content.replace(/^---[\s\S]*?---\s*/, '');
}
Error Handling for Models
The UI component implements specialized error handling for CNAI artifacts to improve user experience when metadata is missing or oversized.
- Status 404: When a CNAI artifact lacks a README, the portal displays a specific
MODEL_NO_READMEmessage. - Status 413: If the model metadata file is too large for the portal to process, a "file too large" warning is triggered.
Sources: src/portal/src/app/base/project/repository/artifact/artifact-additions/summary/summary.component.ts:48-55, src/portal/src/i18n/lang/en-us-lang.json:844-845
Model Registry Summary
The CNAI Model Registry extension transforms Harbor from a simple container registry into a comprehensive AI/ML artifact hub. By adhering to OCI standards while providing AI-specific parsing logic, it bridges the gap between traditional DevOps and modern Data Science workflows.
Key highlights include:
- Unified Management: AI models are managed alongside container images and Helm charts.
- Automated Documentation: Automatic extraction and rendering of
readme.mdandlicensefiles. - AI-Aware UI: Front matter stripping and model-specific empty states in the portal.
- Scalable Metadata: Utilization of the Additions API to handle large model metadata payloads.
Sources: src/portal/src/app/base/project/repository/artifact/artifact-additions/summary/summary.component.ts:48-64, api/v2.0/swagger.yaml:2085-2120, src/portal/src/i18n/lang/en-us-lang.json:841-845