Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ The CLI sends configuration and code to the cluster every time you run `cortex d

## Examples

<!-- CORTEX_VERSION_README_MINOR x4 -->
- [Sentiment analysis](https://github.com/cortexlabs/cortex/tree/0.10/examples/tensorflow/sentiment-analysis) in TensorFlow with BERT
<!-- CORTEX_VERSION_README_MINOR x5 -->
- [Sentiment analysis](https://github.com/cortexlabs/cortex/tree/0.10/examples/tensorflow/sentiment-analyzer) in TensorFlow with BERT
- [Image classification](https://github.com/cortexlabs/cortex/tree/0.10/examples/tensorflow/image-classifier) in TensorFlow with Inception
- [Text generation](https://github.com/cortexlabs/cortex/tree/0.10/examples/pytorch/text-generator) in PyTorch with DistilGPT2
- [Reading comprehension](https://github.com/cortexlabs/cortex/tree/0.10/examples/pytorch/text-generator) in PyTorch with ELMo-BiDAF
Expand Down
27 changes: 13 additions & 14 deletions cli/cmd/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,18 @@ func init() {
}

func addClusterConfigFlag(cmd *cobra.Command) {
cmd.PersistentFlags().StringVarP(&flagClusterConfig, "config", "c", "", "path to a Cortex cluster configuration file")
cmd.PersistentFlags().StringVarP(&flagClusterConfig, "config", "c", "", "path to a cluster configuration file")
cmd.PersistentFlags().SetAnnotation("config", cobra.BashCompFilenameExt, configFileExts)
}

var clusterCmd = &cobra.Command{
Use: "cluster",
Short: "manage a Cortex cluster",
Long: "Manage a Cortex cluster",
Short: "manage a cluster",
}

var upCmd = &cobra.Command{
Use: "up",
Short: "spin up a Cortex cluster",
Long: `This command spins up a Cortex cluster on your AWS account.`,
Short: "spin up a cluster",
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, args []string) {
if err := checkDockerRunning(); err != nil {
Expand All @@ -97,8 +95,7 @@ var upCmd = &cobra.Command{

var updateCmd = &cobra.Command{
Use: "update",
Short: "update a Cortex cluster",
Long: `This command updates a Cortex cluster.`,
Short: "update a cluster",
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, args []string) {
if err := checkDockerRunning(); err != nil {
Expand Down Expand Up @@ -126,8 +123,7 @@ var updateCmd = &cobra.Command{

var infoCmd = &cobra.Command{
Use: "info",
Short: "get information about a Cortex cluster",
Long: `This command gets information about a Cortex cluster.`,
Short: "get information about a cluster",
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, args []string) {
if err := checkDockerRunning(); err != nil {
Expand All @@ -145,7 +141,9 @@ var infoCmd = &cobra.Command{
if err != nil {
errors.Exit(err)
}
if strings.Contains(out, "there isn't a cortex cluster") {

// note: if modifying this string, search the codebase for it and change all occurrences
if strings.Contains(out, "there is no cluster") {
errors.Exit()
}

Expand Down Expand Up @@ -176,8 +174,7 @@ var infoCmd = &cobra.Command{

var downCmd = &cobra.Command{
Use: "down",
Short: "spin down a Cortex cluster",
Long: `This command spins down a Cortex cluster.`,
Short: "spin down a cluster",
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, args []string) {
if err := checkDockerRunning(); err != nil {
Expand Down Expand Up @@ -267,14 +264,16 @@ func refreshCachedClusterConfig(awsCreds *AWSCredentials) *clusterconfig.Cluster
}

if userClusterConfig.Region == nil {
errors.Exit(fmt.Sprintf("unable to find an existing cortex cluster; please configure \"%s\" to the s3 region of an existing cortex cluster or create a cortex cluster with `cortex cluster up`", clusterconfig.RegionKey))
errors.Exit(fmt.Sprintf("unable to find an existing cluster; please configure \"%s\" to the s3 region of an existing cluster or create a cluster with `cortex cluster up`", clusterconfig.RegionKey))
}

out, err := runRefreshClusterConfig(userClusterConfig, awsCreds)
if err != nil {
errors.Exit(err)
}
if strings.Contains(out, "there isn't a cortex cluster") {

// note: if modifying this string, search the codebase for it and change all occurrences
if strings.Contains(out, "there is no cluster") {
errors.Exit()
}

Expand Down
13 changes: 6 additions & 7 deletions cli/cmd/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,15 @@ import (
var completionCmd = &cobra.Command{
Use: "completion",
Short: "generate bash completion scripts",
Long: `Generate bash completion scripts.
Long: `generate bash completion scripts

Add this to your bashrc or bash profile:
add this to your bashrc or bash profile:
source <(cortex completion)
Or run:
echo 'source <(cortex completion)' >> ~/.bash_profile # Mac
echo 'source <(cortex completion)' >> ~/.bashrc # Linux
or run:
echo 'source <(cortex completion)' >> ~/.bash_profile # mac
echo 'source <(cortex completion)' >> ~/.bashrc # linux

This will also add the "cx" alias.
Note: Cortex CLI completion requires the bash_completion package to be installed on your system.
this will also add the "cx" alias (note: cli completion requires the bash_completion package to be installed on your system)
`,
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, args []string) {
Expand Down
7 changes: 2 additions & 5 deletions cli/cmd/configure.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,8 @@ func init() {

var configureCmd = &cobra.Command{
Use: "configure",
Short: "configure the CLI",
Long: `This command configures the Cortex URL and AWS credentials
in order to authenticate and send requests to Cortex.
The configuration is stored in ~/.cortex.`,
Args: cobra.NoArgs,
Short: "configure the cli",
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, args []string) {
if flagPrint {
cliConfig := getDefaults()
Expand Down
1 change: 0 additions & 1 deletion cli/cmd/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ func init() {
var deleteCmd = &cobra.Command{
Use: "delete [DEPLOYMENT_NAME]",
Short: "delete a deployment",
Long: `This command deletes a deployment from the cluster.`,
Args: cobra.MaximumNArgs(1),
Run: func(cmd *cobra.Command, args []string) {
var appName string
Expand Down
6 changes: 2 additions & 4 deletions cli/cmd/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,14 @@ var flagDeployRefresh bool

func init() {
deployCmd.PersistentFlags().BoolVarP(&flagDeployForce, "force", "f", false, "override the in-progress deployment update")
deployCmd.PersistentFlags().BoolVarP(&flagDeployRefresh, "refresh", "r", false, "re-deploy all APIs with cleared cache and rolling updates")
deployCmd.PersistentFlags().BoolVarP(&flagDeployRefresh, "refresh", "r", false, "re-deploy all apis with cleared cache and rolling updates")
addEnvFlag(deployCmd)
}

var deployCmd = &cobra.Command{
Use: "deploy",
Short: "create or update a deployment",
Long: `This command sends all project configuration and code to Cortex.
If validations pass, Cortex will attempt to create the desired state.`,
Args: cobra.NoArgs,
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, args []string) {
deploy(flagDeployForce, flagDeployRefresh)
},
Expand Down
2 changes: 1 addition & 1 deletion cli/cmd/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func ErrorFailedConnectURL(url url.URL) error {
func ErrorFailedToConnectOperator(urlStr string) error {
return Error{
Kind: ErrFailedToConnectOperator,
message: fmt.Sprintf("failed to connect to the operator (%s), run `cortex configure` if you need to update the operator URL", urlStr),
message: fmt.Sprintf("failed to connect to the operator (%s), run `cortex configure` if you need to update the operator endpoint", urlStr),
}
}

Expand Down
12 changes: 5 additions & 7 deletions cli/cmd/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,8 @@ func init() {

var getCmd = &cobra.Command{
Use: "get [API_NAME]",
Short: "get information about APIs",
Long: `This command displays information about APIs.
Adding the -v or --verbose flag displays additional information.`,
Args: cobra.RangeArgs(0, 1),
Short: "get information about deployments",
Args: cobra.RangeArgs(0, 1),
Run: func(cmd *cobra.Command, args []string) {
rerun(func() (string, error) {
return runGet(cmd, args)
Expand Down Expand Up @@ -424,7 +422,7 @@ func classificationMetricsTable(apiMetrics schema.APIMetrics) string {

func describeModelInput(groupStatus *resource.APIGroupStatus, apiEndpoint string) string {
if groupStatus.ReadyUpdated+groupStatus.ReadyStaleCompute == 0 {
return "the model's input schema will be available when the API is live"
return "the model's input schema will be available when the api is live"
}

apiSummary, err := getAPISummary(apiEndpoint)
Expand Down Expand Up @@ -462,7 +460,7 @@ func describeModelInput(groupStatus *resource.APIGroupStatus, apiEndpoint string
func getAPISummary(apiEndpoint string) (*schema.APISummary, error) {
req, err := http.NewRequest("GET", apiEndpoint, nil)
if err != nil {
return nil, errors.Wrap(err, "unable to request API summary")
return nil, errors.Wrap(err, "unable to request api summary")
}
req.Header.Set("Content-Type", "application/json")
response, err := httpsNoVerifyClient.makeRequest(req)
Expand All @@ -473,7 +471,7 @@ func getAPISummary(apiEndpoint string) (*schema.APISummary, error) {
var apiSummary schema.APISummary
err = json.DecodeWithNumber(response, &apiSummary)
if err != nil {
return nil, errors.Wrap(err, "unable to parse API summary response")
return nil, errors.Wrap(err, "unable to parse api summary response")
}

for _, featureSignature := range apiSummary.ModelSignature {
Expand Down
3 changes: 1 addition & 2 deletions cli/cmd/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ func init() {

var logsCmd = &cobra.Command{
Use: "logs API_NAME",
Short: "get logs for an API",
Long: `This command streams logs from a deployed API.`,
Short: "stream logs from an api",
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
resourceName := args[0]
Expand Down
8 changes: 3 additions & 5 deletions cli/cmd/predict.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,13 @@ var predictDebug bool
func init() {
addAppNameFlag(predictCmd)
addEnvFlag(predictCmd)
predictCmd.Flags().BoolVar(&predictDebug, "debug", false, "Predict with debug mode")
predictCmd.Flags().BoolVar(&predictDebug, "debug", false, "predict with debug mode")
}

var predictCmd = &cobra.Command{
Use: "predict API_NAME SAMPLE_FILE",
Short: "make a prediction request",
Long: `This command makes a prediction request using
a JSON file and displays the response.`,
Args: cobra.ExactArgs(2),
Short: "make a prediction request using a json file",
Args: cobra.ExactArgs(2),
Run: func(cmd *cobra.Command, args []string) {
apiName := args[0]
sampleJSONPath := args[1]
Expand Down
18 changes: 4 additions & 14 deletions cli/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import (
"github.com/cortexlabs/cortex/pkg/lib/slices"
s "github.com/cortexlabs/cortex/pkg/lib/strings"
libtime "github.com/cortexlabs/cortex/pkg/lib/time"
"github.com/cortexlabs/cortex/pkg/operator/api/resource"
)

var cmdStr string
Expand Down Expand Up @@ -70,7 +69,6 @@ var rootCmd = &cobra.Command{
Use: "cortex",
Aliases: []string{"cx"},
Short: "deploy machine learning models in production",
Long: `Deploy machine learning models in production`,
}

func Execute() {
Expand Down Expand Up @@ -107,10 +105,10 @@ func updateRootUsage() {
}

usage = strings.Replace(usage, "Usage:\n cortex [command]\n\nAliases:\n cortex, cx\n\n", "", 1)
usage = strings.Replace(usage, "Available Commands:", "Deployment commands:", 1)
usage = strings.Replace(usage, "\n cluster", "\n\nCluster commands:\n cluster", 1)
usage = strings.Replace(usage, "\n configure", "\n\nOther commands:\n configure", 1)
usage = strings.Replace(usage, "\nUse \"cortex", " help help about any command\n\nFlags:\n -h, --help help for cortex\n\nUse \"cortex", 1)
usage = strings.Replace(usage, "Available Commands:", "deployment commands:", 1)
usage = strings.Replace(usage, "\n cluster", "\n\ncluster commands:\n cluster", 1)
usage = strings.Replace(usage, "\n configure", "\n\nother commands:\n configure", 1)
usage = strings.Replace(usage, "\n\nUse \"cortex [command] --help\" for more information about a command.", "", 1)

cmd.Print(usage)

Expand All @@ -136,14 +134,6 @@ func addAppNameFlag(cmd *cobra.Command) {
cmd.PersistentFlags().StringVarP(&flagAppName, "deployment", "d", "", "deployment name")
}

var resourceTypesHelp = fmt.Sprintf("\nResource Types:\n %s\n", strings.Join(resource.VisibleTypes.StringList(), "\n "))

func addResourceTypesToHelp(cmd *cobra.Command) {
usage := cmd.UsageTemplate()
usage = strings.Replace(usage, "\nFlags:\n", resourceTypesHelp+"\nFlags:\n", 1)
cmd.SetUsageTemplate(usage)
}

func getTerminalWidth() int {
cmd := exec.Command("stty", "size")
cmd.Stdin = os.Stdin
Expand Down
3 changes: 1 addition & 2 deletions cli/cmd/support.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ var supportPrompValidation = &cr.PromptValidation{

var supportCmd = &cobra.Command{
Use: "support",
Short: "send a support request to Cortex maintainers",
Long: `This command sends a support request to the Cortex maintainers`,
Short: "send a support request to the maintainers",
Run: func(cmd *cobra.Command, args []string) {
supportRequest := &SupportRequest{}
err := cr.ReadPrompt(supportRequest, supportPrompValidation)
Expand Down
15 changes: 7 additions & 8 deletions cli/cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,29 +33,28 @@ func init() {

var versionCmd = &cobra.Command{
Use: "version",
Short: "print the version of the CLI and cluster",
Long: `This command prints the version of the CLI and cluster`,
Short: "print the cli and cluster versions",
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, args []string) {
if !isCLIConfigured() {
fmt.Println("CLI version: " + consts.CortexVersion + "\n")
fmt.Println("Run `cortex configure` to connect the CLI to a Cortex cluster")
fmt.Println("cli version: " + consts.CortexVersion + "\n")
fmt.Println("run `cortex configure` to connect the cli to a cluster")
return
}

httpResponse, err := HTTPGet("/info")
if err != nil {
fmt.Println("CLI version: " + consts.CortexVersion + "\n")
fmt.Println("cli version: " + consts.CortexVersion + "\n")
errors.Exit(err)
}
var infoResponse schema.InfoResponse
err = json.Unmarshal(httpResponse, &infoResponse)
if err != nil {
fmt.Println("CLI version: " + consts.CortexVersion + "\n")
fmt.Println("cli version: " + consts.CortexVersion + "\n")
errors.Exit(err, "/info", string(httpResponse))
}

fmt.Println("CLI version: " + consts.CortexVersion)
fmt.Println("Cluster version: " + infoResponse.ClusterConfig.APIVersion)
fmt.Println("cli version: " + consts.CortexVersion)
fmt.Println("cluster version: " + infoResponse.ClusterConfig.APIVersion)
},
}
Loading