@@ -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 ,
@@ -183,6 +185,20 @@ func (m *Manager) handleCreateModel(w http.ResponseWriter, r *http.Request) {
183185 }
184186}
185187
188+ // handleLoadModel handles POST <inference-prefix>/models/load requests.
189+ func (m * Manager ) handleLoadModel (w http.ResponseWriter , r * http.Request ) {
190+ if m .distributionClient == nil {
191+ http .Error (w , "model distribution service unavailable" , http .StatusServiceUnavailable )
192+ return
193+ }
194+
195+ if _ , err := m .distributionClient .LoadModel (r .Body , w ); err != nil {
196+ http .Error (w , err .Error (), http .StatusInternalServerError )
197+ return
198+ }
199+ return
200+ }
201+
186202// handleGetModels handles GET <inference-prefix>/models requests.
187203func (m * Manager ) handleGetModels (w http.ResponseWriter , r * http.Request ) {
188204 if m .distributionClient == nil {
0 commit comments