Skip to content

Commit bf754a6

Browse files
authored
disable cog-runtime support and prompts (#2511)
* disable cog-runtime support and prompts * comment out unused functions maybe the linter will be cool with it...
1 parent 908007f commit bf754a6

File tree

1 file changed

+85
-87
lines changed

1 file changed

+85
-87
lines changed

pkg/dockerfile/standard_generator.go

Lines changed: 85 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package dockerfile
33
import (
44
"context"
55
"fmt"
6-
"net/http"
76
"os"
87
"path"
98
"path/filepath"
@@ -14,13 +13,10 @@ import (
1413
"github.com/replicate/cog/pkg/docker/command"
1514
"github.com/replicate/cog/pkg/dockercontext"
1615
"github.com/replicate/cog/pkg/registry"
17-
"github.com/replicate/cog/pkg/util"
1816
"github.com/replicate/cog/pkg/util/console"
1917
"github.com/replicate/cog/pkg/util/slices"
2018
"github.com/replicate/cog/pkg/util/version"
2119
"github.com/replicate/cog/pkg/weights"
22-
"golang.org/x/term"
23-
"gopkg.in/yaml.v2"
2420
)
2521

2622
const DockerignoreHeader = `# generated by replicate/cog
@@ -463,16 +459,18 @@ func (g *StandardGenerator) installCog() (string, error) {
463459
return "", nil
464460
}
465461

466-
if g.Config.Build.CogRuntime != nil && *g.Config.Build.CogRuntime {
467-
return g.installCogRuntime()
468-
}
469-
accepted, err := g.askAboutCogRuntime()
470-
if err != nil {
471-
return "", err
472-
}
473-
if accepted {
474-
return g.installCogRuntime()
475-
}
462+
// completely disable cog-runtime since it's not compatible with non-procedure models!
463+
// TODO[md]: remove this once we sort out a path forward for cog-runtime
464+
// if g.Config.Build.CogRuntime != nil && *g.Config.Build.CogRuntime {
465+
// return g.installCogRuntime()
466+
// }
467+
// accepted, err := g.askAboutCogRuntime()
468+
// if err != nil {
469+
// return "", err
470+
// }
471+
// if accepted {
472+
// return g.installCogRuntime()
473+
// }
476474

477475
data, filename, err := ReadWheelFile()
478476
if err != nil {
@@ -492,79 +490,79 @@ func (g *StandardGenerator) installCog() (string, error) {
492490
return strings.Join(lines, "\n"), nil
493491
}
494492

495-
func (g *StandardGenerator) installCogRuntime() (string, error) {
496-
// We need fast-* compliant Python version to reconstruct coglet venv PYTHONPATH
497-
if !CheckMajorMinorOnly(g.Config.Build.PythonVersion) {
498-
return "", fmt.Errorf("Python version must be <major>.<minor>")
499-
}
500-
m, err := NewMonobaseMatrix(http.DefaultClient)
501-
if err != nil {
502-
return "", err
503-
}
504-
cmds := []string{
505-
"ENV R8_COG_VERSION=coglet",
506-
"ENV R8_PYTHON_VERSION=" + g.Config.Build.PythonVersion,
507-
"RUN pip install " + m.LatestCoglet.URL,
508-
}
509-
return strings.Join(cmds, "\n"), nil
510-
}
511-
512-
func (g *StandardGenerator) askAboutCogRuntime() (bool, error) {
513-
// Training is not supported
514-
if g.Config.Train != "" {
515-
return false, nil
516-
}
517-
// Only warn if cog_runtime is not explicitly set
518-
if g.Config.Build.CogRuntime != nil {
519-
return false, nil
520-
}
521-
522-
console.Warnf("Major Cog runtime upgrade available. Opt in now by setting build.cog_runtime: true in cog.yaml.")
523-
console.Warnf("More: https://replicate.com/changelog/2025-07-21-cog-runtime")
524-
525-
// Do not ask until we're ready
526-
if !AskAboutCogRuntime {
527-
return false, nil
528-
}
529-
530-
// Skip question if not in an interactive shell
531-
if !term.IsTerminal(int(os.Stdin.Fd())) || !term.IsTerminal(int(os.Stdout.Fd())) || !term.IsTerminal(int(os.Stderr.Fd())) {
532-
return false, nil
533-
}
534-
535-
interactive := &console.InteractiveBool{
536-
Prompt: "Do you want to switch to the new Cog runtime?",
537-
Default: true,
538-
// NonDefaultFlag is not applicable here
539-
}
540-
cogRuntime, err := interactive.Read()
541-
if err != nil {
542-
return false, fmt.Errorf("failed to read from stdin: %v", err)
543-
}
544-
// Only add cog_runtime: true to cog.yaml if answer is yes
545-
// Otherwise leave it absent so we keep nagging
546-
if !cogRuntime {
547-
console.Warnf("Not switching. Add build.cog_runtime: false to disable this reminder.")
548-
return false, nil
549-
}
550-
g.Config.Build.CogRuntime = &cogRuntime
551-
552-
console.Infof("Adding build.cog_runtime: true to %s", g.Config.Filename())
553-
newYaml, err := yaml.Marshal(g.Config)
554-
if err != nil {
555-
return false, err
556-
}
557-
path := filepath.Join(g.Dir, g.Config.Filename())
558-
oldYaml, err := os.ReadFile(path)
559-
if err != nil {
560-
return false, err
561-
}
562-
merged, err := util.OverwriteYAML(newYaml, oldYaml)
563-
if err != nil {
564-
return false, err
565-
}
566-
return true, os.WriteFile(path, merged, 0o644)
567-
}
493+
// func (g *StandardGenerator) installCogRuntime() (string, error) {
494+
// // We need fast-* compliant Python version to reconstruct coglet venv PYTHONPATH
495+
// if !CheckMajorMinorOnly(g.Config.Build.PythonVersion) {
496+
// return "", fmt.Errorf("Python version must be <major>.<minor>")
497+
// }
498+
// m, err := NewMonobaseMatrix(http.DefaultClient)
499+
// if err != nil {
500+
// return "", err
501+
// }
502+
// cmds := []string{
503+
// "ENV R8_COG_VERSION=coglet",
504+
// "ENV R8_PYTHON_VERSION=" + g.Config.Build.PythonVersion,
505+
// "RUN pip install " + m.LatestCoglet.URL,
506+
// }
507+
// return strings.Join(cmds, "\n"), nil
508+
// }
509+
510+
// func (g *StandardGenerator) askAboutCogRuntime() (bool, error) {
511+
// // Training is not supported
512+
// if g.Config.Train != "" {
513+
// return false, nil
514+
// }
515+
// // Only warn if cog_runtime is not explicitly set
516+
// if g.Config.Build.CogRuntime != nil {
517+
// return false, nil
518+
// }
519+
520+
// console.Warnf("Major Cog runtime upgrade available. Opt in now by setting build.cog_runtime: true in cog.yaml.")
521+
// console.Warnf("More: https://replicate.com/changelog/2025-07-21-cog-runtime")
522+
523+
// // Do not ask until we're ready
524+
// if !AskAboutCogRuntime {
525+
// return false, nil
526+
// }
527+
528+
// // Skip question if not in an interactive shell
529+
// if !term.IsTerminal(int(os.Stdin.Fd())) || !term.IsTerminal(int(os.Stdout.Fd())) || !term.IsTerminal(int(os.Stderr.Fd())) {
530+
// return false, nil
531+
// }
532+
533+
// interactive := &console.InteractiveBool{
534+
// Prompt: "Do you want to switch to the new Cog runtime?",
535+
// Default: true,
536+
// // NonDefaultFlag is not applicable here
537+
// }
538+
// cogRuntime, err := interactive.Read()
539+
// if err != nil {
540+
// return false, fmt.Errorf("failed to read from stdin: %v", err)
541+
// }
542+
// // Only add cog_runtime: true to cog.yaml if answer is yes
543+
// // Otherwise leave it absent so we keep nagging
544+
// if !cogRuntime {
545+
// console.Warnf("Not switching. Add build.cog_runtime: false to disable this reminder.")
546+
// return false, nil
547+
// }
548+
// g.Config.Build.CogRuntime = &cogRuntime
549+
550+
// console.Infof("Adding build.cog_runtime: true to %s", g.Config.Filename())
551+
// newYaml, err := yaml.Marshal(g.Config)
552+
// if err != nil {
553+
// return false, err
554+
// }
555+
// path := filepath.Join(g.Dir, g.Config.Filename())
556+
// oldYaml, err := os.ReadFile(path)
557+
// if err != nil {
558+
// return false, err
559+
// }
560+
// merged, err := util.OverwriteYAML(newYaml, oldYaml)
561+
// if err != nil {
562+
// return false, err
563+
// }
564+
// return true, os.WriteFile(path, merged, 0o644)
565+
// }
568566

569567
func (g *StandardGenerator) pipInstalls() (string, error) {
570568
var err error

0 commit comments

Comments
 (0)