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
37 changes: 0 additions & 37 deletions integration-tests/tests/build_localimage.txtar

This file was deleted.

38 changes: 0 additions & 38 deletions integration-tests/tests/predict_localimage.txtar

This file was deleted.

11 changes: 1 addition & 10 deletions pkg/cli/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ var buildUseCogBaseImage bool
var buildStrip bool
var buildPrecompile bool
var buildFast bool
var buildLocalImage bool
var configFilename string

const useCogBaseImageFlagKey = "use-cog-base-image"
Expand All @@ -54,7 +53,6 @@ func newBuildCommand() *cobra.Command {
addStripFlag(cmd)
addPrecompileFlag(cmd)
addFastFlag(cmd)
addLocalImage(cmd)
addConfigFlag(cmd)
addPipelineImage(cmd)
cmd.Flags().StringVarP(&buildTag, "tag", "t", "", "A name for the built image in the form 'repository:tag'")
Expand All @@ -74,7 +72,7 @@ func buildCommand(cmd *cobra.Command, args []string) error {
return err
}
logClient := coglog.NewClient(client)
logCtx := logClient.StartBuild(buildLocalImage)
logCtx := logClient.StartBuild()

src, err := model.NewSource(configFilename)
if err != nil {
Expand Down Expand Up @@ -186,12 +184,6 @@ func addFastFlag(cmd *cobra.Command) {
_ = cmd.Flags().MarkHidden(fastFlag)
}

func addLocalImage(cmd *cobra.Command) {
const localImage = "x-localimage"
cmd.Flags().BoolVar(&buildLocalImage, localImage, false, "Whether to use the experimental local image features")
_ = cmd.Flags().MarkHidden(localImage)
}

func addConfigFlag(cmd *cobra.Command) {
cmd.Flags().StringVarP(&configFilename, "file", "f", "cog.yaml", "The name of the config file.")
}
Expand Down Expand Up @@ -237,7 +229,6 @@ func buildOptionsFromFlags(cmd *cobra.Command, imageName string, fast bool, anno
Precompile: buildPrecompile,
Fast: fast,
Annotations: annotations,
LocalImage: buildLocalImage,
PipelinesImage: pipelinesImage,
}
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/cli/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ func newDebugCommand() *cobra.Command {
addUseCogBaseImageFlag(cmd)
addBuildTimestampFlag(cmd)
addFastFlag(cmd)
addLocalImage(cmd)
addConfigFlag(cmd)
cmd.Flags().StringVarP(&imageName, "image-name", "", "", "The image name to use for the generated Dockerfile")

Expand All @@ -49,7 +48,7 @@ func cmdDockerfile(cmd *cobra.Command, args []string) error {
}

client := registry.NewRegistryClient()
generator, err := dockerfile.NewGenerator(cfg, projectDir, buildFast, dockerClient, buildLocalImage, client, true)
generator, err := dockerfile.NewGenerator(cfg, projectDir, buildFast, dockerClient, client, true)
if err != nil {
return fmt.Errorf("Error creating Dockerfile generator: %w", err)
}
Expand Down
1 change: 0 additions & 1 deletion pkg/cli/predict.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ the prediction on that.`,
addGpusFlag(cmd)
addSetupTimeoutFlag(cmd)
addFastFlag(cmd)
addLocalImage(cmd)
addConfigFlag(cmd)
addPipelineImage(cmd)

Expand Down
8 changes: 1 addition & 7 deletions pkg/cli/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ func newPushCommand() *cobra.Command {
addStripFlag(cmd)
addPrecompileFlag(cmd)
addFastFlag(cmd)
addLocalImage(cmd)
addConfigFlag(cmd)
addPipelineImage(cmd)

Expand All @@ -60,7 +59,7 @@ func push(cmd *cobra.Command, args []string) error {
return err
}
logClient := coglog.NewClient(client)
logCtx := logClient.StartPush(buildLocalImage)
logCtx := logClient.StartPush()

src, err := model.NewSource(configFilename)
if err != nil {
Expand Down Expand Up @@ -90,11 +89,6 @@ func push(cmd *cobra.Command, args []string) error {
}

replicatePrefix := fmt.Sprintf("%s/", global.ReplicateRegistryHost)
if !strings.HasPrefix(imageName, replicatePrefix) && buildLocalImage {
err = fmt.Errorf("Unable to push a local image model to a non replicate host, please disable the local image flag before pushing to this host.")
logClient.EndPush(ctx, err, logCtx)
return err
}

annotations := map[string]string{}
buildID, err := uuid.NewV7()
Expand Down
5 changes: 0 additions & 5 deletions pkg/cli/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ func newRunCommand() *cobra.Command {
addUseCogBaseImageFlag(cmd)
addGpusFlag(cmd)
addFastFlag(cmd)
addLocalImage(cmd)
addConfigFlag(cmd)
addPipelineImage(cmd)

Expand Down Expand Up @@ -103,10 +102,6 @@ func run(cmd *cobra.Command, args []string) error {
Volumes: []command.Volume{{Source: src.ProjectDir, Destination: "/src"}},
Workdir: "/src",
}
runOptions, err = docker.FillInWeightsManifestVolumes(ctx, dockerClient, runOptions)
if err != nil {
return err
}

for _, portString := range runPorts {
port, err := strconv.Atoi(portString)
Expand Down
4 changes: 0 additions & 4 deletions pkg/cli/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,6 @@ func cmdServe(cmd *cobra.Command, arg []string) error {
Volumes: []command.Volume{{Source: src.ProjectDir, Destination: "/src"}},
Workdir: "/src",
}
runOptions, err = docker.FillInWeightsManifestVolumes(ctx, dockerClient, runOptions)
if err != nil {
return err
}

runOptions.Ports = append(runOptions.Ports, command.Port{HostPort: port, ContainerPort: 5000})

Expand Down
1 change: 0 additions & 1 deletion pkg/coglog/build_log_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ type BuildLogContext struct {
started time.Time
Fast bool
CogRuntime bool
localImage bool
}
14 changes: 4 additions & 10 deletions pkg/coglog/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,13 @@ type buildLog struct {
BuildError *string `json:"error"`
Fast bool `json:"fast"`
CogRuntime bool `json:"cog_runtime"`
LocalImage bool `json:"local_image"`
}

type pushLog struct {
DurationMs float32 `json:"length_ms"`
BuildError *string `json:"error"`
Fast bool `json:"fast"`
CogRuntime bool `json:"cog_runtime"`
LocalImage bool `json:"local_image"`
}

type pullLog struct {
Expand All @@ -46,10 +44,9 @@ func NewClient(client *http.Client) *Client {
}
}

func (c *Client) StartBuild(localImage bool) BuildLogContext {
func (c *Client) StartBuild() BuildLogContext {
logContext := BuildLogContext{
started: time.Now(),
localImage: localImage,
started: time.Now(),
}
return logContext
}
Expand All @@ -65,7 +62,6 @@ func (c *Client) EndBuild(ctx context.Context, err error, logContext BuildLogCon
BuildError: errorStr,
Fast: logContext.Fast,
CogRuntime: logContext.CogRuntime,
LocalImage: logContext.localImage,
}

jsonData, err := json.Marshal(buildLog)
Expand All @@ -83,10 +79,9 @@ func (c *Client) EndBuild(ctx context.Context, err error, logContext BuildLogCon
return true
}

func (c *Client) StartPush(localImage bool) PushLogContext {
func (c *Client) StartPush() PushLogContext {
logContext := PushLogContext{
started: time.Now(),
localImage: localImage,
started: time.Now(),
}
return logContext
}
Expand All @@ -102,7 +97,6 @@ func (c *Client) EndPush(ctx context.Context, err error, logContext PushLogConte
BuildError: errorStr,
Fast: logContext.Fast,
CogRuntime: logContext.CogRuntime,
LocalImage: logContext.localImage,
}

jsonData, err := json.Marshal(pushLog)
Expand Down
6 changes: 3 additions & 3 deletions pkg/coglog/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ func TestLogBuild(t *testing.T) {
t.Setenv(CoglogHostEnvVarName, url.Host)

client := NewClient(http.DefaultClient)
logContext := client.StartBuild(false)
logContext := client.StartBuild()
success := client.EndBuild(t.Context(), nil, logContext)
require.True(t, success)
}

func TestLogBuildDisabled(t *testing.T) {
t.Setenv(CoglogDisableEnvVarName, "true")
client := NewClient(http.DefaultClient)
logContext := client.StartBuild(false)
logContext := client.StartBuild()
success := client.EndBuild(t.Context(), nil, logContext)
require.False(t, success)
}
Expand All @@ -48,7 +48,7 @@ func TestLogPush(t *testing.T) {
t.Setenv(CoglogHostEnvVarName, url.Host)

client := NewClient(http.DefaultClient)
logContext := client.StartPush(false)
logContext := client.StartPush()
success := client.EndPush(t.Context(), nil, logContext)
require.True(t, success)
}
1 change: 0 additions & 1 deletion pkg/coglog/push_log_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ type PushLogContext struct {
started time.Time
Fast bool
CogRuntime bool
localImage bool
}
1 change: 0 additions & 1 deletion pkg/docker/command/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,4 @@ const R8PythonVersionEnvVarName = "R8_PYTHON_VERSION"
var CogConfigLabelKey = global.LabelNamespace + "config"
var CogVersionLabelKey = global.LabelNamespace + "version"
var CogOpenAPISchemaLabelKey = global.LabelNamespace + "openapi_schema"
var CogWeightsManifestLabelKey = global.LabelNamespace + "r8_weights_manifest"
var CogModelDependenciesLabelKey = global.LabelNamespace + "r8_model_dependencies"
26 changes: 0 additions & 26 deletions pkg/docker/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package docker

import (
"context"
"encoding/json"
"errors"
"fmt"
"io"
Expand All @@ -13,7 +12,6 @@ import (

"github.com/replicate/cog/pkg/docker/command"
"github.com/replicate/cog/pkg/util/console"
"github.com/replicate/cog/pkg/weights"
)

var ErrMissingDeviceDriver = errors.New("Docker is missing required device driver")
Expand Down Expand Up @@ -71,27 +69,3 @@ func GetHostPortForContainer(ctx context.Context, dockerCommand command.Command,

return 0, fmt.Errorf("container %s does not have a port bound to 0.0.0.0", containerID)
}

func FillInWeightsManifestVolumes(ctx context.Context, dockerCommand command.Command, runOptions command.RunOptions) (command.RunOptions, error) {
// Check if the image has a weights manifest
manifest, err := dockerCommand.Inspect(ctx, runOptions.Image)
if err != nil {
return runOptions, err
}
weightsManifest, ok := manifest.Config.Labels[command.CogWeightsManifestLabelKey]
if ok {
var weightsPaths []weights.WeightManifest
err = json.Unmarshal([]byte(weightsManifest), &weightsPaths)
if err != nil {
return runOptions, err
}
for _, weightPath := range weightsPaths {
runOptions.Volumes = append(runOptions.Volumes, command.Volume{
Source: weightPath.Source,
Destination: "/src/" + weightPath.Destination,
})
}
}

return runOptions, nil
}
2 changes: 1 addition & 1 deletion pkg/dockerfile/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ func (g *BaseImageGenerator) GenerateDockerfile(ctx context.Context) (string, er
return "", err
}

generator, err := NewGenerator(conf, "", false, g.command, true, g.client, false)
generator, err := NewGenerator(conf, "", false, g.command, g.client, false)
if err != nil {
return "", err
}
Expand Down
Loading