-
Notifications
You must be signed in to change notification settings - Fork 65
feat: CE-1579: Add support for deploying serverless with models #276
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
eebfea6
feat: CE-1579: Add support for deploying serverless with models
brosenpod 1fc1ae0
cleanup: lint fixes, tests, and go 1.26.4 bump on top of #276
randomizedcoder ff5c484
fix: restore stderr for model command info/error output; fix GetModel…
randomizedcoder File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,122 @@ | ||
| package model | ||
|
|
||
| import ( | ||
| "errors" | ||
| "io" | ||
| "os" | ||
| "strings" | ||
| "sync" | ||
| "testing" | ||
|
|
||
| "github.com/runpod/runpodctl/api" | ||
| ) | ||
|
|
||
| // captureStdStreams runs fn with os.Stdout and os.Stderr replaced by pipes and | ||
| // returns whatever each stream received. It exists to assert that informational | ||
| // and error output goes to the correct stream — a regression class CLAUDE.md | ||
| // explicitly calls out (legacy commands losing stderr ⇒ corrupts stdout for | ||
| // JSON-consuming agents). | ||
| func captureStdStreams(t *testing.T, fn func()) (stdout, stderr string) { | ||
| t.Helper() | ||
|
|
||
| origStdout, origStderr := os.Stdout, os.Stderr | ||
| stdoutR, stdoutW, err := os.Pipe() | ||
| if err != nil { | ||
| t.Fatalf("os.Pipe stdout: %v", err) | ||
| } | ||
| stderrR, stderrW, err := os.Pipe() | ||
| if err != nil { | ||
| t.Fatalf("os.Pipe stderr: %v", err) | ||
| } | ||
| os.Stdout, os.Stderr = stdoutW, stderrW | ||
|
|
||
| var ( | ||
| wg sync.WaitGroup | ||
| stdoutBuf, stderrBuf strings.Builder | ||
| ) | ||
| wg.Add(2) | ||
| go func() { | ||
| defer wg.Done() | ||
| _, _ = io.Copy(&stdoutBuf, stdoutR) | ||
| }() | ||
| go func() { | ||
| defer wg.Done() | ||
| _, _ = io.Copy(&stderrBuf, stderrR) | ||
| }() | ||
|
|
||
| defer func() { | ||
| os.Stdout, os.Stderr = origStdout, origStderr | ||
| }() | ||
|
|
||
| fn() | ||
|
|
||
| _ = stdoutW.Close() | ||
| _ = stderrW.Close() | ||
| wg.Wait() | ||
| _ = stdoutR.Close() | ||
| _ = stderrR.Close() | ||
|
|
||
| return stdoutBuf.String(), stderrBuf.String() | ||
| } | ||
|
|
||
| func TestHandleModelRepoError(t *testing.T) { | ||
| tests := []struct { | ||
| name string | ||
| err error | ||
| wantHandled bool | ||
| wantStderrSub string // empty = stderr must be empty | ||
| wantStdoutSub string // empty = stdout must be empty | ||
| }{ | ||
| { | ||
| name: "nil error is a no-op", | ||
| err: nil, | ||
| wantHandled: false, | ||
| }, | ||
| { | ||
| name: "ErrModelRepoNotImplemented routes to stderr", | ||
| err: api.ErrModelRepoNotImplemented, | ||
| wantHandled: true, | ||
| wantStderrSub: api.ErrModelRepoNotImplemented.Error(), | ||
| }, | ||
| { | ||
| name: "feature-not-enabled message routes to stderr", | ||
| err: errors.New("Model Repo feature is not enabled for this user"), | ||
| wantHandled: true, | ||
| wantStderrSub: "Model Repo feature is not enabled for this user", | ||
| }, | ||
| { | ||
| name: "unrelated error is not handled", | ||
| err: errors.New("some other failure"), | ||
| wantHandled: false, | ||
| }, | ||
| } | ||
|
|
||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| var handled bool | ||
| stdout, stderr := captureStdStreams(t, func() { | ||
| handled = handleModelRepoError(tt.err) | ||
| }) | ||
|
|
||
| if handled != tt.wantHandled { | ||
| t.Fatalf("handled = %v, want %v", handled, tt.wantHandled) | ||
| } | ||
|
|
||
| // CLAUDE.md: deprecation warnings / handled errors must go to stderr | ||
| // only; stdout must stay clean for JSON-consuming agents. | ||
| if stdout != "" { | ||
| t.Fatalf("stdout must remain empty, got %q", stdout) | ||
| } | ||
|
|
||
| if tt.wantStderrSub == "" { | ||
| if stderr != "" { | ||
| t.Fatalf("expected empty stderr, got %q", stderr) | ||
| } | ||
| return | ||
| } | ||
| if !strings.Contains(stderr, tt.wantStderrSub) { | ||
| t.Fatalf("stderr = %q, want substring %q", stderr, tt.wantStderrSub) | ||
| } | ||
| }) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.