fix: skip adding labels to images for local-use commands (run/predict/serve/train)#2787
Merged
tempusfrangit merged 1 commit intomainfrom Feb 28, 2026
Merged
Conversation
…/serve/train) When running cog run, cog predict, cog serve, or cog train, the build was unnecessarily adding Cog metadata labels to the image. This added overhead (pip freeze, git info, base image layer inspection, extra Docker build step) for images that are only used locally and never distributed. This was a regression introduced in 1525f7f which replaced resolver.BuildBase() (no labels) with resolver.Build() (adds labels) for the serve/run/predict/train code paths. Adds a SkipLabels option to BuildOptions that short-circuits the label-adding phase in image.Build() when set.
tempusfrangit
approved these changes
Feb 28, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
cog run,cog predict,cog serve, andcog train— these images are for local use only and don't need metadata labelsSkipLabelsoption toBuildOptionsthat short-circuits before pip freeze, git info, base image layer inspection, and the extra Docker build stepBackground
This was a regression introduced in 1525f7f (
feat(coglet): IPC bridge enhancements) which replacedresolver.BuildBase()(no labels) withresolver.Build()(adds labels) for the serve/run/predict/train code paths. The originalimage.BuildBase()just built the Docker image and returned — no labels were added.Changes
pkg/model/options.go— AddSkipLabels boolfield toBuildOptionspkg/cli/serve.go— SetSkipLabels: trueinserveBuildOptions()(used by run/predict/serve/train)pkg/image/build.go— Early return before label-adding whenskipLabelsis truepkg/model/factory.go— PassSkipLabelsthrough toimage.Build()