Skip to content

feat: add ability to skip files that already exist, overwrite or quit #2430

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 5 commits into from
Jul 1, 2025

Conversation

markphelps
Copy link
Contributor

This updates the cog init command to allow for skipping files that already exists either one by one or all at once

It also adds two cli flags --skip-existing and --overwrite-existing which will either:

  1. skip all existing flags without prompting
  2. overwrite all existing flags without prompting

I chose to not just skip existing by default as to be more consistent with the existing behavior, but I could also see the argument that we just want to always skip all existing files.. so would like to get feedback here

Example Run

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

File cog.yaml already exists. What would you like to do? (default: skip, options: skip, skip-all, quit): skip
Skipped existing cog.yaml
✅ Created /Users/markphelps/workspace/replicate/pipelines-test/predict.py
File .dockerignore already exists. What would you like to do? (default: skip, options: skip, skip-all, quit): skip-all
Skipped existing .dockerignore (and will skip all remaining)
Skipped existing .github/workflows/push.yaml
Skipped existing requirements.txt

Done! For next steps, check out the docs at https://cog.run/getting-started

Signed-off-by: Mark Phelps <209477+markphelps@users.noreply.github.com>
@markphelps markphelps requested a review from zeke June 30, 2025 14:11
Signed-off-by: Mark Phelps <209477+markphelps@users.noreply.github.com>
@markphelps markphelps requested a review from 8W9aG June 30, 2025 14:34
Copy link
Contributor

@8W9aG 8W9aG left a comment

Choose a reason for hiding this comment

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

Nice one!

@zeke
Copy link
Member

zeke commented Jun 30, 2025

I chose to not just skip existing by default as to be more consistent with the existing behavior, but I could also see the argument that we just want to always skip all existing files..

I'd be in favor of skipping existing files by default, with a notice about it. Seems like a courteous move...

Signed-off-by: Mark Phelps <209477+markphelps@users.noreply.github.com>
@markphelps
Copy link
Contributor Author

Refactored to just skip all existing files

replicate/pipeline-test-two » /usr/local/bin/cog init

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

Skipped existing .github/workflows/push.yaml
Skipped existing requirements.txt
Skipped existing cog.yaml
Skipped existing predict.py
Skipped existing .dockerignore

Done! For next steps, check out the docs at https://cog.run/getting-started

@markphelps markphelps requested a review from 8W9aG June 30, 2025 18:01
Signed-off-by: Mark Phelps <209477+markphelps@users.noreply.github.com>
@markphelps markphelps enabled auto-merge (squash) July 1, 2025 13:43
@markphelps markphelps merged commit 3e6d5e6 into main Jul 1, 2025
26 checks passed
@markphelps markphelps deleted the mp/feat/skip-existing-cog-init branch July 1, 2025 13:57
@zeke
Copy link
Member

zeke commented Jul 2, 2025

Whoop whoop! ✨

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