Skip to content

Rename cog run to cog exec#2916

Merged
markphelps merged 3 commits intomainfrom
cog-run
Apr 8, 2026
Merged

Rename cog run to cog exec#2916
markphelps merged 3 commits intomainfrom
cog-run

Conversation

@markphelps
Copy link
Copy Markdown
Contributor

Summary

  • Renames the cog run command to cog exec to free up the run verb for predictions
  • Keeps cog run as a hidden alias with a deprecation warning printed to stderr so existing scripts don't break
  • Uses Cobra's Aliases field — single command definition, no duplicated flag registration

Changes

Go (4 files)

  • pkg/cli/run.gopkg/cli/exec.go: renamed command constructor, handler, and port variable; added Aliases: []string{"run"} and deprecation warning via cmd.CalledAs()
  • pkg/cli/root.go: updated command registration and root example text
  • pkg/model/options.go, pkg/image/build.go: updated comments

Integration tests (6 files, 3 renamed)

  • run_basic.txtarexec_basic.txtar, run_stdin_cat.txtarexec_stdin_cat.txtar, run_stdin_unconsumed.txtarexec_stdin_unconsumed.txtar
  • pty_echo.txtar, pty_interactive.txtar, config_subdirectory.txtar: updated commands

Docs (auto-generated + manual)

  • docs/cli.md and docs/llms.txt: regenerated
  • docs/getting-started.md, docs/getting-started-own-model.md, docs/notebooks.md, docs/yaml.md: updated examples
  • README.md, architecture/06-cli.md, architecture/04-container-runtime.md, integration-tests/README.md: updated references

Testing

  • mise run lint:go — 0 issues
  • mise run test:go — all tests pass
  • mise run docs:cli:check — docs up to date
  • cog exec --help shows the new command
  • cog run --help works via alias
  • cog --help only lists exec (alias is hidden)

Reclaim the `run` verb for predictions by moving the arbitrary-command
runner to `cog exec`. `cog run` remains as a hidden alias with a
deprecation warning so existing scripts continue to work.

- Rename pkg/cli/run.go -> pkg/cli/exec.go
- Use Cobra Aliases for the backward-compatible `run` alias
- Print deprecation warning to stderr when invoked as `cog run`
- Update integration tests, docs, and architecture references
- Regenerate docs/cli.md and docs/llms.txt
@ask-bonk
Copy link
Copy Markdown

ask-bonk bot commented Apr 8, 2026

LGTM

github run

- Add exec_run_deprecated.txtar to verify 'cog run' alias works and
  emits a deprecation warning (matches train_deprecated.txtar pattern)
- Fix AGENTS.md: 'build, run, predict' -> 'build, exec, predict'
@ask-bonk
Copy link
Copy Markdown

ask-bonk bot commented Apr 8, 2026

I reviewed PR #2916 by loading the relevant review skills and examining the key changed files including pkg/cli/exec.go, pkg/cli/root.go, and the integration tests. I verified the deprecation warning implementation, checked that all documentation comments were updated from "cog run" to "cog exec", and confirmed the test coverage for both the new command and the deprecated alias. Finding no actionable issues, I marked the PR as LGTM.

github run

Switch from raw fmt.Fprintln(os.Stderr) to console.Warn() for the
'cog run' deprecation message, consistent with how warnings are
emitted elsewhere in the CLI.
Copy link
Copy Markdown

@ask-bonk ask-bonk bot left a comment

Choose a reason for hiding this comment

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

This PR renames cog run to cog exec while maintaining backward compatibility via a hidden alias with deprecation warning. The implementation looks solid overall with proper use of Cobra's Aliases field and appropriate deprecation messaging.

One minor issue with a comment referencing the wrong command:


// The final image ID comes from the label-adding step.
// When schema validation is skipped (cog run), there is no schema file to bundle.
// When schema validation is skipped (cog exec), there is no schema file to bundle.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The comment mentions cog exec but the condition checks skipSchemaValidation which is used by cog exec, cog predict, cog serve, and cog train (per the comment on line 290). The comment should be more accurate:

Suggested change
// When schema validation is skipped (cog exec), there is no schema file to bundle.
// The final image ID comes from the label-adding step.
// When schema validation is skipped (cog exec/predict/serve/train), there is no schema file to bundle.

@ask-bonk
Copy link
Copy Markdown

ask-bonk bot commented Apr 8, 2026

I'm Bonk, and I've done a quick review of your PR.

This PR renames cog run to cog exec while maintaining backward compatibility via a hidden alias with deprecation warning. The implementation looks solid with proper use of Cobra's Aliases field and appropriate deprecation messaging.

Minor issue:

In pkg/image/build.go:390-391, the comment mentions "When schema validation is skipped (cog exec)" but skipSchemaValidation is also used by cog predict, cog serve, and cog train (as noted on line 290). The comment should be updated to reflect this.

github run

@markphelps markphelps marked this pull request as ready for review April 8, 2026 14:39
@markphelps markphelps requested a review from a team as a code owner April 8, 2026 14:39
@markphelps markphelps requested a review from michaeldwan April 8, 2026 14:39
Copy link
Copy Markdown
Member

@michaeldwan michaeldwan left a comment

Choose a reason for hiding this comment

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

👍

@michaeldwan michaeldwan added this pull request to the merge queue Apr 8, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Apr 8, 2026
@markphelps markphelps merged commit ba48ff8 into main Apr 8, 2026
87 of 91 checks passed
@markphelps markphelps deleted the cog-run branch April 8, 2026 18:10
markphelps added a commit that referenced this pull request Apr 8, 2026
…icate/cog into mphelps/push-phase-progress

* 'mphelps/push-phase-progress' of https://github.com/replicate/cog: (95 commits)
  feat: add metric name validation (#2911)
  Rename `cog run` to `cog exec` (#2916)
  chore(deps): bump github.com/google/go-containerregistry (#2884)
  fix: replace removed libgl1-mesa-glx in tensorflow integration test (#2914)
  ci: enforce stub freshness in CI, fix existing stub drift (#2912)
  feat: add schema-compare command to test harness (#2891)
  chore(deps): bump uuid from 1.22.0 to 1.23.0 in /crates (#2887)
  chore(deps): bump github.com/hashicorp/go-version from 1.7.0 to 1.9.0 (#2909)
  chore(deps): bump insta from 1.46.3 to 1.47.2 in /crates (#2908)
  fix: support list[X] | None inputs + integration tests for PEP 604 union File/Path coercion (#2882)
  ci: exclude Dependabot PRs from auto-code review (#2910)
  chore(deps): bump actions/checkout from 4 to 6 (#2904)
  chore(deps): bump github.com/testcontainers/testcontainers-go/modules/registry (#2886)
  fix: metrics bugs in coglet prediction server (#2896)
  Bump version to 0.17.2 (#2903)
  fix(coglet): propagate metric scope to async event loop thread (#2902)
  chore: remove unnecessary nolint directive in test (#2803)
  feat(coglet): add Sentry error reporting for infrastructure errors (#2865)
  fix: homebrew cask postflight xattr references wrong binary name (#2899)
  fix: include custom metrics in cog predict --json output (#2897)
  ...
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.

2 participants