Add a new scaffold command to the CLI#34
Conversation
`replicate clone --template node [prediction] [output path]` `replicate clone --template python [prediction] [output path]`
|
Should we also support this other format of prediction URL? |
mattt
left a comment
There was a problem hiding this comment.
This is great, @jakedahn. Thank you so much for working on this. I left some specific code review suggestions for your consideration.
Some more high-level feedback:
-
I'm not sure
cloneis the right spelling for this command. I slightly preferscaffold, but maybe there's another optionbootstrap?project init?- If
project init, then maybe the prediction is optional, and you just use a default example, like SDXL.
- If
-
Looking what's in the starter repos, I think it might make sense to embed them in the CLI itself. Go has a nice affordance for embedding source files as string constants to make that convenient.
- If the concern is future-proofing, then we could put the template files in the CLI repo and fetch the latest versions.
| // Run the example prediction | ||
| fmt.Println("Running example prediction...") | ||
| commands = []string{ | ||
| fmt.Sprintf("cd %s && node prediction.py", outputClonePath), | ||
| } | ||
| for _, command := range commands { | ||
| cmd := exec.Command("bash", "-c", command) | ||
| cmd.Stdout = os.Stdout | ||
| cmd.Stderr = os.Stderr | ||
| err := cmd.Run() | ||
| if err != nil { | ||
| return err | ||
| } | ||
| } |
There was a problem hiding this comment.
I find this last step of running the prediction to be unexpected. Instead, I think we should print the output path and provide instructions for what to do next.
There was a problem hiding this comment.
@jakedahn Any objections to skipping this last step?
|
Agreed clone feels a bit funny. Not sure why. Perhaps because it's a bit of a different intent from Git? Perhaps because having it as a top-level command implies it's a primary action of Replicate the product? Run, models, deployments... clone?
|
…e optional argument, and change to kebab case. Co-authored-by: Mattt <mattt@replicate.com>
Co-authored-by: Mattt <mattt@replicate.com>
…default name should be generated based on the prediction ID Co-authored-by: Mattt <mattt@replicate.com>
Co-authored-by: Mattt <mattt@replicate.com>
Co-authored-by: Mattt <mattt@replicate.com>
Co-authored-by: Mattt <mattt@replicate.com>
Co-authored-by: Mattt <mattt@replicate.com>
Co-authored-by: Mattt <mattt@replicate.com>
I tend to agree. |
I disagree here. The hope behind using actual git repos here is that in a future iteration, someone could say I think it's a strange experience to be like "oh I would really love to add a starter template for elixir", and then be forced to vendor everything inside of a golang codebase where it never gets updated because doing so inside of a golang codebase feels foreign. This pattern is not implemented in this PR as-is, but this is a future I think is worth heading towards. |
|
I've renamed everything to |
@jakedahn 100% with you. We can get the best of both worlds by locating built-in templates ( You could even implement this internally by routing aliases like |
|
@jakedahn Thanks again for your great work on this. I'm excited to have this in the CLI. I was thinking about this some more the other day, and came up with a slightly different interface: # Generate from a prediction
replicate prediction scaffold z5kvo4tb6mhb7xnpxpjpfxlzxe # also supports URLs
# Generate from a model's default example
replicate model scaffold stability-ai/sdxl # also supports URLs, optional version
# Top-level alias that automatically does the right thing
replicate scaffold z5kvo4tb6mhb7xnpxpjpfxlzxe # prediction ID
replicate scaffold stability-ai/sdxl # model name
replicate scaffold # default project template In the interest of shipping fast and iterating, the minimal change would be to rename How does that sound? |
scaffold command to the CLI
This PR introduces a new
scaffoldcommand to the Replicate CLI.You can use this command to bootstrap a completely functional development environment from a given prediction ID or URL.
To start, support is limited to javascript via the https://github.com/replicate/node-starter repo and python via the https://github.com/replicate/python-starter repo.
Usage
Scaffold via prediction URL
replicate scaffold https://replicate.com/p/z5kvo4tb6mhb7xnpxpjpfxlzxe /path/to/repo(default uses node)replicate scaffold --template node https://replicate.com/p/z5kvo4tb6mhb7xnpxpjpfxlzxe /path/to/repo(node)replicate scaffold --template python https://replicate.com/p/z5kvo4tb6mhb7xnpxpjpfxlzxe /path/to/repo(python)Scaffold via prediction ID
replicate scaffold z5kvo4tb6mhb7xnpxpjpfxlzxe /path/to/repo(default uses node)replicate scaffold --template node z5kvo4tb6mhb7xnpxpjpfxlzxe /path/to/repo(node)replicate scaffold --template python z5kvo4tb6mhb7xnpxpjpfxlzxe /path/to/repo(python)