Skip to content

Commit b3e2fc8

Browse files
authored
Remove cli mixed output (#1950)
1 parent 6883d8a commit b3e2fc8

File tree

5 files changed

+5
-47
lines changed

5 files changed

+5
-47
lines changed

cli/cmd/deploy.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,6 @@ var _deployCmd = &cobra.Command{
110110
exit.Error(err)
111111
}
112112
fmt.Print(string(bytes))
113-
case flags.MixedOutputType:
114-
err := mixedPrint(deployResults)
115-
if err != nil {
116-
exit.Error(err)
117-
}
118113
case flags.PrettyOutputType:
119114
message, err := deployMessage(deployResults, env.Name)
120115
if err != nil {

cli/cmd/root.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ limitations under the License.
1717
package cmd
1818

1919
import (
20-
"encoding/base64"
2120
"fmt"
2221
"os"
2322
"path/filepath"
@@ -27,7 +26,6 @@ import (
2726
"github.com/cortexlabs/cortex/pkg/lib/errors"
2827
"github.com/cortexlabs/cortex/pkg/lib/exit"
2928
"github.com/cortexlabs/cortex/pkg/lib/files"
30-
libjson "github.com/cortexlabs/cortex/pkg/lib/json"
3129
s "github.com/cortexlabs/cortex/pkg/lib/strings"
3230
"github.com/cortexlabs/cortex/pkg/lib/telemetry"
3331
homedir "github.com/mitchellh/go-homedir"
@@ -238,12 +236,3 @@ func envStringIfNotSpecified(envName string, cmd *cobra.Command) (string, error)
238236

239237
return "", nil
240238
}
241-
242-
func mixedPrint(a interface{}) error {
243-
jsonBytes, err := libjson.Marshal(a)
244-
if err != nil {
245-
return err
246-
}
247-
fmt.Print(fmt.Sprintf("~~cortex~~%s~~cortex~~", base64.StdEncoding.EncodeToString(jsonBytes)))
248-
return nil
249-
}

cli/types/flags/output_type.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,12 @@ type OutputType int
2020

2121
const (
2222
UnknownOutputType OutputType = iota
23-
MixedOutputType // Internal only
2423
PrettyOutputType
2524
JSONOutputType
2625
)
2726

2827
var _outputTypes = []string{
2928
"unknown",
30-
"mixed",
3129
"pretty",
3230
"json",
3331
}

pkg/cortex/client/cortex/binary/__init__.py

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,11 @@
1313
# limitations under the License.
1414

1515
import os
16-
import base64
1716
import sys
1817
import subprocess
1918
from typing import List
2019
from cortex.exceptions import CortexBinaryException
2120

22-
MIXED_CORTEX_MARKER = "~~cortex~~"
23-
2421

2522
def run():
2623
"""
@@ -36,21 +33,19 @@ def run():
3633
def run_cli(
3734
args: List[str],
3835
hide_output: bool = False,
39-
mixed_output: bool = False,
4036
) -> str:
4137
"""
4238
Runs the Cortex binary with the specified arguments.
4339
4440
Args:
4541
args: Arguments to use when invoking the Cortex CLI.
4642
hide_output: Flag to prevent streaming CLI output to stdout.
47-
mixed_output: Used to handle CLI output that both prints to stdout and should be returned.
4843
4944
Raises:
5045
CortexBinaryException: Cortex CLI command returned an error.
5146
5247
Returns:
53-
The stdout from the Cortex CLI command, or the result if mixed_output output.
48+
The stdout from the Cortex CLI command.
5449
"""
5550

5651
env = os.environ.copy()
@@ -71,35 +66,16 @@ def run_cli(
7166
for c in iter(lambda: process.stdout.read(1), ""):
7267
output += c
7368

74-
if mixed_output:
75-
if output[-2:] == "\n~" or output == "~":
76-
processing_result = True
77-
output = output[:-1]
78-
if processing_result:
79-
result += c
80-
if (
81-
result[: len(MIXED_CORTEX_MARKER)] == MIXED_CORTEX_MARKER
82-
and result[-len(MIXED_CORTEX_MARKER) :] == MIXED_CORTEX_MARKER
83-
and len(result) > len(MIXED_CORTEX_MARKER)
84-
):
85-
result = result[len(MIXED_CORTEX_MARKER) : -len(MIXED_CORTEX_MARKER)]
86-
result = base64.b64decode(result).decode("utf8")
87-
processed_result = True
88-
89-
output = output[:-1]
9069
if not hide_output:
91-
if (not mixed_output) or (mixed_output and not processing_result):
92-
sys.stdout.write(c)
93-
sys.stdout.flush()
70+
sys.stdout.write(c)
71+
sys.stdout.flush()
9472

9573
if processed_result == True:
9674
processing_result = False
9775

9876
process.wait()
9977

10078
if process.returncode == 0:
101-
if mixed_output:
102-
return result
10379
return output
10480

10581
if result != "":

pkg/cortex/client/cortex/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,14 +239,14 @@ def _deploy(
239239
"--env",
240240
self.env_name,
241241
"-o",
242-
"mixed",
242+
"json",
243243
"-y",
244244
]
245245

246246
if force:
247247
args.append("--force")
248248

249-
output = run_cli(args, mixed_output=True)
249+
output = run_cli(args, hide_output=True)
250250

251251
deploy_results = json.loads(output.strip())
252252

0 commit comments

Comments
 (0)