Skip to content

feat: support cog init with pipeline template #2437

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jul 2, 2025

Conversation

markphelps
Copy link
Contributor

@markphelps markphelps commented Jul 2, 2025

Fixes: DP-85

Adds the --x-pipeline flag to cog init to create a pipeline template for cog

/tmp/cog-pipeline-test » /usr/local/bin/cog init --x-pipeline

Setting up the current directory for use with Cog...

✅ Created /tmp/cog-pipeline-test/.dockerignore
✅ Created /tmp/cog-pipeline-test/cog.yaml
✅ Created /tmp/cog-pipeline-test/main.py
✅ Created /tmp/cog-pipeline-test/requirements.txt

Done! For next steps, check out the docs at https://cog.run/getting-started
/tmp/cog-pipeline-test » ls -la
total 32
drwxr-xr-x@ 6 markphelps  wheel  192 Jul  2 12:57 .
drwxrwxrwt  9 root        wheel  288 Jul  2 12:55 ..
-rw-r--r--@ 1 markphelps  wheel  366 Jul  2 12:57 .dockerignore
-rw-r--r--@ 1 markphelps  wheel  455 Jul  2 12:57 cog.yaml
-rw-r--r--@ 1 markphelps  wheel  679 Jul  2 12:57 main.py
-rw-r--r--@ 1 markphelps  wheel  652 Jul  2 12:57 requirements.txt

Example

/tmp/cog-pipeline-test » /usr/local/bin/cog predict \
  -i prompt="A tiny tiger in the rain" \
  --use-replicate-token

output

Notes/Questions

  1. I didnt include a github actions template like the regular init as I wasnt sure what inputs it would take/how it should work
  2. I also chose to keep --x-pipeline flag hidden (from cli usage) as this matches cog push where -x-pipeline is also a hidden flag
  3. Should we output or link to run instructions? Ie that you have to use the --x-pipeline --use-replicate-token flags?

Signed-off-by: Mark Phelps <209477+markphelps@users.noreply.github.com>
@markphelps markphelps requested review from aron, 8W9aG and ethulia July 2, 2025 17:03
Signed-off-by: Mark Phelps <209477+markphelps@users.noreply.github.com>
Signed-off-by: Mark Phelps <209477+markphelps@users.noreply.github.com>
@markphelps markphelps requested a review from zeke July 2, 2025 17:09
@@ -0,0 +1,27 @@
# This is a normal Python requirements.txt file.
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we remove this file? We don't support additional python packages in pipelines so it might lead to user confusion

Copy link
Contributor Author

@markphelps markphelps Jul 2, 2025

Choose a reason for hiding this comment

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

in the web editor it has these contents:

# IMPORTANT: The requirements.txt is only for local development,
# it will be ignored in production.
replicate>=1.1.0b1,<2.0.0a1

What is considered 'local' ?

Copy link

Choose a reason for hiding this comment

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

Since we don't support requirements.txt (aka custom dependencies) for pipelines running on Replicate, and we expect pretty much everyone to be developing pipelines so that they can eventually run them on Replicate (vs wanting to run them purely locally), we should just build the init under that assumption.

Signed-off-by: Mark Phelps <209477+markphelps@users.noreply.github.com>
Signed-off-by: Mark Phelps <209477+markphelps@users.noreply.github.com>
…replicate/cog into feat/add-init-pipelines-support

* 'feat/add-init-pipelines-support' of https://github.com/replicate/cog:
  Move to CDN for monobase matrix.json
@markphelps markphelps requested review from 8W9aG and michaeldwan July 2, 2025 19:10
@markphelps markphelps merged commit 138ec81 into main Jul 2, 2025
24 of 26 checks passed
@markphelps markphelps deleted the feat/add-init-pipelines-support branch July 2, 2025 20:52
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.

3 participants