Skip to content

Commit deee70f

Browse files
authored
Removes unused code (#519)
1 parent 2c53258 commit deee70f

File tree

3 files changed

+0
-94
lines changed

3 files changed

+0
-94
lines changed

pkg/inference/models/api.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,6 @@ type ModelCreateRequest struct {
1818
BearerToken string `json:"bearer-token,omitempty"`
1919
}
2020

21-
// ModelPackageRequest represents a model package request, which creates a new model
22-
// from an existing one with modified properties (e.g., context size).
23-
type ModelPackageRequest struct {
24-
// From is the name of the source model to package from.
25-
From string `json:"from"`
26-
// Tag is the name to give the new packaged model.
27-
Tag string `json:"tag"`
28-
// ContextSize specifies the context size to set for the new model.
29-
ContextSize *int32 `json:"context-size,omitempty"`
30-
}
31-
3221
// SimpleModel is a wrapper that allows creating a model with modified configuration
3322
type SimpleModel struct {
3423
types.Model

pkg/inference/models/http_handler.go

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import (
1515
"github.com/docker/model-runner/pkg/distribution/distribution"
1616
"github.com/docker/model-runner/pkg/distribution/registry"
1717
"github.com/docker/model-runner/pkg/inference"
18-
"github.com/docker/model-runner/pkg/internal/utils"
1918
"github.com/docker/model-runner/pkg/logging"
2019
"github.com/docker/model-runner/pkg/middleware"
2120
"github.com/sirupsen/logrus"
@@ -81,7 +80,6 @@ func (h *HTTPHandler) routeHandlers() map[string]http.HandlerFunc {
8180
return map[string]http.HandlerFunc{
8281
"POST " + inference.ModelsPrefix + "/create": h.handleCreateModel,
8382
"POST " + inference.ModelsPrefix + "/load": h.handleLoadModel,
84-
"POST " + inference.ModelsPrefix + "/package": h.handlePackageModel,
8583
"GET " + inference.ModelsPrefix: h.handleGetModels,
8684
"GET " + inference.ModelsPrefix + "/{name...}": h.handleGetModel,
8785
"DELETE " + inference.ModelsPrefix + "/{name...}": h.handleDeleteModel,
@@ -436,44 +434,6 @@ func (h *HTTPHandler) handlePushModel(w http.ResponseWriter, r *http.Request, mo
436434
}
437435
}
438436

439-
// handlePackageModel handles POST <inference-prefix>/models/package requests.
440-
func (h *HTTPHandler) handlePackageModel(w http.ResponseWriter, r *http.Request) {
441-
442-
// Decode the request
443-
var request ModelPackageRequest
444-
if err := json.NewDecoder(r.Body).Decode(&request); err != nil {
445-
http.Error(w, "invalid request body", http.StatusBadRequest)
446-
return
447-
}
448-
449-
// Validate required fields
450-
if request.From == "" || request.Tag == "" {
451-
http.Error(w, "both 'from' and 'tag' fields are required", http.StatusBadRequest)
452-
return
453-
}
454-
455-
err := h.manager.Package(request.From, request.Tag, request.ContextSize)
456-
if err != nil {
457-
if errors.Is(err, distribution.ErrModelNotFound) {
458-
h.log.Warnf("Failed to package model from %q: %v", utils.SanitizeForLog(request.From, -1), err)
459-
http.Error(w, "Model not found", http.StatusNotFound)
460-
return
461-
}
462-
http.Error(w, err.Error(), http.StatusInternalServerError)
463-
return
464-
}
465-
466-
// Return success response
467-
w.Header().Set("Content-Type", "application/json")
468-
response := map[string]string{
469-
"message": fmt.Sprintf("Successfully packaged model from %s with tag %s", request.From, request.Tag),
470-
"model": request.Tag,
471-
}
472-
if err := json.NewEncoder(w).Encode(response); err != nil {
473-
h.log.Warnln("Error while encoding package response:", err)
474-
}
475-
}
476-
477437
// handlePurge handles DELETE <inference-prefix>/models/purge requests.
478438
func (h *HTTPHandler) handlePurge(w http.ResponseWriter, _ *http.Request) {
479439
err := h.manager.Purge()

pkg/inference/models/manager.go

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"strings"
1010

1111
"github.com/docker/model-runner/pkg/diskusage"
12-
"github.com/docker/model-runner/pkg/distribution/builder"
1312
"github.com/docker/model-runner/pkg/distribution/distribution"
1413
"github.com/docker/model-runner/pkg/distribution/registry"
1514
"github.com/docker/model-runner/pkg/distribution/types"
@@ -410,48 +409,6 @@ func (m *Manager) Push(model string, r *http.Request, w http.ResponseWriter) err
410409
return nil
411410
}
412411

413-
func (m *Manager) Package(ref string, tag string, contextSize *int32) error {
414-
// Create a builder from an existing model by getting the bundle first
415-
// Since ModelArtifact interface is needed to work with the builder
416-
bundle, err := m.distributionClient.GetBundle(ref)
417-
if err != nil {
418-
return fmt.Errorf("error while getting model bundle: %w", err)
419-
}
420-
421-
// Create a builder from the existing model artifact (from the bundle)
422-
modelArtifact, ok := bundle.(types.ModelArtifact)
423-
if !ok {
424-
return fmt.Errorf("model bundle is not a valid model artifact")
425-
}
426-
427-
// Create a builder from the existing model
428-
bldr, err := builder.FromModel(modelArtifact)
429-
if err != nil {
430-
return fmt.Errorf("error while building model bundle: %w", err)
431-
}
432-
433-
// Apply context size if specified
434-
if contextSize != nil {
435-
bldr = bldr.WithContextSize(*contextSize)
436-
}
437-
438-
// Get the built model artifact
439-
builtModel := bldr.Model()
440-
441-
// Check if we can use lightweight repackaging (config-only changes from existing model)
442-
useLightweight := bldr.HasOnlyConfigChanges()
443-
444-
if useLightweight {
445-
// Use the lightweight method to avoid re-transferring layers
446-
if err := m.distributionClient.WriteLightweightModel(builtModel, []string{tag}); err != nil {
447-
return fmt.Errorf("error writing model: %w", err)
448-
}
449-
} else {
450-
return err
451-
}
452-
return nil
453-
}
454-
455412
func (m *Manager) Purge() error {
456413
if m.distributionClient == nil {
457414
return fmt.Errorf("model distribution service unavailable")

0 commit comments

Comments
 (0)