Skip to content

Commit 14de02e

Browse files
committed
add model/load endpoint
Signed-off-by: Emily Casey <emily.casey@docker.com>
1 parent a8437d3 commit 14de02e

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.23.7
55
require (
66
github.com/containerd/containerd/v2 v2.0.4
77
github.com/containerd/platforms v1.0.0-rc.1
8-
github.com/docker/model-distribution v0.0.0-20250710123110-a633223e127e
8+
github.com/docker/model-distribution v0.0.0-20250724025158-b173151a7474
99
github.com/google/go-containerregistry v0.20.3
1010
github.com/jaypipes/ghw v0.16.0
1111
github.com/mattn/go-shellwords v1.0.12

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ github.com/docker/distribution v2.8.3+incompatible h1:AtKxIZ36LoNK51+Z6RpzLpddBi
3838
github.com/docker/distribution v2.8.3+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
3939
github.com/docker/docker-credential-helpers v0.8.2 h1:bX3YxiGzFP5sOXWc3bTPEXdEaZSeVMrFgOr3T+zrFAo=
4040
github.com/docker/docker-credential-helpers v0.8.2/go.mod h1:P3ci7E3lwkZg6XiHdRKft1KckHiO9a2rNtyFbZ/ry9M=
41-
github.com/docker/model-distribution v0.0.0-20250710123110-a633223e127e h1:qBkjP4A20f3RXvtstitIPiStQ4p+bK8xcjosrXLBQZ0=
42-
github.com/docker/model-distribution v0.0.0-20250710123110-a633223e127e/go.mod h1:dThpO9JoG5Px3i+rTluAeZcqLGw8C0qepuEL4gL2o/c=
41+
github.com/docker/model-distribution v0.0.0-20250724025158-b173151a7474 h1:F4MtfsvC/9/BMEjMQw8gku/hJ4xnXdMLnDE4z00Pcvw=
42+
github.com/docker/model-distribution v0.0.0-20250724025158-b173151a7474/go.mod h1:dThpO9JoG5Px3i+rTluAeZcqLGw8C0qepuEL4gL2o/c=
4343
github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
4444
github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
4545
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=

pkg/inference/models/manager.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ func (m *Manager) RebuildRoutes(allowedOrigins []string) {
120120
func (m *Manager) routeHandlers(allowedOrigins []string) map[string]http.HandlerFunc {
121121
handlers := map[string]http.HandlerFunc{
122122
"POST " + inference.ModelsPrefix + "/create": m.handleCreateModel,
123+
"POST " + inference.ModelsPrefix + "/load": m.handleLoadModel,
123124
"GET " + inference.ModelsPrefix: m.handleGetModels,
124125
"GET " + inference.ModelsPrefix + "/{name...}": m.handleGetModel,
125126
"DELETE " + inference.ModelsPrefix + "/{name...}": m.handleDeleteModel,
@@ -153,6 +154,15 @@ func (m *Manager) handleCreateModel(w http.ResponseWriter, r *http.Request) {
153154
return
154155
}
155156

157+
//if src := r.URL.Query().Get("fromSrc"); src != "" {
158+
// fmt.Println("IMPORTING")
159+
// if err := m.distributionClient.LoadModel(r.Context(), "emilycasey003/foo", r.Body, w); err != nil {
160+
// http.Error(w, err.Error(), http.StatusInternalServerError)
161+
// return
162+
// }
163+
// return
164+
//}
165+
156166
// Decode the request.
157167
var request ModelCreateRequest
158168
if err := json.NewDecoder(r.Body).Decode(&request); err != nil {
@@ -183,6 +193,20 @@ func (m *Manager) handleCreateModel(w http.ResponseWriter, r *http.Request) {
183193
}
184194
}
185195

196+
// handleLoadModel handles POST <inference-prefix>/models/load requests.
197+
func (m *Manager) handleLoadModel(w http.ResponseWriter, r *http.Request) {
198+
if m.distributionClient == nil {
199+
http.Error(w, "model distribution service unavailable", http.StatusServiceUnavailable)
200+
return
201+
}
202+
203+
if _, err := m.distributionClient.LoadModel(r.Body, w); err != nil {
204+
http.Error(w, err.Error(), http.StatusInternalServerError)
205+
return
206+
}
207+
return
208+
}
209+
186210
// handleGetModels handles GET <inference-prefix>/models requests.
187211
func (m *Manager) handleGetModels(w http.ResponseWriter, r *http.Request) {
188212
if m.distributionClient == nil {

0 commit comments

Comments
 (0)