Move examples from cog-examples to cog#3055
Conversation
There was a problem hiding this comment.
I'm Bonk, and I've done a quick review of your PR.
This PR moves example models from the external cog-examples repo into the main cog repo and updates the test harness to support base_dir for local models. Good cleanup overall.
I found two actionable issues:
- HIGH: The
managed-weightsweights.lockwas regenerated from incomplete/stub weights. The parakeetmodel.safetensorsis listed as 135 bytes instead of ~2.5GB. - MEDIUM: The
hello-trainmodel lost itstrain_testsentry in the manifest, removing training test coverage even though the example still supports training.
|
I'm Bonk, and I've done a quick review of your PR. Summary: Moves example models from Issues found:
|
There was a problem hiding this comment.
I'm Bonk, and I've done a quick review of your PR.
Summary: Moves example models from cog-examples into the main repo and updates the test harness to support base_dir for local models.
Issues found:
-
HIGH —
examples/managed-weights/weights.lockwas regenerated from incomplete/stub weights. The parakeetmodel.safetensorsis listed as 135 bytes instead of ~2.5GB, and the total size dropped from ~2.5GB to ~1.1MB. Please regenerate from the actual weights or revert this file. -
MEDIUM —
hello-trainlost itstrain_testsentry intools/test-harness/manifest.yamleven though the example still containstrain.pyand atrain:field incog.yaml. This removes training test coverage. I've posted a suggestion to restore it. -
MEDIUM —
examples/z-image-turbo/run.pyusestempfile.mktemp()which creates a predictable temporary file path (flagged by CodeQL). Replace withtempfile.NamedTemporaryFile(delete=False)for safety. -
MEDIUM —
examples/hello-concurrency/run.pyhas an emptyexcept FileNotFoundError: passblock. Add a logging statement to document the intent.
|
I'm Bonk, and I've done a quick review of your PR. Summary: Moves example models from Issues found:
|
There was a problem hiding this comment.
I'm Bonk, and I've done a quick review of your PR.
Summary: Moves example models from cog-examples into the main repo and updates the test harness to support base_dir for local models.
Issues found:
- MEDIUM —
examples/blur/run.pyreturns the built-ininputfunction instead of theimageparameter whenblur == 0. This is a logic bug. - MEDIUM —
hello-trainis still missing itstrain_testsentry intools/test-harness/manifest.yamleven though the example containstrain.pyand atrain:field incog.yaml. This removes training test coverage.
|
I'm Bonk, and I've done a quick review of your PR. Summary: Moves example models from Issues found:
Both issues have suggestions posted as review comments. |
There was a problem hiding this comment.
I'm Bonk, and I've done a quick review of your PR.
Summary: Moves example models from cog-examples into the main repo and updates the test harness to support base_dir for local models.
Issues found:
- MEDIUM —
hello-trainis still missing itstrain_testsentry intools/test-harness/manifest.yamleven though the example containstrain.pyand atrain:field incog.yaml. The test harness still fully supportstrain_tests(seemanifest.goandrunner.go), and there is no visible replacement mechanism or deprecation marker in the codebase. Removing the only training test without a documented alternative creates a coverage gap.
|
I'm Bonk, and I've done a quick review of your PR. Summary: Moves example models from Issues found:
Posted as review comment on PR #3055. |
There was a problem hiding this comment.
I'm Bonk, and I've done a quick review of your PR.
Summary: Moves example models from cog-examples into the main repo, updates the test harness for base_dir support, and adds Secret type coercion in coglet.
Issues found:
-
HIGH — The new Secret coercion in
crates/coglet-python/src/input.rscallsSecret(value)in Python, but the PythonSecretclass inpython/cog/types.pydoes not define an__init__that accepts arguments. This will raiseTypeError: Secret() takes no argumentsat runtime when any predictor declares aSecret-typed input. -
MEDIUM —
hello-trainis still missing itstrain_testsentry intools/test-harness/manifest.yamleven though the example containstrain.pyand atrain:field incog.yaml. The test harness still processestrain_tests(seemanifest.goandrunner.go), and there is no deprecation marker or replacement mechanism visible in the code. Removing the only training test creates a coverage gap.
|
Done. I posted a review on PR #3055 with two actionable issues:
|
- Document list[Secret] coercion exclusion in coglet input handling - Fix stale 'predict.py' comments in example cog.yaml files - Correct hello-train README to use 'cog predict' - Add trailing newlines to example cog.yaml files - Only pass --setup-timeout for 'cog predict' (not 'cog train') - Re-add train_tests for hello-train
|
@anish-sahoo Bonk workflow was cancelled. View workflow run · To retry, trigger Bonk again. |
markphelps
left a comment
There was a problem hiding this comment.
Non-Secret review comments from a focused pass on the example migration and test harness. I left Secret/coglet scope comments out separately.
markphelps
left a comment
There was a problem hiding this comment.
I think the coglet Secret input support should be pulled out into a separate PR. This PR is already large and is primarily about moving/modernizing examples; adding new runtime input coercion behavior changes the review surface and deserves its own focused tests/review.
For this PR, can we either:
- remove the coglet Secret changes and any example/test-harness dependency on them, or
- keep the hello-replicate example only if it works with existing released behavior / reads REPLICATE_API_TOKEN from env rather than requiring new coglet Secret coercion?
Then a follow-up PR can add Secret, Optional[Secret], and any list/edge-case behavior with dedicated coglet tests.
- Remove coglet Secret coercion (moved to dedicated PR #3057) - Remove hello-replicate example and its test-harness entry (moved to #3057) - Drop Secret usage from the scalar-types fixture - Gate managed-weights harness run behind COG_MANAGED_WEIGHTS_READY - Fix stale predict.py/run.py and max:32/max:4 references in hello-concurrency README - Fix hello-context README to match the text input - Fix resnet README to describe GPU + torchvision setup-time weight fetch - Update resnet-managed-weights README to reference model: instead of image:
|
Re: pulling the coglet |
|
LGTM |
- Resolve local models by base_dir (relative to repo root) instead of requiring 'repo: local'; precedence is base_dir, then repo, then the default fixtures/models dir. - Reject 'repo: local' in manifest.Load with a migration message. - Drop redundant 'repo: local' from all manifest entries; examples use 'base_dir: examples', fixtures use 'base_dir: tools/test-harness/fixtures/models'. - Add Model.Source() for clearer 'list' output when repo is empty. - Add tests for resolution, repo:local rejection, and Source().
markphelps
left a comment
There was a problem hiding this comment.
looks great! thank you for taking this on
Moves the example models from the separate
replicate/cog-examplesrepo into this repo underexamples/, migrates them to theBaseRunner/runAPI, and addscog.Secretinput support to coglet.run.py/BaseRunner:blur,canary,hello-concurrency,hello-context,hello-image,hello-replicate,hello-train,hello-world,notebook,z-image-turbostreaming-textexample torun.py/BaseRunnerexamples/resnetwith the classic torchvision ResNet50 classifier (BaseRunner, ImageNet weights bundled with torchvision -- no managed weights or import step), ported and modernized fromreplicate/cog-examplesexamples/experimental/resnet-managed-weights(renamedmodel: resnet-managed-weights)managed-weightscog.yamlto use themodel:field (replacingimage: <your-registry>/...) and refresh itsweights.lockhello-replicatedemonstratesSecretusage by calling the Replicate APIcoglet
cog.Secretinput support: classify and coerceSecret,Optional[Secret], andSecret | Nonefields, wrapping string values incog.types.Secret(list[Secret]is intentionally not coerced)cargo-deny(RUSTSEC-2026-0176,RUSTSEC-2026-0177) with justification; pinned due to numpy/pyo3-async-runtimes lag, and neither code path is reachable in coglettest harness
base_dirfield forrepo: localmodels so local models resolve relative to the manifest (defaults tofixtures/models/)manifest.yamlat the localexamples/directory instead ofreplicate/cog-examplespredict.py/BasePredictortorun.py/BaseRunner--setup-timeouttocog predict(cog traindoes not support it)