Skip to content

Commit 025fa20

Browse files
authored
Rrmove memory estimation logic and related structures (#504)
* remove memory estimation logic and related structures * remove unused Elastic dependencies from go.mod and go.sum * remove unnecessary field and helper * update docs * fix integration_test.go
1 parent 9eaf448 commit 025fa20

File tree

23 files changed

+54
-564
lines changed

23 files changed

+54
-564
lines changed

cmd/cli/commands/compose.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ func downloadModelsOnlyIfNotFound(desktopClient *desktop.Client, models []string
177177
printer := desktop.NewSimplePrinter(func(s string) {
178178
_ = sendInfo(s)
179179
})
180-
_, _, err = desktopClient.Pull(model, false, printer)
180+
_, _, err = desktopClient.Pull(model, printer)
181181
if err != nil {
182182
_ = sendErrorf("Failed to pull model: %v", err)
183183
return fmt.Errorf("Failed to pull model: %w\n", err)

cmd/cli/commands/integration_test.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ func TestIntegration_PullModel(t *testing.T) {
371371
t.Run(tc.name, func(t *testing.T) {
372372
// Pull the model using the test case reference
373373
t.Logf("Pulling model with reference: %s", tc.ref)
374-
err := pullModel(newPullCmd(), env.client, tc.ref, true)
374+
err := pullModel(newPullCmd(), env.client, tc.ref)
375375
require.NoError(t, err, "Failed to pull model with reference: %s", tc.ref)
376376

377377
// List models and verify the expected model is present
@@ -426,7 +426,7 @@ func TestIntegration_InspectModel(t *testing.T) {
426426
// Pull the model using a short reference
427427
pullRef := "inspect-test"
428428
t.Logf("Pulling model with reference: %s", pullRef)
429-
err = pullModel(newPullCmd(), env.client, pullRef, true)
429+
err = pullModel(newPullCmd(), env.client, pullRef)
430430
require.NoError(t, err, "Failed to pull model")
431431

432432
// Verify the model was pulled
@@ -485,7 +485,7 @@ func TestIntegration_TagModel(t *testing.T) {
485485
// Pull the model using a simple reference
486486
pullRef := "tag-test"
487487
t.Logf("Pulling model with reference: %s", pullRef)
488-
err = pullModel(newPullCmd(), env.client, pullRef, true)
488+
err = pullModel(newPullCmd(), env.client, pullRef)
489489
require.NoError(t, err, "Failed to pull model")
490490

491491
// Verify the model was pulled
@@ -663,7 +663,7 @@ func TestIntegration_PushModel(t *testing.T) {
663663
// Pull the model using a simple reference
664664
pullRef := "tag-test"
665665
t.Logf("Pulling model with reference: %s", pullRef)
666-
err = pullModel(newPullCmd(), env.client, pullRef, true)
666+
err = pullModel(newPullCmd(), env.client, pullRef)
667667
require.NoError(t, err, "Failed to pull model")
668668

669669
// Verify the model was pulled
@@ -814,7 +814,7 @@ func TestIntegration_RemoveModel(t *testing.T) {
814814
// Pull the model
815815
pullRef := "rm-test"
816816
t.Logf("Pulling model with reference: %s", pullRef)
817-
err := pullModel(newPullCmd(), env.client, pullRef, true)
817+
err := pullModel(newPullCmd(), env.client, pullRef)
818818
require.NoError(t, err, "Failed to pull model")
819819

820820
// Verify model exists
@@ -848,11 +848,11 @@ func TestIntegration_RemoveModel(t *testing.T) {
848848

849849
// Pull both models
850850
t.Logf("Pulling first model: rm-multi-1")
851-
err := pullModel(newPullCmd(), env.client, "rm-multi-1", true)
851+
err := pullModel(newPullCmd(), env.client, "rm-multi-1")
852852
require.NoError(t, err, "Failed to pull first model")
853853

854854
t.Logf("Pulling second model: rm-multi-2")
855-
err = pullModel(newPullCmd(), env.client, "rm-multi-2", true)
855+
err = pullModel(newPullCmd(), env.client, "rm-multi-2")
856856
require.NoError(t, err, "Failed to pull second model")
857857

858858
// Verify both models exist
@@ -878,7 +878,7 @@ func TestIntegration_RemoveModel(t *testing.T) {
878878
t.Run("remove specific tag keeps other tags", func(t *testing.T) {
879879
// Pull the model
880880
t.Logf("Pulling model: rm-test")
881-
err := pullModel(newPullCmd(), env.client, "rm-test", true)
881+
err := pullModel(newPullCmd(), env.client, "rm-test")
882882
require.NoError(t, err, "Failed to pull model")
883883

884884
// Add multiple tags to the same model
@@ -940,7 +940,7 @@ func TestIntegration_RemoveModel(t *testing.T) {
940940
t.Run("remove by model ID removes all tags", func(t *testing.T) {
941941
// Pull the model
942942
t.Logf("Pulling model: rm-test")
943-
err := pullModel(newPullCmd(), env.client, "rm-test", true)
943+
err := pullModel(newPullCmd(), env.client, "rm-test")
944944
require.NoError(t, err, "Failed to pull model")
945945

946946
// Add multiple tags
@@ -971,7 +971,7 @@ func TestIntegration_RemoveModel(t *testing.T) {
971971
t.Run("force flag", func(t *testing.T) {
972972
// Pull the model
973973
t.Logf("Pulling model: rm-test")
974-
err := pullModel(newPullCmd(), env.client, "rm-test", true)
974+
err := pullModel(newPullCmd(), env.client, "rm-test")
975975
require.NoError(t, err, "Failed to pull model")
976976

977977
// Test removal with force flag

cmd/cli/commands/pull.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ import (
1010
)
1111

1212
func newPullCmd() *cobra.Command {
13-
var ignoreRuntimeMemoryCheck bool
14-
1513
c := &cobra.Command{
1614
Use: "pull MODEL",
1715
Short: "Pull a model from Docker Hub or HuggingFace to your local environment",
@@ -20,19 +18,17 @@ func newPullCmd() *cobra.Command {
2018
if _, err := ensureStandaloneRunnerAvailable(cmd.Context(), asPrinter(cmd), false); err != nil {
2119
return fmt.Errorf("unable to initialize standalone model runner: %w", err)
2220
}
23-
return pullModel(cmd, desktopClient, args[0], ignoreRuntimeMemoryCheck)
21+
return pullModel(cmd, desktopClient, args[0])
2422
},
2523
ValidArgsFunction: completion.NoComplete,
2624
}
2725

28-
c.Flags().BoolVar(&ignoreRuntimeMemoryCheck, "ignore-runtime-memory-check", false, "Do not block pull if estimated runtime memory for model exceeds system resources.")
29-
3026
return c
3127
}
3228

33-
func pullModel(cmd *cobra.Command, desktopClient *desktop.Client, model string, ignoreRuntimeMemoryCheck bool) error {
29+
func pullModel(cmd *cobra.Command, desktopClient *desktop.Client, model string) error {
3430
printer := asPrinter(cmd)
35-
response, _, err := desktopClient.Pull(model, ignoreRuntimeMemoryCheck, printer)
31+
response, _, err := desktopClient.Pull(model, printer)
3632

3733
if err != nil {
3834
return handleClientError(err, "Failed to pull model")

cmd/cli/commands/run.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,6 @@ func chatWithMarkdownContext(ctx context.Context, cmd *cobra.Command, client *de
570570

571571
func newRunCmd() *cobra.Command {
572572
var debug bool
573-
var ignoreRuntimeMemoryCheck bool
574573
var colorMode string
575574
var detach bool
576575

@@ -686,7 +685,7 @@ func newRunCmd() *cobra.Command {
686685
return handleClientError(err, "Failed to inspect model")
687686
}
688687
cmd.Println("Unable to find model '" + model + "' locally. Pulling from the server.")
689-
if err := pullModel(cmd, desktopClient, model, ignoreRuntimeMemoryCheck); err != nil {
688+
if err := pullModel(cmd, desktopClient, model); err != nil {
690689
return err
691690
}
692691
}
@@ -733,7 +732,6 @@ func newRunCmd() *cobra.Command {
733732
c.Args = requireMinArgs(1, "run", cmdArgs)
734733

735734
c.Flags().BoolVar(&debug, "debug", false, "Enable debug logging")
736-
c.Flags().BoolVar(&ignoreRuntimeMemoryCheck, "ignore-runtime-memory-check", false, "Do not block pull if estimated runtime memory for model exceeds system resources.")
737735
c.Flags().StringVar(&colorMode, "color", "no", "Use colored output (auto|yes|no)")
738736
c.Flags().BoolVarP(&detach, "detach", "d", false, "Load the model in the background without interaction")
739737

cmd/cli/desktop/desktop.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ func (c *Client) Status() Status {
105105
}
106106
}
107107

108-
func (c *Client) Pull(model string, ignoreRuntimeMemoryCheck bool, printer standalone.StatusPrinter) (string, bool, error) {
108+
func (c *Client) Pull(model string, printer standalone.StatusPrinter) (string, bool, error) {
109109
model = normalizeHuggingFaceModelName(model)
110110

111111
// Check if this is a Hugging Face model and if HF_TOKEN is set
@@ -116,9 +116,8 @@ func (c *Client) Pull(model string, ignoreRuntimeMemoryCheck bool, printer stand
116116

117117
return c.withRetries("download", 3, printer, func(attempt int) (string, bool, error, bool) {
118118
jsonData, err := json.Marshal(dmrm.ModelCreateRequest{
119-
From: model,
120-
IgnoreRuntimeMemoryCheck: ignoreRuntimeMemoryCheck,
121-
BearerToken: hfToken,
119+
From: model,
120+
BearerToken: hfToken,
122121
})
123122
if err != nil {
124123
// Marshaling errors are not retryable

cmd/cli/desktop/desktop_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func TestPullHuggingFaceModel(t *testing.T) {
3939
}, nil)
4040

4141
printer := NewSimplePrinter(func(s string) {})
42-
_, _, err := client.Pull(modelName, false, printer)
42+
_, _, err := client.Pull(modelName, printer)
4343
assert.NoError(t, err)
4444
}
4545

@@ -126,7 +126,7 @@ func TestNonHuggingFaceModel(t *testing.T) {
126126
}, nil)
127127

128128
printer := NewSimplePrinter(func(s string) {})
129-
_, _, err := client.Pull(modelName, false, printer)
129+
_, _, err := client.Pull(modelName, printer)
130130
assert.NoError(t, err)
131131
}
132132

@@ -250,7 +250,7 @@ func TestPullRetryOnNetworkError(t *testing.T) {
250250
)
251251

252252
printer := NewSimplePrinter(func(s string) {})
253-
_, _, err := client.Pull(modelName, false, printer)
253+
_, _, err := client.Pull(modelName, printer)
254254
assert.NoError(t, err)
255255
}
256256

@@ -270,7 +270,7 @@ func TestPullNoRetryOn4xxError(t *testing.T) {
270270
}, nil).Times(1)
271271

272272
printer := NewSimplePrinter(func(s string) {})
273-
_, _, err := client.Pull(modelName, false, printer)
273+
_, _, err := client.Pull(modelName, printer)
274274
assert.Error(t, err)
275275
assert.Contains(t, err.Error(), "Model not found")
276276
}
@@ -297,7 +297,7 @@ func TestPullRetryOn5xxError(t *testing.T) {
297297
)
298298

299299
printer := NewSimplePrinter(func(s string) {})
300-
_, _, err := client.Pull(modelName, false, printer)
300+
_, _, err := client.Pull(modelName, printer)
301301
assert.NoError(t, err)
302302
}
303303

@@ -324,7 +324,7 @@ func TestPullRetryOnServiceUnavailable(t *testing.T) {
324324
)
325325

326326
printer := NewSimplePrinter(func(s string) {})
327-
_, _, err := client.Pull(modelName, false, printer)
327+
_, _, err := client.Pull(modelName, printer)
328328
assert.NoError(t, err)
329329
}
330330

@@ -341,7 +341,7 @@ func TestPullMaxRetriesExhausted(t *testing.T) {
341341
mockClient.EXPECT().Do(gomock.Any()).Return(nil, io.EOF).Times(4)
342342

343343
printer := NewSimplePrinter(func(s string) {})
344-
_, _, err := client.Pull(modelName, false, printer)
344+
_, _, err := client.Pull(modelName, printer)
345345
assert.Error(t, err)
346346
assert.Contains(t, err.Error(), "failed to download after 3 retries")
347347
}

cmd/cli/docs/reference/docker_model_pull.yaml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,6 @@ long: |
55
usage: docker model pull MODEL
66
pname: docker model
77
plink: docker_model.yaml
8-
options:
9-
- option: ignore-runtime-memory-check
10-
value_type: bool
11-
default_value: "false"
12-
description: |
13-
Do not block pull if estimated runtime memory for model exceeds system resources.
14-
deprecated: false
15-
hidden: false
16-
experimental: false
17-
experimentalcli: false
18-
kubernetes: false
19-
swarm: false
208
examples: |-
219
### Pulling a model from Docker Hub
2210

cmd/cli/docs/reference/docker_model_run.yaml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,6 @@ options:
4141
experimentalcli: false
4242
kubernetes: false
4343
swarm: false
44-
- option: ignore-runtime-memory-check
45-
value_type: bool
46-
default_value: "false"
47-
description: |
48-
Do not block pull if estimated runtime memory for model exceeds system resources.
49-
deprecated: false
50-
hidden: false
51-
experimental: false
52-
experimentalcli: false
53-
kubernetes: false
54-
swarm: false
5544
examples: |-
5645
### One-time prompt
5746

cmd/cli/docs/reference/model_pull.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,6 @@
33
<!---MARKER_GEN_START-->
44
Pull a model from Docker Hub or HuggingFace to your local environment
55

6-
### Options
7-
8-
| Name | Type | Default | Description |
9-
|:--------------------------------|:-------|:--------|:----------------------------------------------------------------------------------|
10-
| `--ignore-runtime-memory-check` | `bool` | | Do not block pull if estimated runtime memory for model exceeds system resources. |
11-
126

137
<!---MARKER_GEN_END-->
148

cmd/cli/docs/reference/model_run.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@ Run a model and interact with it using a submitted prompt or chat mode
55

66
### Options
77

8-
| Name | Type | Default | Description |
9-
|:--------------------------------|:---------|:--------|:----------------------------------------------------------------------------------|
10-
| `--color` | `string` | `no` | Use colored output (auto\|yes\|no) |
11-
| `--debug` | `bool` | | Enable debug logging |
12-
| `-d`, `--detach` | `bool` | | Load the model in the background without interaction |
13-
| `--ignore-runtime-memory-check` | `bool` | | Do not block pull if estimated runtime memory for model exceeds system resources. |
8+
| Name | Type | Default | Description |
9+
|:-----------------|:---------|:--------|:-----------------------------------------------------|
10+
| `--color` | `string` | `no` | Use colored output (auto\|yes\|no) |
11+
| `--debug` | `bool` | | Enable debug logging |
12+
| `-d`, `--detach` | `bool` | | Load the model in the background without interaction |
1413

1514

1615
<!---MARKER_GEN_END-->

0 commit comments

Comments
 (0)