@@ -46,8 +46,7 @@ const StripDebugSymbolsCommand = "find / -type f -name \"*python*.so\" -not -nam
4646const CFlags = "ENV CFLAGS=\" -O3 -funroll-loops -fno-strict-aliasing -flto -S\" "
4747const PrecompilePythonCommand = "RUN find / -type f -name \" *.py[co]\" -delete && find / -type f -name \" *.py\" -exec touch -t 197001010000 {} \\ ; && find / -type f -name \" *.py\" -printf \" %h\\ n\" | sort -u | /usr/bin/python3 -m compileall --invalidation-mode timestamp -o 2 -j 0"
4848const STANDARD_GENERATOR_NAME = "STANDARD_GENERATOR"
49-
50- const AskAboutCogRuntime = false
49+ const PinnedCogletURL = "https://github.com/replicate/cog-runtime/releases/download/v0.1.0-beta10/coglet-0.1.0b10-py3-none-any.whl" // Pinned coglet URL to avoid API dependency
5150
5251type StandardGenerator struct {
5352 Config * config.Config
@@ -449,7 +448,7 @@ RUN rm -rf /usr/bin/python3 && ln -s ` + "`realpath \\`pyenv which python\\`` /u
449448}
450449
451450func (g * StandardGenerator ) installCog () (string , error ) {
452- // FIXME: remove once pipelines use cog_runtime: true
451+ // Skip installing normal cog if coglet is already in requirements
453452 if g .Config .ContainsCoglet () {
454453 return "" , nil
455454 }
@@ -459,18 +458,9 @@ func (g *StandardGenerator) installCog() (string, error) {
459458 return "" , nil
460459 }
461460
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- // }
461+ if g .Config .Build .CogRuntime != nil && * g .Config .Build .CogRuntime {
462+ return g .installCogRuntime ()
463+ }
474464
475465 data , filename , err := ReadWheelFile ()
476466 if err != nil {
@@ -490,79 +480,18 @@ func (g *StandardGenerator) installCog() (string, error) {
490480 return strings .Join (lines , "\n " ), nil
491481}
492482
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- // }
483+ func (g * StandardGenerator ) installCogRuntime () (string , error ) {
484+ // We need fast-* compliant Python version to reconstruct coglet venv PYTHONPATH
485+ if ! CheckMajorMinorOnly (g .Config .Build .PythonVersion ) {
486+ return "" , fmt .Errorf ("Python version must be <major>.<minor>" )
487+ }
488+ cmds := []string {
489+ "ENV R8_COG_VERSION=coglet" ,
490+ "ENV R8_PYTHON_VERSION=" + g .Config .Build .PythonVersion ,
491+ "RUN pip install " + PinnedCogletURL ,
492+ }
493+ return strings .Join (cmds , "\n " ), nil
494+ }
566495
567496func (g * StandardGenerator ) pipInstalls () (string , error ) {
568497 var err error
0 commit comments