Skip to content

Commit 0a3f3a1

Browse files
14pankajhteeyeohbharagha
authored
Minor updates (open-edge-platform#1248)
Co-authored-by: Hoong Tee, Yeoh <[email protected]> Co-authored-by: Raghu Bhat <[email protected]>
1 parent 1b8874f commit 0a3f3a1

File tree

12 files changed

+152
-133
lines changed

12 files changed

+152
-133
lines changed
Lines changed: 13 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,20 @@
1-
# Model Download Microservice Overview
1+
# Model Download Microservice
22

3-
The Model Download Microservice provides a unified solution for downloading AI/ML models from various model hubs while ensuring consistency and simplicity across applications. This service acts as a centralized model management system that handles model downloads, storage, and optional format conversions.
3+
The Model Download Microservice offers a streamlined approach for acquiring AI/ML models from multiple model hubs, promoting consistency and ease of use across different applications. It serves as a centralized system for managing model downloads, storage, and optional format conversions.
44

5-
## Architecture
5+
Below, you'll find links to detailed documentation to help you get started, configure, and deploy the microservice.
66

7-
The diagram below illustrates the high-level architecture of the Model Download Microservice, showcasing its core components and their interactions with external systems.
7+
## Documentation
88

9-
<p align="center">
10-
<img src="./docs/user-guide/images/architecture.png" alt="Architecture" />
11-
</p>
9+
- **Overview**
10+
- [Overview](docs/user-guide/Overview.md): A high-level introduction to the microservice.
1211

13-
## Components
12+
- **Getting Started**
13+
- [Get Started](docs/user-guide/get-started.md): Step-by-step guide to getting started with the microservice.
14+
- [System Requirements](docs/user-guide/system-requirements.md): Hardware and software requirements for running the microservice.
1415

15-
The service follows a plugin-based microservice architecture with the following key components:
16+
- **Deployment**
17+
- [How to Build from Source](docs/user-guide/build-from-source.md): Instructions for building the microservice from source code.
1618

17-
### Core Components
18-
19-
1. **FastAPI Service Layer**
20-
- **Description**: The FastAPI Service Layer serves as the primary entry point for all client interactions. It exposes a RESTful API for downloading, converting, and managing models.
21-
- **Responsibilities**:
22-
- Provides RESTful API endpoints for all service operations.
23-
- Handles incoming request validation, serialization, and routing to the appropriate components.
24-
- Generates and serves OpenAPI (Swagger) documentation for clear, interactive API specifications.
25-
26-
2. **Model Manager**
27-
- **Description**: The Model Manager is the central orchestration component that directs the model download and conversion processes. It acts as the brain of the service, coordinating actions between the API layer and the plugin system.
28-
- **Responsibilities**:
29-
- Orchestrates end-to-end model download and conversion workflows.
30-
- Manages model storage, including organizing file paths and handling caching.
31-
- Interfaces with the Plugin Registry to delegate tasks to the appropriate plugins.
32-
33-
3. **Plugin Registry**
34-
- **Description**: The Plugin Registry is responsible for the discovery, registration, and management of all available plugins. It provides a flexible mechanism for extending the service's capabilities without modifying the core application logic.
35-
- **Responsibilities**:
36-
- Dynamically discovers and registers plugins at startup.
37-
- Manages the lifecycle of each plugin.
38-
- Provides a consistent abstraction layer that decouples the Model Manager from concrete plugin implementations.
39-
40-
### Plugin System
41-
42-
The service's functionality is extended through a modular plugin system that handles interactions with different model sources and conversion tasks.
43-
44-
**Model Hub Plugins:**
45-
- **HuggingFace Hub Plugin**: Manages model downloads from the Hugging Face Hub, including handling authentication for private or gated models.
46-
- **Ollama Hub Plugin**: Interfaces with Ollama to pull and manage models from the Ollama model library.
47-
- **Ultralytics Hub Plugin**: Downloads computer vision models, such as YOLO, from the Ultralytics framework.
48-
49-
**Conversion Plugins:**
50-
- **OpenVINO Model Conversion Plugin**: Provides functionality to convert downloaded models (e.g., from Hugging Face) into the OpenVINO™ Intermediate Representation (IR) format for optimized inference on Intel hardware.
51-
52-
### Storage
53-
54-
- **Downloaded Models Storage**: This component represents the physical storage location for all downloaded and converted models. It is a configurable file system path that acts as a centralized repository and cache.
55-
- **Responsibilities**:
56-
- Provides a persistent location for storing model files.
57-
- Enables caching to avoid redundant downloads of the same model.
58-
- Organizes models in a structured directory format for easy access.
59-
60-
## Key Features
61-
62-
- **Multi-Hub Support**: Download models from multiple sources (HuggingFace, Ollama, Ultralytics)
63-
- **Format Conversion**: Convert models to OpenVINO format for optimization
64-
- **Parallel Downloads**: Optional concurrent model downloads
65-
- **Precision Control**: Support for various model precisions (INT8, FP16, FP32)
66-
- **Device Targeting**: Optimization for different compute devices (CPU, GPU)
67-
- **Caching**: Configurable model caching for improved performance
68-
69-
## Integration
70-
71-
The service can be integrated into applications through:
72-
- REST API calls
73-
- Docker container deployment
74-
- Docker Compose orchestration
75-
76-
## Use Cases
77-
78-
This microservice is ideal for:
79-
- Edge AI applications requiring model downloads
80-
- Development and testing environments
81-
- Sample applications demonstrating AI capabilities
82-
- Automated model deployment pipelines
83-
84-
## Limitations
85-
86-
This service is not intended to replace full model registry solutions and has the following limitations:
87-
- Basic model versioning
88-
- Limited model metadata management
89-
- No built-in model serving capabilities
90-
91-
## Supporting Resources
92-
- [**Get Started Guide**](./docs/user-guide/get-started.md)
93-
- [**API Reference**](./docs/user-guide/api-docs/openapi.yaml)
19+
- **Release Notes**
20+
- [Release Notes](docs/user-guide/release-notes.md): Information on the latest updates, improvements, and bug fixes.

microservices/model-download/chart/Chart.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ apiVersion: v2
22
name: model-download
33
description: A Helm chart for deploying the model-download FastAPI microservice
44
type: application
5-
version: 1.0.0
6-
appVersion: "1.0.0"
5+
version: 1.0.1
6+
appVersion: "1.0.1"

microservices/model-download/chart/templates/deployment.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ spec:
1818
fsGroup: 1001
1919
runAsUser: 1001
2020
runAsGroup: 1001
21-
allowPrivilegeEscalation: false
2221
containers:
2322
- name: model-download
2423
image: "{{ .Values.modeldownload.image.registry }}model-download:{{ .Values.modeldownload.image.tag }}"
@@ -51,6 +50,8 @@ spec:
5150
volumeMounts:
5251
- name: models
5352
mountPath: /opt/models
53+
securityContext:
54+
allowPrivilegeEscalation: false
5455
volumes:
5556
- name: models
5657
persistentVolumeClaim:

microservices/model-download/chart/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ modeldownload:
1111
name: model-download
1212
image:
1313
registry: "" #provide your registry info here, replace 'registry' with actual registry URL
14-
tag: 1.0.0
14+
tag: 1.0.1
1515
pullPolicy: IfNotPresent
1616

1717
readinessProbe:

microservices/model-download/docker/Dockerfile

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
# ---- Stage 1: Build dependencies ----
55
FROM python:3.11-slim AS python-base
66

7-
# Add uv to PATH
8-
ENV PATH="/opt/.local/bin:$PATH"
9-
107
# Set the working directory in the container
118
WORKDIR /opt
129

@@ -21,7 +18,7 @@ RUN apt-get update && apt-get install -y \
2118
rm -rf /var/lib/apt/lists/*
2219

2320
# Install uv
24-
RUN curl -LsSf https://astral.sh/uv/install.sh | UV_INSTALL_DIR=/opt/.local/bin sh
21+
RUN pip install uv==0.9.10
2522

2623
# Copy project files
2724
COPY pyproject.toml uv.lock /opt/
@@ -53,7 +50,6 @@ RUN groupadd -g ${GID} appuser && \
5350
# Copy installed dependencies from python-base
5451
COPY --from=python-base /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages
5552
COPY --from=python-base /usr/local/bin /usr/local/bin
56-
COPY --from=python-base /opt/.local/bin/uv /usr/local/bin/uv
5753

5854
COPY src /opt/src
5955
COPY scripts /opt/scripts

microservices/model-download/docker/entrypoint.sh

Lines changed: 30 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -103,52 +103,48 @@ while [[ $# -gt 0 ]]; do
103103
esac
104104
done
105105

106-
# Define all available plugins in the application
106+
107107
AVAILABLE_PLUGINS=("openvino" "huggingface" "ollama" "ultralytics")
108+
PLUGINS_LOWER=$(echo "$PLUGINS" | tr '[:upper:]' '[:lower:]')
108109

109-
# Install plugin-specific dependencies
110+
# Determine which plugins to activate
110111
print_header "Installing plugin dependencies"
111-
if [ "$PLUGINS" = "all" ]; then
112+
if [ "$PLUGINS_LOWER" = "all" ]; then
113+
PLUGIN_LIST=("${AVAILABLE_PLUGINS[@]}")
112114
print_info "Installing ALL plugins"
113-
114-
# Install dependencies for all available plugins
115-
for plugin in "${AVAILABLE_PLUGINS[@]}"; do
116-
install_dependencies "$plugin"
117-
done
118-
119-
echo "ACTIVATED_PLUGINS=all" > "$PLUGINS_ENV_FILE"
120-
print_success "All plugins are activated"
121115
else
122-
# Split comma-separated plugins and install dependencies for each
123-
IFS=',' read -ra PLUGIN_LIST <<< "$PLUGINS"
124-
echo "ACTIVATED_PLUGINS=$PLUGINS" > "$PLUGINS_ENV_FILE"
125-
126-
for plugin in "${PLUGIN_LIST[@]}"; do
127-
install_dependencies "$plugin"
116+
# Split comma-separated plugins into array and convert to lowercase
117+
IFS=',' read -ra PLUGIN_LIST_RAW <<< "$PLUGINS_LOWER"
118+
PLUGIN_LIST=()
119+
for plugin in "${PLUGIN_LIST_RAW[@]}"; do
120+
# Trim whitespace and add to array
121+
plugin=$(echo "$plugin" | xargs)
122+
PLUGIN_LIST+=("$plugin")
128123
done
129-
130-
print_success "Activated plugins: $PLUGINS"
131124
fi
132125

126+
# Install plugin-specific dependencies
127+
for plugin in "${PLUGIN_LIST[@]}"; do
128+
install_dependencies "$plugin"
129+
done
130+
131+
# Save activated plugins to env file
132+
echo "ACTIVATED_PLUGINS=$PLUGINS" > "$PLUGINS_ENV_FILE"
133+
print_success "Activated plugins: ${PLUGIN_LIST[*]}"
134+
135+
# Build the list of --extra arguments from the activated plugins
136+
EXTRA_ARGS=()
137+
for plugin in "${PLUGIN_LIST[@]}"; do
138+
EXTRA_ARGS+=(--extra "$plugin")
139+
done
140+
133141
# Sync dependencies using UV
134142
print_header "Syncing dependencies with UV"
135143
cd /opt
136144
print_info "Installing dependencies from pyproject.toml..."
137145

138-
# Add UV and ollama to PATH if it's not already there
139-
export PATH="/usr/local/bin:$HOME/.local/bin:/opt/bin/:$PATH"
140-
141-
# Build the list of --extra arguments from the activated plugins
142-
EXTRA_ARGS=()
143-
if [ "$PLUGINS" = "all" ]; then
144-
for plugin in "${AVAILABLE_PLUGINS[@]}"; do
145-
EXTRA_ARGS+=(--extra "$plugin")
146-
done
147-
else
148-
for plugin in "${PLUGIN_LIST[@]}"; do
149-
EXTRA_ARGS+=(--extra "$plugin")
150-
done
151-
fi
146+
# ollama to PATH if it's not already there
147+
export PATH="/opt/bin/:$PATH"
152148

153149
if uv sync "${EXTRA_ARGS[@]}"; then
154150
print_success "Dependencies synced successfully"
@@ -174,4 +170,4 @@ if [ "$START_SERVICE" = true ]; then
174170
else
175171
print_warning "Service start skipped due to --no-start flag"
176172
exec "$@"
177-
fi
173+
fi
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
## Model Download
2+
3+
The Model Download Microservice provides a unified solution for downloading AI/ML models from various model hubs while ensuring consistency and simplicity across applications. This service acts as a centralized model management system that handles model downloads, storage, and optional format conversions.
4+
5+
6+
## Architecture
7+
8+
The diagram below illustrates the high-level architecture of the Model Download Microservice, showcasing its core components and their interactions with external systems.
9+
10+
<p align="center">
11+
<img src="./images/architecture.png" alt="Architecture" />
12+
</p>
13+
14+
## Components
15+
16+
The service follows a plugin-based microservice architecture with the following key components:
17+
18+
### Core Components
19+
20+
1. **FastAPI Service Layer**
21+
- **Description**: The FastAPI Service Layer serves as the primary entry point for all client interactions. It exposes a RESTful API for downloading, converting, and managing models.
22+
- **Responsibilities**:
23+
- Provides RESTful API endpoints for all service operations.
24+
- Handles incoming request validation, serialization, and routing to the appropriate components.
25+
- Generates and serves OpenAPI (Swagger) documentation for clear, interactive API specifications.
26+
27+
2. **Model Manager**
28+
- **Description**: The Model Manager is the central orchestration component that directs the model download and conversion processes. It acts as the brain of the service, coordinating actions between the API layer and the plugin system.
29+
- **Responsibilities**:
30+
- Orchestrates end-to-end model download and conversion workflows.
31+
- Manages model storage, including organizing file paths and handling caching.
32+
- Interfaces with the Plugin Registry to delegate tasks to the appropriate plugins.
33+
34+
3. **Plugin Registry**
35+
- **Description**: The Plugin Registry is responsible for the discovery, registration, and management of all available plugins. It provides a flexible mechanism for extending the service's capabilities without modifying the core application logic.
36+
- **Responsibilities**:
37+
- Dynamically discovers and registers plugins at startup.
38+
- Manages the lifecycle of each plugin.
39+
- Provides a consistent abstraction layer that decouples the Model Manager from concrete plugin implementations.
40+
41+
### Plugin System
42+
43+
The service's functionality is extended through a modular plugin system that handles interactions with different model sources and conversion tasks.
44+
45+
**Model Hub Plugins:**
46+
- **HuggingFace Hub Plugin**: Manages model downloads from the Hugging Face Hub, including handling authentication for private or gated models.
47+
- **Ollama Hub Plugin**: Interfaces with Ollama to pull and manage models from the Ollama model library.
48+
- **Ultralytics Hub Plugin**: Downloads computer vision models, such as YOLO, from the Ultralytics framework.
49+
50+
**Conversion Plugins:**
51+
- **OpenVINO Model Conversion Plugin**: Provides functionality to convert downloaded models (e.g., from Hugging Face) into the OpenVINO™ Intermediate Representation (IR) format for optimized inference on Intel hardware.
52+
53+
### Storage
54+
55+
- **Downloaded Models Storage**: This component represents the physical storage location for all downloaded and converted models. It is a configurable file system path that acts as a centralized repository and cache.
56+
- **Responsibilities**:
57+
- Provides a persistent location for storing model files.
58+
- Enables caching to avoid redundant downloads of the same model.
59+
- Organizes models in a structured directory format for easy access.
60+
61+
## Key Features
62+
63+
- **Multi-Hub Support**: Download models from multiple sources (HuggingFace, Ollama, Ultralytics)
64+
- **Format Conversion**: Convert models to OpenVINO format for optimization
65+
- **Parallel Downloads**: Optional concurrent model downloads
66+
- **Precision Control**: Support for various model precisions (INT8, FP16, FP32)
67+
- **Device Targeting**: Optimization for different compute devices (CPU, GPU)
68+
- **Caching**: Configurable model caching for improved performance
69+
70+
## Integration
71+
72+
The service can be integrated into applications through:
73+
- REST API calls
74+
- Docker container deployment
75+
- Docker Compose orchestration
76+
77+
## Use Cases
78+
79+
This microservice is ideal for:
80+
- Edge AI applications requiring model downloads
81+
- Development and testing environments
82+
- Sample applications demonstrating AI capabilities
83+
- Automated model deployment pipelines
84+
85+
## Limitations
86+
87+
This service is not intended to replace full model registry solutions and has the following limitations:
88+
- Basic model versioning
89+
- Limited model metadata management
90+
- No built-in model serving capabilities
91+
92+
## Supporting Resources
93+
- [**Get Started Guide**](./get-started.md)
94+
- [**API Reference**](./api-docs/openapi.yaml)

microservices/model-download/docs/user-guide/deploy-with-helm.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ kubectl get services -n <your-namespace>
101101

102102
### Step 6: Access the Application
103103

104-
Open the application swagger documentation in a browser at `http://\<node-ip\>:\<node-port\>/api/v1/docs`
104+
Open the application swagger documentation in a browser at `http://<node-ip>:<node-port>/api/v1/docs`
105105

106106
### Step 7: Uninstall Helm chart
107107

microservices/model-download/docs/user-guide/get-started.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ curl -X POST "http://<host-ip>:8200/api/v1/models/download?download_path=ovms_mo
154154
"is_ovms": true,
155155
"config": {
156156
"precision": "fp32",
157-
"device": "cpu",
157+
"device": "CPU",
158158
"cache_size": 10
159159
}
160160
}

microservices/model-download/src/api/main.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ async def download_models(
132132
hub=model.hub,
133133
output_dir=model_download_path,
134134
plugin_name=model.hub,
135+
model_type=model.type,
135136
)
136137

137138
# Add to job_ids for response
@@ -176,7 +177,8 @@ async def download_models(
176177
model_name=model.name,
177178
hub=model.hub,
178179
output_dir=convert_output_dir,
179-
plugin_name="openvino"
180+
plugin_name="openvino",
181+
model_type=model.type,
180182
)
181183

182184
# Add to job_ids for response

0 commit comments

Comments
 (0)