Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ jobs:
run: uv pip install --system tox tox-uv
- name: Test
run: make test-integration
env:
R8_COGLET_VERSION: coglet==0.1.0-alpha17

release:
name: "Release"
Expand Down
11 changes: 11 additions & 0 deletions pkg/dockerfile/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@ package dockerfile

import (
"maps"
"os"
"slices"

"github.com/replicate/cog/pkg/config"
)

const CogletVersionEnvVarName = "R8_COGLET_VERSION"

func envLineFromConfig(c *config.Config) (string, error) {
vars := c.ParsedEnvironment()
if len(vars) == 0 {
Expand All @@ -21,3 +24,11 @@ func envLineFromConfig(c *config.Config) (string, error) {

return out, nil
}

func CogletVersionFromEnvironment() string {
host := os.Getenv(CogletVersionEnvVarName)
if host == "" {
host = "coglet"
}
return host
}
13 changes: 13 additions & 0 deletions pkg/dockerfile/env_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package dockerfile

import (
"testing"

"github.com/stretchr/testify/require"
)

func TestCogletVersionFromEnvironment(t *testing.T) {
const cogletVersion = "coglet==0.1.0-alpha17"
t.Setenv(CogletVersionEnvVarName, cogletVersion)
require.Equal(t, CogletVersionFromEnvironment(), cogletVersion)
}
10 changes: 2 additions & 8 deletions pkg/dockerfile/fast_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,15 +227,9 @@ func (g *FastGenerator) generate(ctx context.Context) (string, error) {

func (g *FastGenerator) generateMonobase(lines []string, tmpDir string) ([]string, error) {
var envs []string
// Install the latest version of coglet
cogletVersion := "coglet"
// Unless if we're in replicate/cog repo CI, e.g. integration tests
// Then pin version to avoid GH API rate limit
if os.Getenv("CI") == "true" && os.Getenv("GITHUB_REPOSITORY") == "replicate/cog" {
cogletVersion = "coglet==0.1.0-alpha17"
}

envs = append(envs, []string{
"ENV R8_COG_VERSION=" + cogletVersion,
"ENV R8_COG_VERSION=" + CogletVersionFromEnvironment(),
}...)

if g.Config.Build.GPU {
Expand Down
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,5 @@ deps =
pytest-xdist
pass_env =
COG_BINARY
R8_COGLET_VERSION
commands = pytest {posargs:-n auto -vv --reruns 3}