@@ -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
2425const (
@@ -120,6 +121,7 @@ func (m *Manager) RebuildRoutes(allowedOrigins []string) {
120121func (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.
191207func (m * Manager ) handleGetModels (w http.ResponseWriter , r * http.Request ) {
192208 if m .distributionClient == nil {
0 commit comments