Skip to content

Commit 4215c12

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

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ 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-20250724035854-a9454ee7284c
9+
github.com/elastic/go-sysinfo v1.15.3
910
github.com/google/go-containerregistry v0.20.3
11+
github.com/gpustack/gguf-parser-go v0.14.1
1012
github.com/jaypipes/ghw v0.16.0
1113
github.com/mattn/go-shellwords v1.0.12
1214
github.com/opencontainers/go-digest v1.0.0
@@ -29,13 +31,11 @@ require (
2931
github.com/docker/cli v27.5.0+incompatible // indirect
3032
github.com/docker/distribution v2.8.3+incompatible // indirect
3133
github.com/docker/docker-credential-helpers v0.8.2 // indirect
32-
github.com/elastic/go-sysinfo v1.15.3 // indirect
3334
github.com/elastic/go-windows v1.0.2 // indirect
3435
github.com/felixge/httpsnoop v1.0.4 // indirect
3536
github.com/go-logr/logr v1.4.2 // indirect
3637
github.com/go-logr/stdr v1.2.2 // indirect
3738
github.com/go-ole/go-ole v1.2.6 // indirect
38-
github.com/gpustack/gguf-parser-go v0.14.1 // indirect
3939
github.com/henvic/httpretty v0.1.4 // indirect
4040
github.com/jaypipes/pcidb v1.0.1 // indirect
4141
github.com/json-iterator/go v1.1.12 // indirect

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-20250724035854-a9454ee7284c h1:hkMon8WnL995BHacRCEsbtPEO2mYsUmdsohJva15QDU=
42+
github.com/docker/model-distribution v0.0.0-20250724035854-a9454ee7284c/go.mod h1:dThpO9JoG5Px3i+rTluAeZcqLGw8C0qepuEL4gL2o/c=
4343
github.com/elastic/go-sysinfo v1.15.3 h1:W+RnmhKFkqPTCRoFq2VCTmsT4p/fwpo+3gKNQsn1XU0=
4444
github.com/elastic/go-sysinfo v1.15.3/go.mod h1:K/cNrqYTDrSoMh2oDkYEMS2+a72GRxMvNP+GC+vRIlo=
4545
github.com/elastic/go-windows v1.0.2 h1:yoLLsAsV5cfg9FLhZ9EXZ2n2sQFKeDYrHenkcivY4vI=

pkg/inference/models/manager.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@ import (
1515
"github.com/docker/model-distribution/distribution"
1616
"github.com/docker/model-distribution/registry"
1717
"github.com/docker/model-distribution/types"
18+
"github.com/sirupsen/logrus"
19+
1820
"github.com/docker/model-runner/pkg/diskusage"
1921
"github.com/docker/model-runner/pkg/inference"
2022
"github.com/docker/model-runner/pkg/logging"
21-
"github.com/sirupsen/logrus"
2223
)
2324

2425
const (
@@ -120,6 +121,7 @@ func (m *Manager) RebuildRoutes(allowedOrigins []string) {
120121
func (m *Manager) routeHandlers(allowedOrigins []string) map[string]http.HandlerFunc {
121122
handlers := map[string]http.HandlerFunc{
122123
"POST " + inference.ModelsPrefix + "/create": m.handleCreateModel,
124+
"POST " + inference.ModelsPrefix + "/load": m.handleLoadModel,
123125
"GET " + inference.ModelsPrefix: m.handleGetModels,
124126
"GET " + inference.ModelsPrefix + "/{name...}": m.handleGetModel,
125127
"DELETE " + inference.ModelsPrefix + "/{name...}": m.handleDeleteModel,
@@ -187,6 +189,20 @@ func (m *Manager) handleCreateModel(w http.ResponseWriter, r *http.Request) {
187189
}
188190
}
189191

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

0 commit comments

Comments
 (0)