Skip to content

feat: Rename predict to run with backward compatibility#3015

Draft
markphelps wants to merge 3 commits into
mainfrom
rename-predict-run
Draft

feat: Rename predict to run with backward compatibility#3015
markphelps wants to merge 3 commits into
mainfrom
rename-predict-run

Conversation

@markphelps
Copy link
Copy Markdown
Contributor

Summary

Renames the user-facing predict concept to run across the entire stack while maintaining full backward compatibility.

Changes

CLI

  • New cog run command (replaces cog predict as primary)
  • cog predict kept as deprecated alias with warning
  • Smart dispatch: cog run handles both predictions and exec commands

Python SDK

  • New BaseRunner class (replaces BasePredictor)
  • New run() method (replaces predict())
  • BasePredictor kept as compatibility alias
  • predict() still works via two-way delegation bridge

Configuration

  • New run: field in cog.yaml (replaces predict:)
  • predict: still accepted with deprecation warning
  • cog doctor --fix can auto-migrate common patterns

Examples & Docs

  • predict.pyrun.py in examples
  • PredictorRunner in examples
  • README.md, docs, architecture docs updated

Tests

  • Integration tests for both legacy and new interfaces
  • Doctor migration tests
  • Deprecation warning tests

Backward Compatibility

All existing models continue to work without changes:

  • cog predict → works with warning
  • BasePredictor → works with warning
  • predict() → works with warning
  • predict: in cog.yaml → works with warning

Rename the user-facing predict concept to run across the entire stack:
- CLI: cog predict → cog run (predict kept as deprecated alias)
- Python SDK: BasePredictor → BaseRunner, predict() → run()
- Config: predict: → run: in cog.yaml
- Examples: predict.py → run.py, Predictor → Runner

Backward compatibility maintained throughout:
- cog predict still works with deprecation warning
- BasePredictor kept as alias for BaseRunner
- predict() method still works
- predict: in cog.yaml still accepted

Also includes:
- Doctor check with auto-migration for common patterns
- Integration tests for both legacy and new interfaces
- Updated documentation and examples
Comment thread python/tests/test_predictor.py Fixed
Comment thread python/cog/_inspector.py Fixed
Copy link
Copy Markdown
Contributor

@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.

I'm Bonk, and I've done a quick review of your PR. This PR renames predict to run across the entire stack while maintaining full backward compatibility.

Comment thread python/cog/predictor.py Outdated
Comment thread pkg/doctor/check_predict_to_run_migration.go
Comment thread pkg/schema/python/parser.go
Comment thread python/cog/__init__.py
@ask-bonk
Copy link
Copy Markdown
Contributor

ask-bonk Bot commented May 12, 2026

I found a bug in the backward compatibility delegation logic in python/cog/predictor.py. The condition on line 76 checks if "predict" is in the class __dict__ but "run" is not. However, since BaseRunner defines run(), both methods will be in the class __dict__ when a user only overrides predict(), so the fallback to self.predict(**kwargs) will never trigger.

I posted a review with a suggested fix using the existing _user_method_owner() helper function which correctly walks the MRO to find where methods are actually defined.

github run

Copy link
Copy Markdown
Contributor

@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.

I found one critical bug in the backward compatibility delegation logic that needs to be fixed before this can be merged. The delegation bridge in python/cog/predictor.py doesn't work correctly for user classes that only override predict().

The issue is that the condition checks if "predict" is in the class __dict__ but "run" is not. However, since BaseRunner defines run(), both methods will be in the class __dict__, so the fallback never triggers.

I've provided a suggestion with the fix using the existing _user_method_owner() helper.

Comment thread python/cog/predictor.py
@ask-bonk
Copy link
Copy Markdown
Contributor

ask-bonk Bot commented May 12, 2026

Posted the review comment. The critical issue is the backward compatibility delegation in python/cog/predictor.py line 76 - it needs to use _user_method_owner() to correctly detect when a user class only overrides predict().

github run

@ask-bonk
Copy link
Copy Markdown
Contributor

ask-bonk Bot commented May 12, 2026

LGTM

github run

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.

1 participant