-
Notifications
You must be signed in to change notification settings - Fork 618
Generate CLI docs from Go code #1696
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
Draft
zeke
wants to merge
5
commits into
main
Choose a base branch
from
generate-cli-docs-with-cobra
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
873b0f3
docs: add more long-form docs to CLI commands
zeke da494da
docs: use cobra/docs to generate CLI reference
zeke c828bb4
add script/build-cli-docs
zeke a23a446
add generated docs/cli.md
zeke 077efdf
add CLI to cog.run site nav
zeke File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,248 @@ | ||
# Cog CLI reference | ||
|
||
|
||
<!-- Do not manually edit this file! It is auto-generated from Go source code. --> | ||
|
||
|
||
This document defines the command-line interface for Cog. | ||
|
||
|
||
## `cog init` | ||
|
||
Scaffold a new Cog model | ||
|
||
### Synopsis | ||
|
||
This command sets up a new Cog project in the current directory, with files to get you started: | ||
|
||
- cog.yaml, for definining Python and system-level dependencies | ||
- predict.py, for defining the Prediction API for your model | ||
- .dockerignore, to keep large unneeded files out of your published model | ||
- .github/workflows/push.yaml, a GitHub Actions workflow to package and push your model | ||
|
||
``` | ||
cog init [flags] | ||
``` | ||
|
||
### Examples | ||
|
||
``` | ||
mkdir my-model && cd my-model && cog init | ||
``` | ||
|
||
### Options | ||
|
||
``` | ||
-h, --help help for init | ||
``` | ||
|
||
### Options inherited from parent commands | ||
|
||
``` | ||
--debug Show debugging output | ||
--version Show version of Cog | ||
``` | ||
|
||
|
||
## `cog build` | ||
|
||
Build an image from cog.yaml | ||
|
||
### Synopsis | ||
|
||
This command builds a Docker image from your project's cog.yaml. | ||
|
||
This bakes your model's code, the trained weights, and the Docker environment | ||
into a Docker image which can serve predictions with an HTTP server, and can be | ||
deployed to anywhere that Docker runs to serve real-time predictions. | ||
|
||
``` | ||
cog build [flags] | ||
``` | ||
|
||
### Options | ||
|
||
``` | ||
-h, --help help for build | ||
--no-cache Do not use cache when building the image | ||
--openapi-schema string Load OpenAPI schema from a file | ||
--progress string Set type of build progress output, 'auto' (default), 'tty' or 'plain' (default "auto") | ||
--secret stringArray Secrets to pass to the build environment in the form 'id=foo,src=/path/to/file' | ||
--separate-weights Separate model weights from code in image layers | ||
-t, --tag string A name for the built image in the form 'repository:tag' | ||
--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") | ||
``` | ||
|
||
### Options inherited from parent commands | ||
|
||
``` | ||
--debug Show debugging output | ||
--version Show version of Cog | ||
``` | ||
|
||
|
||
## `cog run` | ||
|
||
Run a command inside a Docker environment | ||
|
||
### Synopsis | ||
|
||
Run a command inside a Docker environment. | ||
|
||
The command will be run with the current directory mounted as a volume. | ||
|
||
Use commands like "cog run bash" or "cog run python" to access your | ||
model's runtime environment, so you can interact with it in a Python | ||
shell, install system dependencies, etc. | ||
|
||
``` | ||
cog run <command> [arg...] [flags] | ||
``` | ||
|
||
### Examples | ||
|
||
``` | ||
# Run Python in your container using the Python version you set in cog.yaml | ||
cog run python | ||
|
||
# Access an interactive shell inside your container | ||
cog run bash | ||
``` | ||
|
||
### Options | ||
|
||
``` | ||
-e, --env stringArray Environment variables, in the form name=value | ||
--gpus docker run --gpus GPU devices to add to the container, in the same format as docker run --gpus. | ||
-h, --help help for run | ||
--progress string Set type of build progress output, 'auto' (default), 'tty' or 'plain' (default "auto") | ||
-p, --publish stringArray Publish a container's port to the host, e.g. -p 8000 | ||
--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") | ||
``` | ||
|
||
### Options inherited from parent commands | ||
|
||
``` | ||
--debug Show debugging output | ||
--version Show version of Cog | ||
``` | ||
|
||
|
||
## `cog predict` | ||
|
||
Run a prediction | ||
|
||
### Synopsis | ||
|
||
This command runs a prediction. | ||
|
||
If 'image' is passed, it will run the prediction on that Docker image. | ||
It must be an image that has been built by Cog. | ||
|
||
Otherwise, it will build the model in the current directory and run | ||
the prediction on that. | ||
|
||
``` | ||
cog predict [image] [flags] | ||
``` | ||
|
||
### Examples | ||
|
||
``` | ||
cog predict -i mask_image=@my_mask.png -i meaning_of_life=42 | ||
``` | ||
|
||
### Options | ||
|
||
``` | ||
-e, --env stringArray Environment variables, in the form name=value | ||
--gpus docker run --gpus GPU devices to add to the container, in the same format as docker run --gpus. | ||
-h, --help help for predict | ||
-i, --input stringArray Inputs, in the form name=value. if value is prefixed with @, then it is read from a file on disk. E.g. -i path=@image.jpg | ||
-o, --output string Output path | ||
--progress string Set type of build progress output, 'auto' (default), 'tty' or 'plain' (default "auto") | ||
--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") | ||
``` | ||
|
||
### Options inherited from parent commands | ||
|
||
``` | ||
--debug Show debugging output | ||
--version Show version of Cog | ||
``` | ||
|
||
|
||
## `cog login` | ||
|
||
Log in to the Replicate Docker registry | ||
|
||
### Synopsis | ||
|
||
Log in to the Replicate Docker registry. | ||
|
||
This will allow you to push and pull Docker images from the Replicate registry. | ||
|
||
``` | ||
cog login [flags] | ||
``` | ||
|
||
### Examples | ||
|
||
``` | ||
# log in interactively via web browser | ||
cog login | ||
|
||
# pipe token from environment variable | ||
echo $REPLICATE_API_TOKEN | cog login --token-stdin | ||
|
||
# log in to a custom registry | ||
cog login --registry=my-custom-docker-registry.com | ||
``` | ||
|
||
### Options | ||
|
||
``` | ||
-h, --help help for login | ||
--token-stdin Pass login token on stdin instead of opening a browser. You can find your Replicate login token at https://replicate.com/auth/token | ||
``` | ||
|
||
### Options inherited from parent commands | ||
|
||
``` | ||
--debug Show debugging output | ||
--version Show version of Cog | ||
``` | ||
|
||
|
||
## `cog push` | ||
|
||
Build and push model in current directory to a Docker registry | ||
|
||
``` | ||
cog push [IMAGE] [flags] | ||
``` | ||
|
||
### Examples | ||
|
||
``` | ||
cog push r8.im/your-username/hotdog-detector | ||
``` | ||
|
||
### Options | ||
|
||
``` | ||
-h, --help help for push | ||
--no-cache Do not use cache when building the image | ||
--openapi-schema string Load OpenAPI schema from a file | ||
--progress string Set type of build progress output, 'auto' (default), 'tty' or 'plain' (default "auto") | ||
--secret stringArray Secrets to pass to the build environment in the form 'id=foo,src=/path/to/file' | ||
--separate-weights Separate model weights from code in image layers | ||
--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") | ||
``` | ||
|
||
### Options inherited from parent commands | ||
|
||
``` | ||
--debug Show debugging output | ||
--version Show version of Cog | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,6 +60,7 @@ require ( | |
github.com/cespare/xxhash/v2 v2.1.2 // indirect | ||
github.com/charithe/durationcheck v0.0.10 // indirect | ||
github.com/chavacava/garif v0.1.0 // indirect | ||
github.com/cpuguy83/go-md2man/v2 v2.0.3 // indirect | ||
github.com/curioswitch/go-reassign v0.2.0 // indirect | ||
github.com/daixiang0/gci v0.12.1 // indirect | ||
github.com/davecgh/go-spew v1.1.1 // indirect | ||
|
@@ -165,6 +166,7 @@ require ( | |
github.com/quasilyte/regex/syntax v0.0.0-20210819130434-b3f0c404a727 // indirect | ||
github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567 // indirect | ||
github.com/rivo/uniseg v0.2.0 // indirect | ||
github.com/russross/blackfriday/v2 v2.1.0 // indirect | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are you still using the new dependencies here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm actually not sure.. I didn't add them manually. Maybe they got added by cobra/doc? |
||
github.com/ryancurrah/gomodguard v1.3.0 // indirect | ||
github.com/ryanrolds/sqlclosecheck v0.5.1 // indirect | ||
github.com/sanposhiho/wastedassign/v2 v2.0.7 // indirect | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be moved to a separate command. Otherwise, it creates the docs everytime the main get invoked