feat: Rename predict to run with backward compatibility#3015
feat: Rename predict to run with backward compatibility#3015markphelps wants to merge 3 commits into
Conversation
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
|
I found a bug in the backward compatibility delegation logic in I posted a review with a suggested fix using the existing |
There was a problem hiding this comment.
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.
|
Posted the review comment. The critical issue is the backward compatibility delegation in |
|
LGTM |
Summary
Renames the user-facing
predictconcept torunacross the entire stack while maintaining full backward compatibility.Changes
CLI
cog runcommand (replacescog predictas primary)cog predictkept as deprecated alias with warningcog runhandles both predictions and exec commandsPython SDK
BaseRunnerclass (replacesBasePredictor)run()method (replacespredict())BasePredictorkept as compatibility aliaspredict()still works via two-way delegation bridgeConfiguration
run:field incog.yaml(replacespredict:)predict:still accepted with deprecation warningcog doctor --fixcan auto-migrate common patternsExamples & Docs
predict.py→run.pyin examplesPredictor→Runnerin examplesTests
Backward Compatibility
All existing models continue to work without changes:
cog predict→ works with warningBasePredictor→ works with warningpredict()→ works with warningpredict:in cog.yaml → works with warning