fix: add modelReferences to endpoint create/update and document in runpod.toml template#281
Conversation
|
Promptless prepared a documentation update related to this change. Triggered by PR #281 This documents the new |
0f09ed8 to
8a4b418
Compare
There was a problem hiding this comment.
Pull request overview
Adds modelReferences support to serverless endpoint creation and introduces a new CLI command to update an existing endpoint’s cached model references, with accompanying documentation in the runpod.toml template.
Changes:
- Extend endpoint API payloads/queries to include
modelReferences, and fix JSON unmarshalling for endpoint IDs. - Read
model_refsfromrunpod.tomlduring project deploy and pass through to endpoint creation. - Add
runpodctl endpoint model ...command for updating model references on an existing endpoint.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| cmd/root.go | Registers the new top-level endpoint command group. |
| cmd/project/tomlBuilder.go | Documents model_refs in the generated runpod.toml template. |
| cmd/project/functions.go | Parses model_refs from TOML and passes them into endpoint creation. |
| cmd/endpoint/update_model.go | Adds CLI subcommand to set endpoint model references. |
| cmd/endpoint/endpoint.go | Introduces the endpoint command group and wires subcommands. |
| api/endpoint.go | Adds ModelReferences to create input, fixes Endpoint.Id JSON tag, extends queries, and adds model update mutation helper. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if refs, ok := endpointConfig.Get("model_refs").([]interface{}); ok { | ||
| for _, r := range refs { | ||
| modelRefs = append(modelRefs, r.(string)) | ||
| } | ||
| } |
| var modelCmd = &cobra.Command{ | ||
| Use: "model <endpoint-id> <model-ref> [model-ref...]", | ||
| Short: "update model references on an endpoint", | ||
| Long: "set the model references (cached models) for a serverless endpoint", | ||
| Args: cobra.MinimumNArgs(2), | ||
| RunE: runModel, | ||
| } | ||
|
|
||
| func runModel(cmd *cobra.Command, args []string) error { | ||
| endpointID := args[0] | ||
| modelRefs := args[1:] | ||
|
|
TimPietruskyRunPod
left a comment
There was a problem hiding this comment.
the modelReferences plumbing here is solid — CreateEndpointInput, the GetEndpoints query addition, UpdateEndpointModel() via saveEndpoint, and the runpod.toml model_refs key are all the right pieces. requesting changes on the CLI surface only.
don't introduce a new top-level endpoint group — use the existing serverless group.
we already have serverless (create/delete/get/list/update), and serverless create --model-reference already landed in #276. adding endpoint model alongside it gives two command namespaces for the same resource, and model would be the only thing under endpoint — so the surface fragments and --model-reference (create) vs endpoint model (update) becomes inconsistent for the same concept.
endpoint model <id> [refs...] [--clear] is functionally just a serverless update that only touches model refs. fold it into the command that already exists:
- set/replace:
runpodctl serverless update <id> --model-reference a --model-reference b - remove all:
runpodctl serverless update <id> --clear-models
concretely:
- add a repeatable
--model-reference(StringArrayVar) and a--clear-modelsbool tocmd/serverless/update.go, matching the--model-referenceverb already onserverless create - on update, set
modelReferenceson thesaveEndpointinput: the provided refs, or[]when--clear-modelsis passed (same empty-list-to-clear behavior the current--clearalready relies on) - keep all the api /
runpod.tomlplumbing from this PR as-is — only the command placement changes - drop
cmd/endpoint/(and revert the docs to extend the serverless reference page instead of a new endpoint page)
the only thing that would justify a new group is a deliberate rename serverless → endpoint (the API/console domain term is "Endpoint") with serverless kept as a hidden alias — but that's a bigger decision and should be its own PR with a deprecation plan, not introduced as a side effect of adding model refs.
tl;dr: plumbing 👍 — move endpoint model → serverless update --model-reference / --clear-models and drop the new top-level group.
|
to be clear on scope — the read-side additions are great, keep them:
the only change requested is the write-side command placement: drop the new top-level so: read extension to |
1af837b to
09afb41
Compare
|
done — dropped
the two are mutually exclusive (validated at runtime). the |
09afb41 to
54c8f3b
Compare
|
Done — |
TimPietruskyRunPod
left a comment
There was a problem hiding this comment.
re-review — command placement is fixed, but the update path ships data loss
thanks for folding the write-side into serverless update --model-reference / --clear-models and dropping the top-level endpoint group — that part is exactly right, and the create/toml plumbing is good.
blocking: serverless update --model-reference (and --clear-models) silently resets the rest of the endpoint's config to defaults. saveEndpoint is a full replace, not a merge, and UpdateEndpointModels only sends id + name + modelReferences, so every other field reverts.
verified end-to-end against the live api on this branch:
- created an endpoint with
idleTimeout=42, scalerValue=9, workersMax=5 - ran
serverless update <id> --model-reference https://huggingface.co/Qwen/Qwen2.5-0.5B-Instruct:main - re-fetched:
idleTimeout=10, scalerValue=4, workersMax=3— all reset to defaults
this is net-new in this PR: on main, saveEndpoint is only ever called for create (no id), and the existing serverless update uses the REST PATCH (UpdateEndpoint) + the dedicated updateEndpointTemplate mutation for partial updates — neither touches saveEndpoint. the safe partial-update path was already established; the model-update code just didn't follow it. it also breaks the combined case (--workers-min 5 --model-reference X): the REST patch sets workers, then saveEndpoint immediately wipes them.
the schema confirms only name is required on EndpointInput, so the partial mutation succeeds silently with no error — which is what makes this a quiet footgun rather than a loud failure.
fix options:
- round-trip the full current config —
UpdateEndpointModelsalready fetches the endpoint for its name; fetch the rest (workersMin/workersMax/idleTimeout/scalerType/scalerValue/gpuIds/templateId/...) and echo it back alongsidemodelReferences, or - use/ask backend for a dedicated partial mutation (the way
updateEndpointTemplateexists separately is the hint thatsaveEndpointisn't safe for partial updates).
plus two cleanups inline. happy to push the round-trip fix if useful.
…od.toml - Add --model-reference flag to 'serverless update' (repeatable; replaces existing) - Add --clear-models flag to 'serverless update' to remove all model references - Wire model_refs from runpod.toml [endpoint] section into 'project deploy' - Add modelReferences to GetEndpoints query - Document model_refs in generated runpod.toml template - Add UpdateEndpointModels() to internal API client Closes SLS-94
54c8f3b to
45b13fe
Compare
Tim is no longer on the team and all concerns have been addressed
|
Promptless updated the documentation suggestion to match the final merged changes. Triggered by PR #281 Since the standalone |
Summary
Adds support for
modelReferencesin the endpoint create/update flow.Changes
api/endpoint.go— AddedModelReferences []stringfield toCreateEndpointInput; fixed missingjson:"id"tag onEndpoint.Id; addedmodelReferencestoGetEndpointsGraphQL query; addedUpdateEndpointModel()function that usessaveEndpointmutation to update models on existing endpointscmd/project/functions.go—deployProjectreadsmodel_refsfrom endpoint config and passes it asModelReferencestoCreateEndpointInputcmd/project/tomlBuilder.go— Documents the newmodel_refsconfig key in the[endpoint]section of therunpod.tomltemplatecmd/endpoint/update_model.go(new) — Addsrunpodctl endpoint model <endpoint-id> <model-ref> [model-ref...]CLI command to set model references on an existing endpointcmd/root.go— Registers the new endpoint command groupRelated