Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
7ab4d5f
feat(doctor): add core types and Check interface
markphelps Apr 9, 2026
d2f1980
refactor(schema): export tree-sitter helpers for reuse by doctor checks
markphelps Apr 9, 2026
d2ba918
feat(doctor): add runner with check orchestration and fix flow
markphelps Apr 9, 2026
4c7f252
feat(doctor): add check registry
markphelps Apr 9, 2026
dc23230
feat(doctor): add CLI command with output formatting
markphelps Apr 9, 2026
96ee37e
feat(doctor): add config parse check
markphelps Apr 9, 2026
7c5d1f1
feat(doctor): add deprecated config fields check
markphelps Apr 9, 2026
158968b
feat(doctor): add predict reference check
markphelps Apr 9, 2026
f33aaff
feat(doctor): add pydantic BaseModel check with auto-fix
markphelps Apr 9, 2026
f2275f4
feat(doctor): add deprecated imports check with auto-fix
markphelps Apr 9, 2026
5967098
feat(doctor): add Docker availability check
markphelps Apr 9, 2026
7363db2
feat(doctor): add Python version check
markphelps Apr 9, 2026
7c35c14
feat(doctor): add config schema validation check
markphelps Apr 9, 2026
bdab4b1
feat(doctor): add missing type annotations check
markphelps Apr 9, 2026
f889818
fix(doctor): address lint issues in printDoctorResults
markphelps Apr 9, 2026
3a96760
test(doctor): add integration tests for cog doctor command
markphelps Apr 9, 2026
c8dd36f
Merge branch 'main' into cog-doctor
markphelps Apr 9, 2026
43b831e
fix(doctor): address review findings — fix correctness bugs, consolid…
markphelps Apr 9, 2026
bf45c61
chore: update cli docs
markphelps Apr 9, 2026
98fcd5a
chore: update llms docs
markphelps Apr 9, 2026
9bcbd79
Merge branch 'main' into cog-doctor
markphelps Apr 10, 2026
ca41884
Update pkg/doctor/runner.go
markphelps Apr 13, 2026
edf71a3
Merge branch 'cog-doctor' of https://github.com/replicate/cog into co…
markphelps Apr 13, 2026
af0d2ec
chore: fix context passing
markphelps Apr 13, 2026
5b5008d
fix: remove deprecated name references and orphaned imports in doctor…
markphelps Apr 13, 2026
2401425
chore: pass context
markphelps Apr 13, 2026
ea97668
fix: pass context.Background() in deprecated imports fix tests
markphelps Apr 13, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,24 @@ cog build [flags]
--use-cog-base-image Use pre-built Cog base image for faster cold boots (default true)
--use-cuda-base-image string Use Nvidia CUDA base image, 'true' (default) or 'false' (use python base image). False results in a smaller image but may cause problems for non-torch projects (default "auto")
```
## `cog doctor`

Diagnose and fix common issues in your Cog project.

By default, cog doctor reports problems without modifying any files.
Pass --fix to automatically apply safe fixes.

```
cog doctor [flags]
```

**Options**

```
-f, --file string The name of the config file. (default "cog.yaml")
--fix Automatically apply fixes
-h, --help help for doctor
```
## `cog exec`

Execute a command inside a Docker environment defined by cog.yaml.
Expand Down
18 changes: 18 additions & 0 deletions docs/llms.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions integration-tests/tests/doctor_clean_project.txtar
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Test that cog doctor succeeds on a valid project with no issues.

cog doctor
stderr 'no issues found'

-- cog.yaml --
build:
python_version: "3.12"
predict: "predict.py:Predictor"

-- predict.py --
from cog import BasePredictor


class Predictor(BasePredictor):
def predict(self, text: str) -> str:
return "hello " + text
21 changes: 21 additions & 0 deletions integration-tests/tests/doctor_deprecated_fields.txtar
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Test that cog doctor reports deprecated config fields as warnings.
# Warnings do not cause a non-zero exit code; only errors do.

cog doctor
stderr 'python_packages'
stderr 'deprecated'

-- cog.yaml --
build:
python_version: "3.12"
python_packages:
- torch==2.0.0
predict: "predict.py:Predictor"

-- predict.py --
from cog import BasePredictor


class Predictor(BasePredictor):
def predict(self, text: str) -> str:
return "hello " + text
23 changes: 23 additions & 0 deletions integration-tests/tests/doctor_deprecated_imports.txtar
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Test that cog doctor detects deprecated imports.
# ExperimentalFeatureWarning was removed in cog 0.17.

! cog doctor
stderr 'ExperimentalFeatureWarning'
stderr 'removed'

-- cog.yaml --
build:
python_version: "3.12"
predict: "predict.py:Predictor"

-- predict.py --
import warnings
from cog import BasePredictor
from cog.types import ExperimentalFeatureWarning

warnings.filterwarnings("ignore", category=ExperimentalFeatureWarning)


class Predictor(BasePredictor):
def predict(self, text: str) -> str:
return "hello " + text
10 changes: 10 additions & 0 deletions integration-tests/tests/doctor_exit_code.txtar
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Test that cog doctor exits with code 1 when predict file is missing.

! cog doctor
stderr 'predict.py'
stderr 'not found'

-- cog.yaml --
build:
python_version: "3.12"
predict: "predict.py:Predictor"
35 changes: 35 additions & 0 deletions integration-tests/tests/doctor_fix_deprecated_imports.txtar
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Test that cog doctor --fix removes deprecated imports.

# First, doctor should detect the issue
! cog doctor
stderr 'ExperimentalFeatureWarning'

# Fix the issue
cog doctor --fix
stderr 'Fixed'

# Verify the import was removed from the file
exec cat predict.py
! stdout 'ExperimentalFeatureWarning'
! stdout 'cog.types'

# Re-running doctor should now pass
cog doctor
stderr 'no issues found'

-- cog.yaml --
build:
python_version: "3.12"
predict: "predict.py:Predictor"

-- predict.py --
import warnings
from cog import BasePredictor
from cog.types import ExperimentalFeatureWarning

warnings.filterwarnings("ignore", category=ExperimentalFeatureWarning)


class Predictor(BasePredictor):
def predict(self, text: str) -> str:
return "hello " + text
41 changes: 41 additions & 0 deletions integration-tests/tests/doctor_fix_pydantic.txtar
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Test that cog doctor --fix rewrites pydantic.BaseModel to cog.BaseModel.
# After fix, re-running cog doctor should pass.

# First, doctor should detect the issue
! cog doctor
stderr 'pydantic.BaseModel'

# Fix the issue
cog doctor --fix
stderr 'Fixed'

# Verify the file was modified: pydantic.BaseModel replaced with cog.BaseModel
exec cat predict.py
stdout 'from cog import BasePredictor, Path, BaseModel'
! stdout 'from pydantic import BaseModel'
! stdout 'ConfigDict'
! stdout 'arbitrary_types_allowed'

# Re-running doctor should now pass
cog doctor
stderr 'no issues found'

-- cog.yaml --
build:
python_version: "3.12"
predict: "predict.py:Predictor"

-- predict.py --
from cog import BasePredictor, Path
from pydantic import BaseModel, ConfigDict


class VoiceCloningOutputs(BaseModel):
model_config = ConfigDict(arbitrary_types_allowed=True)
audio: Path
spectrogram: Path


class Predictor(BasePredictor):
def predict(self, text: str) -> VoiceCloningOutputs:
return VoiceCloningOutputs(audio="a.wav", spectrogram="s.png")
19 changes: 19 additions & 0 deletions integration-tests/tests/doctor_missing_predict_ref.txtar
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Test that cog doctor detects when predict ref points to a nonexistent class.
# cog.yaml references DoesNotExist but only Predictor exists in predict.py.

! cog doctor
stderr 'DoesNotExist'
stderr 'not found'

-- cog.yaml --
build:
python_version: "3.12"
predict: "predict.py:DoesNotExist"

-- predict.py --
from cog import BasePredictor


class Predictor(BasePredictor):
def predict(self, text: str) -> str:
return "hello " + text
26 changes: 26 additions & 0 deletions integration-tests/tests/doctor_pydantic_basemodel.txtar
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Test that cog doctor detects pydantic.BaseModel with arbitrary_types_allowed.
# This is a common workaround that should use cog.BaseModel instead.

! cog doctor
stderr 'pydantic.BaseModel'
stderr 'cog.BaseModel'

-- cog.yaml --
build:
python_version: "3.12"
predict: "predict.py:Predictor"

-- predict.py --
from cog import BasePredictor, Path
from pydantic import BaseModel, ConfigDict


class VoiceCloningOutputs(BaseModel):
model_config = ConfigDict(arbitrary_types_allowed=True)
audio: Path
spectrogram: Path


class Predictor(BasePredictor):
def predict(self, text: str) -> VoiceCloningOutputs:
return VoiceCloningOutputs(audio="a.wav", spectrogram="s.png")
Loading
Loading