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
2 changes: 1 addition & 1 deletion cli/cmd/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ var _deleteCmd = &cobra.Command{
if err != nil {
exit.Error(err)
}
fmt.Println(string(bytes))
fmt.Print(string(bytes))
return
}

Expand Down
2 changes: 1 addition & 1 deletion cli/cmd/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ var _deployCmd = &cobra.Command{
if err != nil {
exit.Error(err)
}
fmt.Println(string(bytes))
fmt.Print(string(bytes))
case flags.MixedOutputType:
err := mixedPrint(deployResults)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion cli/cmd/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ var _envListCmd = &cobra.Command{
if err != nil {
exit.Error(err)
}
fmt.Println(string(bytes))
fmt.Print(string(bytes))
return
}

Expand Down
2 changes: 0 additions & 2 deletions cli/cmd/lib_realtime_apis.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ func realtimeAPITable(realtimeAPI schema.APIResponse, env cliconfig.Environment)

out += "\n" + console.Bold("endpoint: ") + realtimeAPI.Endpoint

out += fmt.Sprintf("\n%s curl %s -X POST -H \"Content-Type: application/json\" -d @sample.json\n", console.Bold("example curl:"), realtimeAPI.Endpoint)

if !(realtimeAPI.Spec.Predictor.Type == userconfig.PythonPredictorType && realtimeAPI.Spec.Predictor.ModelPath == nil && realtimeAPI.Spec.Predictor.Models == nil) {
out += "\n" + describeModelInput(realtimeAPI.Status, realtimeAPI.Spec.Predictor, realtimeAPI.Endpoint)
}
Expand Down
2 changes: 0 additions & 2 deletions cli/cmd/lib_traffic_splitters.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
package cmd

import (
"fmt"
"strings"
"time"

Expand Down Expand Up @@ -51,7 +50,6 @@ func trafficSplitterTable(trafficSplitter schema.APIResponse, env cliconfig.Envi

out += "\n" + console.Bold("last updated: ") + libtime.SinceStr(&lastUpdated)
out += "\n" + console.Bold("endpoint: ") + trafficSplitter.Endpoint
out += fmt.Sprintf("\n%s curl %s -X POST -H \"Content-Type: application/json\" -d @sample.json\n", console.Bold("example curl:"), trafficSplitter.Endpoint)

out += "\n" + apiHistoryTable(trafficSplitter.APIVersions)

Expand Down
2 changes: 1 addition & 1 deletion cli/cmd/patch.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ var _patchCmd = &cobra.Command{
if err != nil {
exit.Error(err)
}
fmt.Println(string(bytes))
fmt.Print(string(bytes))
case flags.PrettyOutputType:
message := deployMessage(deployResults, env.Name)
if didAnyResultsError(deployResults) {
Expand Down
2 changes: 1 addition & 1 deletion cli/cmd/refresh.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ var _refreshCmd = &cobra.Command{
if err != nil {
exit.Error(err)
}
fmt.Println(string(bytes))
fmt.Print(string(bytes))
return
}

Expand Down
10 changes: 1 addition & 9 deletions cli/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ func Execute() {

updateRootUsage()

printLeadingNewLine()
_rootCmd.Execute()

exit.Ok()
Expand Down Expand Up @@ -250,18 +249,11 @@ func envStringIfNotSpecified(envName string, cmd *cobra.Command) (string, error)
return "", nil
}

func printLeadingNewLine() {
if len(os.Args) == 3 && os.Args[1] == "completion" {
return
}
fmt.Println("")
}

func mixedPrint(a interface{}) error {
jsonBytes, err := libjson.Marshal(a)
if err != nil {
return err
}
fmt.Println(fmt.Sprintf("~~cortex~~%s~~cortex~~", base64.StdEncoding.EncodeToString(jsonBytes)))
fmt.Print(fmt.Sprintf("~~cortex~~%s~~cortex~~", base64.StdEncoding.EncodeToString(jsonBytes)))
return nil
}
2 changes: 1 addition & 1 deletion dev/deploy_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def predict(self, payload):
return self.model(payload["text"])[0]


api = cx.deploy(
api = cx.create_api(
api_config,
predictor=PythonPredictor,
requirements=["torch", "transformers"],
Expand Down
2 changes: 1 addition & 1 deletion dev/generate_cli_md.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ for cmd in "${commands[@]}"; do
echo '' >> $out_file
echo "### ${cmd}" >> $out_file
echo '' >> $out_file
echo -n '```text' >> $out_file
echo '```text' >> $out_file
$ROOT/bin/cortex help ${cmd} >> $out_file
echo '```' >> $out_file
done
Expand Down
4 changes: 2 additions & 2 deletions dev/generate_python_client_md.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ sed -i "/\* \[Client](#cortex\.client\.Client)/d" $ROOT/docs/miscellaneous/pytho
sed -i "s/\* \[cortex\.client](#cortex\.client)/\* [cortex\.client\.Client](#cortex-client-client)/g" $ROOT/docs/miscellaneous/python-client.md
sed -i "s/# cortex\.client/# cortex\.client\.Client/g" $ROOT/docs/miscellaneous/python-client.md
# delete unnecessary section body
sed -i "/# cortex.client.Client/,/## deploy/{//!d}" $ROOT/docs/miscellaneous/python-client.md
sed -i "/# cortex.client.Client/,/## create\\\_api/{//!d}" $ROOT/docs/miscellaneous/python-client.md
sed -i "s/# cortex.client.Client/# cortex.client.Client\n/g" $ROOT/docs/miscellaneous/python-client.md

# fix table of contents links
Expand All @@ -61,7 +61,7 @@ sed -i 's/[[:space:]]*$//' $ROOT/docs/miscellaneous/python-client.md
truncate -s -1 $ROOT/docs/miscellaneous/python-client.md

# Cortex version comment
sed -i "s/^## deploy/## deploy\n\n<!-- CORTEX_VERSION_MINOR x5 -->/g" $ROOT/docs/miscellaneous/python-client.md
sed -i "s/^## create\\\_api/## create\\\_api\n\n<!-- CORTEX_VERSION_MINOR x5 -->/g" $ROOT/docs/miscellaneous/python-client.md

pip3 uninstall -y cortex
rm -rf $ROOT/pkg/workloads/cortex/client/cortex.egg-info
6 changes: 3 additions & 3 deletions docs/miscellaneous/python-client.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ _WARNING: you are on the master branch, please refer to the docs on the branch t
* [env\_list](#env_list)
* [env\_delete](#env_delete)
* [cortex.client.Client](#cortex-client-client)
* [deploy](#deploy)
* [create\_api](#create_api)
* [get\_api](#get_api)
* [list\_apis](#list_apis)
* [get\_job](#get_job)
Expand Down Expand Up @@ -104,12 +104,12 @@ Delete an environment configured on this machine.

# cortex.client.Client

## deploy
## create\_api

<!-- CORTEX_VERSION_MINOR x5 -->

```python
| deploy(api_spec: dict, predictor=None, requirements=[], conda_packages=[], project_dir: Optional[str] = None, force: bool = True, wait: bool = False) -> list
| create_api(api_spec: dict, predictor=None, requirements=[], conda_packages=[], project_dir: Optional[str] = None, force: bool = True, wait: bool = False) -> list
```

Deploy an API.
Expand Down
6 changes: 3 additions & 3 deletions examples/pytorch/text-generator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ api_spec = {
}
}

cx_local.deploy(api_spec, project_dir=".", wait=True)
cx_local.create_api(api_spec, project_dir=".", wait=True)
```

## Consume your API
Expand Down Expand Up @@ -126,7 +126,7 @@ api_spec = {
}
}

cx_aws.deploy(api_spec, project_dir=".")
cx_aws.create_api(api_spec, project_dir=".")
```

Monitor the status of your APIs using `cortex get` using your CLI:
Expand Down Expand Up @@ -169,7 +169,7 @@ api_spec = {
}
}

cx_aws.deploy(api_spec, project_dir=".")
cx_aws.create_api(api_spec, project_dir=".")
```

As your new API is initializing, the old API will continue to respond to prediction requests. Once the API's status becomes "live" (with one up-to-date replica), traffic will be routed to the updated version. You can track the status of your API using `cortex get`:
Expand Down
2 changes: 1 addition & 1 deletion examples/pytorch/text-generator/deploy.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
" }\n",
"}\n",
"\n",
"cx.deploy(api_spec, project_dir=\".\", wait=True)"
"cx.create_api(api_spec, project_dir=\".\", wait=True)"
]
},
{
Expand Down
29 changes: 18 additions & 11 deletions pkg/workloads/cortex/client/cortex/binary/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,29 +67,36 @@ def run_cli(

output = ""
result = ""
result_found = False
processing_result = False
processed_result = False

for c in iter(lambda: process.stdout.read(1), ""):
output += c

if mixed_output:
if output[-2:] == "\n~":
result_found = True
result = "~"
output = output[:-1]
if result_found:
if output[-2:] == "\n~" or output == "~":
processing_result = True
output = output[:-1]
if c == "\n":
result_found = False
if processing_result:
result += c
if (
result[: len(MIXED_CORTEX_MARKER)] == MIXED_CORTEX_MARKER
and result[-len(MIXED_CORTEX_MARKER) :] == MIXED_CORTEX_MARKER
and len(result) > len(MIXED_CORTEX_MARKER)
):
result = result[len(MIXED_CORTEX_MARKER) : -len(MIXED_CORTEX_MARKER)]
result = base64.b64decode(result).decode("utf8")
else:
result += c
processed_result = True

output = output[:-1]
if not hide_output:
if (not mixed_output) or (mixed_output and not result_found):
if (not mixed_output) or (mixed_output and not processing_result):
sys.stdout.write(c)
sys.stdout.flush()

if processed_result == True:
processing_result = False

process.wait()

if process.returncode == 0:
Expand Down
2 changes: 1 addition & 1 deletion pkg/workloads/cortex/client/cortex/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def __init__(self, env: dict):
self.env_name = env["name"]

# CORTEX_VERSION_MINOR x5
def deploy(
def create_api(
self,
api_spec: dict,
predictor=None,
Expand Down