Skip to content

Commit 8bc02f8

Browse files
committed
remove unnecessary field and helper
1 parent bc78095 commit 8bc02f8

File tree

10 files changed

+20
-105
lines changed

10 files changed

+20
-105
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/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/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-->

pkg/inference/models/api.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ import (
1414
type ModelCreateRequest struct {
1515
// From is the name of the model to pull.
1616
From string `json:"from"`
17-
// IgnoreRuntimeMemoryCheck indicates whether the server should check if it has sufficient
18-
// memory to run the given model (assuming default configuration).
19-
IgnoreRuntimeMemoryCheck bool `json:"ignore-runtime-memory-check,omitempty"`
2017
// BearerToken is an optional bearer token for authentication.
2118
BearerToken string `json:"bearer-token,omitempty"`
2219
}

pkg/inference/scheduling/loader.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -194,15 +194,6 @@ func (l *loader) broadcast() {
194194
}
195195
}
196196

197-
// formatMemorySize formats a memory size in bytes as a string.
198-
// Values of 0 or 1 are treated as sentinel values for "unknown" memory size.
199-
func formatMemorySize(bytes uint64) string {
200-
if bytes <= 1 {
201-
return "unknown"
202-
}
203-
return fmt.Sprintf("%d MB", bytes/1024/1024)
204-
}
205-
206197
// freeRunnerSlot frees a runner slot.
207198
// The caller must hold the loader lock.
208199
func (l *loader) freeRunnerSlot(slot int, key runnerKey) {

pkg/inference/scheduling/loader_test.go

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -125,65 +125,6 @@ func createAliveTerminableMockRunner(log *logrus.Entry, backend inference.Backen
125125
}
126126
}
127127

128-
// TestFormatMemorySize tests the formatMemorySize helper function
129-
func TestFormatMemorySize(t *testing.T) {
130-
tests := []struct {
131-
name string
132-
bytes uint64
133-
expected string
134-
}{
135-
{
136-
name: "sentinel value 0 is unknown",
137-
bytes: 0,
138-
expected: "unknown",
139-
},
140-
{
141-
name: "sentinel value 1 is unknown",
142-
bytes: 1,
143-
expected: "unknown",
144-
},
145-
{
146-
name: "2 bytes is still unknown (edge case)",
147-
bytes: 2,
148-
expected: "0 MB",
149-
},
150-
{
151-
name: "1 MB",
152-
bytes: 1024 * 1024,
153-
expected: "1 MB",
154-
},
155-
{
156-
name: "512 MB",
157-
bytes: 512 * 1024 * 1024,
158-
expected: "512 MB",
159-
},
160-
{
161-
name: "1 GB",
162-
bytes: 1024 * 1024 * 1024,
163-
expected: "1024 MB",
164-
},
165-
{
166-
name: "8 GB",
167-
bytes: 8 * 1024 * 1024 * 1024,
168-
expected: "8192 MB",
169-
},
170-
{
171-
name: "fractional MB rounds down",
172-
bytes: 1024*1024 + 512*1024, // 1.5 MB
173-
expected: "1 MB",
174-
},
175-
}
176-
177-
for _, tt := range tests {
178-
t.Run(tt.name, func(t *testing.T) {
179-
result := formatMemorySize(tt.bytes)
180-
if result != tt.expected {
181-
t.Errorf("formatMemorySize(%d) = %q, want %q", tt.bytes, result, tt.expected)
182-
}
183-
})
184-
}
185-
}
186-
187128
// TestMakeRunnerKey tests that runner keys are created correctly
188129
func TestMakeRunnerKey(t *testing.T) {
189130
tests := []struct {

0 commit comments

Comments
 (0)