Skip to content

Conversation

@NikhilSinha1
Copy link
Contributor

@NikhilSinha1 NikhilSinha1 commented Jan 23, 2026

Summary

We have been investigating a caching issue that has lead to versions of cog including an old version of the src folder when running cog build or cog push on a model that already has a version. We are fairly sure that in certain circumstances, when the FROM r8.im/<username>/<model-name> command is run, it is pulling the latest from the upstream registry instead of using the recently built image from the local machine. To disambiguate, we should directly pass the SHA of the image on the local machine instead of letting docker just look for latest, as it would do by default.

Test Plan

A script, ./script/test-e2e-rebuild, was introduced, that simply makes a small change to the predict.py function and tries to rebuild the image. It then checks that the hash of the predict.py built into the docker image is the same as the one in the predict.py source directory for building the image.

To verify the correctness of this change, build cog from source on the main branch. Then checkout this branch and run the test. The exit code of the script should be 1. Rebuild cog from this branch, and re-run the test. The exit code of the script should be 0.

@NikhilSinha1 NikhilSinha1 requested a review from a team as a code owner January 23, 2026 01:49
}

func (c *apiClient) LocalImageID(ctx context.Context, ref string) (string, error) {
console.Debugf("=== APIClient.LocalImageTag %s", ref)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was expecting this debug line to say APIClient.LocalImageID 🤔

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't found a way to run this that produces the incorrect hash message 🤔

func BuildAddLabelsAndSchemaToImage(ctx context.Context, dockerClient command.Command, image string, labels map[string]string, bundledSchemaFile string, progressOutput string) error {
dockerfile := "FROM " + image + "\n"
dockerfile += "COPY " + bundledSchemaFile + " .cog\n"
if strings.HasPrefix("image", "r8.im") {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you mean?

Suggested change
if strings.HasPrefix("image", "r8.im") {
if strings.HasPrefix(image , "r8.im") {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants