Skip to content

Commit 213fc3c

Browse files
authored
Rename SyncAPI to RealtimeAPI and APISplitter to TrafficSplitter (#1277)
1 parent 66d542b commit 213fc3c

File tree

104 files changed

+494
-490
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+494
-490
lines changed

cli/cluster/delete.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import (
2929

3030
func Delete(operatorConfig OperatorConfig, apiName string, keepCache bool, force bool) (schema.DeleteResponse, error) {
3131
if !force {
32-
readyReplicas := getReadySyncAPIReplicasOrNil(operatorConfig, apiName)
32+
readyReplicas := getReadyRealtimeAPIReplicasOrNil(operatorConfig, apiName)
3333
if readyReplicas != nil && *readyReplicas > 2 {
3434
prompt.YesOrExit(fmt.Sprintf("are you sure you want to delete %s (which has %d live replicas)?", apiName, *readyReplicas), "", "")
3535
}
@@ -54,7 +54,7 @@ func Delete(operatorConfig OperatorConfig, apiName string, keepCache bool, force
5454
return deleteRes, nil
5555
}
5656

57-
func getReadySyncAPIReplicasOrNil(operatorConfig OperatorConfig, apiName string) *int32 {
57+
func getReadyRealtimeAPIReplicasOrNil(operatorConfig OperatorConfig, apiName string) *int32 {
5858
httpRes, err := HTTPGet(operatorConfig, "/get/"+apiName)
5959
if err != nil {
6060
return nil
@@ -65,11 +65,11 @@ func getReadySyncAPIReplicasOrNil(operatorConfig OperatorConfig, apiName string)
6565
return nil
6666
}
6767

68-
if apiRes.SyncAPI == nil {
68+
if apiRes.RealtimeAPI == nil {
6969
return nil
7070
}
7171

72-
totalReady := apiRes.SyncAPI.Status.Updated.Ready + apiRes.SyncAPI.Status.Stale.Ready
72+
totalReady := apiRes.RealtimeAPI.Status.Updated.Ready + apiRes.RealtimeAPI.Status.Stale.Ready
7373
return &totalReady
7474
}
7575

cli/cmd/deploy.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ func getAPICommandsMessage(results []schema.DeployResult, envName string) string
283283
items.Add(fmt.Sprintf("cortex get %s%s", apiName, envArg), "(show api info)")
284284

285285
for _, result := range results {
286-
if result.API.Kind == userconfig.SyncAPIKind {
286+
if result.API.Kind == userconfig.RealtimeAPIKind {
287287
items.Add(fmt.Sprintf("cortex logs %s%s", apiName, envArg), "(stream api logs)")
288288
break
289289
}

cli/cmd/errors.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,6 @@ func ErrorDeployFromTopLevelDir(genericDirName string, providerType types.Provid
347347
}
348348
return errors.WithStack(&errors.Error{
349349
Kind: ErrDeployFromTopLevelDir,
350-
Message: fmt.Sprintf("cannot deploy from your %s directory - when deploying your API, cortex sends all files in your project directory (i.e. the directory which contains cortex.yaml) to your %s (see https://docs.cortex.dev/v/%s/deployments/syncapi/predictors#project-files for Sync API and https://docs.cortex.dev/v/%s/deployments/batchapi/predictors#project-files for Batch API); therefore it is recommended to create a subdirectory for your project files", genericDirName, targetStr, consts.CortexVersionMinor, consts.CortexVersionMinor),
350+
Message: fmt.Sprintf("cannot deploy from your %s directory - when deploying your API, cortex sends all files in your project directory (i.e. the directory which contains cortex.yaml) to your %s (see https://docs.cortex.dev/v/%s/deployments/realtime-api/predictors#project-files for Realtime API and https://docs.cortex.dev/v/%s/deployments/batch-api/predictors#project-files for Batch API); therefore it is recommended to create a subdirectory for your project files", genericDirName, targetStr, consts.CortexVersionMinor, consts.CortexVersionMinor),
351351
})
352352
}

cli/cmd/get.go

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import (
3737

3838
const (
3939
_titleEnvironment = "env"
40-
_titleSyncAPI = "sync api"
40+
_titleRealtimeAPI = "realtime api"
4141
_titleStatus = "status"
4242
_titleUpToDate = "up-to-date"
4343
_titleStale = "stale"
@@ -150,12 +150,12 @@ func getAPIsInAllEnvironments() (string, error) {
150150
return "", err
151151
}
152152

153-
var allSyncAPIs []schema.SyncAPI
154-
var allSyncAPIEnvs []string
153+
var allRealtimeAPIs []schema.RealtimeAPI
154+
var allRealtimeAPIEnvs []string
155155
var allBatchAPIs []schema.BatchAPI
156156
var allBatchAPIEnvs []string
157-
var allAPISplitters []schema.APISplitter
158-
var allAPISplitterEnvs []string
157+
var allTrafficSplitters []schema.TrafficSplitter
158+
var allTrafficSplitterEnvs []string
159159

160160
errorsMap := map[string]error{}
161161
// get apis from both environments
@@ -172,23 +172,23 @@ func getAPIsInAllEnvironments() (string, error) {
172172
for range apisRes.BatchAPIs {
173173
allBatchAPIEnvs = append(allBatchAPIEnvs, env.Name)
174174
}
175-
for range apisRes.SyncAPIs {
176-
allSyncAPIEnvs = append(allSyncAPIEnvs, env.Name)
175+
for range apisRes.RealtimeAPIs {
176+
allRealtimeAPIEnvs = append(allRealtimeAPIEnvs, env.Name)
177177
}
178-
for range apisRes.APISplitters {
179-
allAPISplitterEnvs = append(allAPISplitterEnvs, env.Name)
178+
for range apisRes.TrafficSplitters {
179+
allTrafficSplitterEnvs = append(allTrafficSplitterEnvs, env.Name)
180180
}
181-
allSyncAPIs = append(allSyncAPIs, apisRes.SyncAPIs...)
181+
allRealtimeAPIs = append(allRealtimeAPIs, apisRes.RealtimeAPIs...)
182182
allBatchAPIs = append(allBatchAPIs, apisRes.BatchAPIs...)
183-
allAPISplitters = append(allAPISplitters, apisRes.APISplitters...)
183+
allTrafficSplitters = append(allTrafficSplitters, apisRes.TrafficSplitters...)
184184
} else {
185185
errorsMap[env.Name] = err
186186
}
187187
}
188188

189189
out := ""
190190

191-
if len(allSyncAPIs) == 0 && len(allBatchAPIs) == 0 && len(allAPISplitters) == 0 {
191+
if len(allRealtimeAPIs) == 0 && len(allBatchAPIs) == 0 && len(allTrafficSplitters) == 0 {
192192
if len(errorsMap) == 1 {
193193
// Print the error if there is just one
194194
exit.Error(errors.FirstErrorInMap(errorsMap))
@@ -203,9 +203,9 @@ func getAPIsInAllEnvironments() (string, error) {
203203
out += t.MustFormat()
204204
}
205205

206-
if len(allSyncAPIs) > 0 {
207-
t := syncAPIsTable(allSyncAPIs, allSyncAPIEnvs)
208-
if strset.New(allSyncAPIEnvs...).IsEqual(strset.New(types.LocalProviderType.String())) {
206+
if len(allRealtimeAPIs) > 0 {
207+
t := realtimeAPIsTable(allRealtimeAPIs, allRealtimeAPIEnvs)
208+
if strset.New(allRealtimeAPIEnvs...).IsEqual(strset.New(types.LocalProviderType.String())) {
209209
hideReplicaCountColumns(&t)
210210
}
211211

@@ -216,10 +216,10 @@ func getAPIsInAllEnvironments() (string, error) {
216216
out += t.MustFormat()
217217
}
218218

219-
if len(allAPISplitters) > 0 {
220-
t := apiSplitterListTable(allAPISplitters, allAPISplitterEnvs)
219+
if len(allTrafficSplitters) > 0 {
220+
t := trafficSplitterListTable(allTrafficSplitters, allTrafficSplitterEnvs)
221221

222-
if len(allSyncAPIs) > 0 || len(allBatchAPIs) > 0 {
222+
if len(allRealtimeAPIs) > 0 || len(allBatchAPIs) > 0 {
223223
out += "\n"
224224
}
225225

@@ -267,7 +267,7 @@ func getAPIsByEnv(env cliconfig.Environment, printEnv bool) (string, error) {
267267
}
268268
}
269269

270-
if len(apisRes.SyncAPIs) == 0 && len(apisRes.BatchAPIs) == 0 && len(apisRes.APISplitters) == 0 {
270+
if len(apisRes.RealtimeAPIs) == 0 && len(apisRes.BatchAPIs) == 0 && len(apisRes.TrafficSplitters) == 0 {
271271
return console.Bold("no apis are deployed"), nil
272272
}
273273

@@ -285,13 +285,13 @@ func getAPIsByEnv(env cliconfig.Environment, printEnv bool) (string, error) {
285285
out += t.MustFormat()
286286
}
287287

288-
if len(apisRes.SyncAPIs) > 0 {
288+
if len(apisRes.RealtimeAPIs) > 0 {
289289
envNames := []string{}
290-
for range apisRes.SyncAPIs {
290+
for range apisRes.RealtimeAPIs {
291291
envNames = append(envNames, env.Name)
292292
}
293293

294-
t := syncAPIsTable(apisRes.SyncAPIs, envNames)
294+
t := realtimeAPIsTable(apisRes.RealtimeAPIs, envNames)
295295
t.FindHeaderByTitle(_titleEnvironment).Hidden = true
296296

297297
if len(apisRes.BatchAPIs) > 0 {
@@ -305,16 +305,16 @@ func getAPIsByEnv(env cliconfig.Environment, printEnv bool) (string, error) {
305305
out += t.MustFormat()
306306
}
307307

308-
if len(apisRes.APISplitters) > 0 {
308+
if len(apisRes.TrafficSplitters) > 0 {
309309
envNames := []string{}
310-
for range apisRes.APISplitters {
310+
for range apisRes.TrafficSplitters {
311311
envNames = append(envNames, env.Name)
312312
}
313313

314-
t := apiSplitterListTable(apisRes.APISplitters, envNames)
314+
t := trafficSplitterListTable(apisRes.TrafficSplitters, envNames)
315315
t.FindHeaderByTitle(_titleEnvironment).Hidden = true
316316

317-
if len(apisRes.BatchAPIs) > 0 || len(apisRes.SyncAPIs) > 0 {
317+
if len(apisRes.BatchAPIs) > 0 || len(apisRes.RealtimeAPIs) > 0 {
318318
out += "\n"
319319
}
320320

@@ -357,11 +357,11 @@ func getAPI(env cliconfig.Environment, apiName string) (string, error) {
357357
return "", err
358358
}
359359

360-
if apiRes.SyncAPI != nil {
361-
return syncAPITable(apiRes.SyncAPI, env)
360+
if apiRes.RealtimeAPI != nil {
361+
return realtimeAPITable(apiRes.RealtimeAPI, env)
362362
}
363-
if apiRes.APISplitter != nil {
364-
return apiSplitterTable(apiRes.APISplitter, env)
363+
if apiRes.TrafficSplitter != nil {
364+
return trafficSplitterTable(apiRes.TrafficSplitter, env)
365365
}
366366
return batchAPITable(*apiRes.BatchAPI), nil
367367
}
@@ -375,7 +375,7 @@ func getAPI(env cliconfig.Environment, apiName string) (string, error) {
375375
return "", err
376376
}
377377

378-
return syncAPITable(apiRes.SyncAPI, env)
378+
return realtimeAPITable(apiRes.RealtimeAPI, env)
379379
}
380380

381381
func titleStr(title string) string {

cli/cmd/lib_sync_apis.go renamed to cli/cmd/lib_realtime_apis.go

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -41,82 +41,82 @@ import (
4141
"github.com/cortexlabs/cortex/pkg/types/userconfig"
4242
)
4343

44-
func syncAPITable(syncAPI *schema.SyncAPI, env cliconfig.Environment) (string, error) {
44+
func realtimeAPITable(realtimeAPI *schema.RealtimeAPI, env cliconfig.Environment) (string, error) {
4545
var out string
4646

47-
t := syncAPIsTable([]schema.SyncAPI{*syncAPI}, []string{env.Name})
47+
t := realtimeAPIsTable([]schema.RealtimeAPI{*realtimeAPI}, []string{env.Name})
4848
t.FindHeaderByTitle(_titleEnvironment).Hidden = true
49-
t.FindHeaderByTitle(_titleSyncAPI).Hidden = true
49+
t.FindHeaderByTitle(_titleRealtimeAPI).Hidden = true
5050
if env.Provider == types.LocalProviderType {
5151
hideReplicaCountColumns(&t)
5252
}
5353

5454
out += t.MustFormat()
5555

56-
if env.Provider != types.LocalProviderType && syncAPI.Spec.Monitoring != nil {
57-
switch syncAPI.Spec.Monitoring.ModelType {
56+
if env.Provider != types.LocalProviderType && realtimeAPI.Spec.Monitoring != nil {
57+
switch realtimeAPI.Spec.Monitoring.ModelType {
5858
case userconfig.ClassificationModelType:
59-
out += "\n" + classificationMetricsStr(&syncAPI.Metrics)
59+
out += "\n" + classificationMetricsStr(&realtimeAPI.Metrics)
6060
case userconfig.RegressionModelType:
61-
out += "\n" + regressionMetricsStr(&syncAPI.Metrics)
61+
out += "\n" + regressionMetricsStr(&realtimeAPI.Metrics)
6262
}
6363
}
6464

65-
if syncAPI.DashboardURL != "" {
66-
out += "\n" + console.Bold("metrics dashboard: ") + syncAPI.DashboardURL + "\n"
65+
if realtimeAPI.DashboardURL != "" {
66+
out += "\n" + console.Bold("metrics dashboard: ") + realtimeAPI.DashboardURL + "\n"
6767
}
6868

69-
out += "\n" + console.Bold("endpoint: ") + syncAPI.Endpoint
69+
out += "\n" + console.Bold("endpoint: ") + realtimeAPI.Endpoint
7070

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

73-
if syncAPI.Spec.Predictor.Type == userconfig.TensorFlowPredictorType || syncAPI.Spec.Predictor.Type == userconfig.ONNXPredictorType {
74-
out += "\n" + describeModelInput(&syncAPI.Status, syncAPI.Endpoint)
73+
if realtimeAPI.Spec.Predictor.Type == userconfig.TensorFlowPredictorType || realtimeAPI.Spec.Predictor.Type == userconfig.ONNXPredictorType {
74+
out += "\n" + describeModelInput(&realtimeAPI.Status, realtimeAPI.Endpoint)
7575
}
7676

77-
out += titleStr("configuration") + strings.TrimSpace(syncAPI.Spec.UserStr(env.Provider))
77+
out += titleStr("configuration") + strings.TrimSpace(realtimeAPI.Spec.UserStr(env.Provider))
7878

7979
return out, nil
8080
}
8181

82-
func syncAPIsTable(syncAPIs []schema.SyncAPI, envNames []string) table.Table {
83-
rows := make([][]interface{}, 0, len(syncAPIs))
82+
func realtimeAPIsTable(realtimeAPIs []schema.RealtimeAPI, envNames []string) table.Table {
83+
rows := make([][]interface{}, 0, len(realtimeAPIs))
8484

8585
var totalFailed int32
8686
var totalStale int32
8787
var total4XX int
8888
var total5XX int
8989

90-
for i, syncAPI := range syncAPIs {
91-
lastUpdated := time.Unix(syncAPI.Spec.LastUpdated, 0)
90+
for i, realtimeAPI := range realtimeAPIs {
91+
lastUpdated := time.Unix(realtimeAPI.Spec.LastUpdated, 0)
9292
rows = append(rows, []interface{}{
9393
envNames[i],
94-
syncAPI.Spec.Name,
95-
syncAPI.Status.Message(),
96-
syncAPI.Status.Updated.Ready,
97-
syncAPI.Status.Stale.Ready,
98-
syncAPI.Status.Requested,
99-
syncAPI.Status.Updated.TotalFailed(),
94+
realtimeAPI.Spec.Name,
95+
realtimeAPI.Status.Message(),
96+
realtimeAPI.Status.Updated.Ready,
97+
realtimeAPI.Status.Stale.Ready,
98+
realtimeAPI.Status.Requested,
99+
realtimeAPI.Status.Updated.TotalFailed(),
100100
libtime.SinceStr(&lastUpdated),
101-
latencyStr(&syncAPI.Metrics),
102-
code2XXStr(&syncAPI.Metrics),
103-
code4XXStr(&syncAPI.Metrics),
104-
code5XXStr(&syncAPI.Metrics),
101+
latencyStr(&realtimeAPI.Metrics),
102+
code2XXStr(&realtimeAPI.Metrics),
103+
code4XXStr(&realtimeAPI.Metrics),
104+
code5XXStr(&realtimeAPI.Metrics),
105105
})
106106

107-
totalFailed += syncAPI.Status.Updated.TotalFailed()
108-
totalStale += syncAPI.Status.Stale.Ready
107+
totalFailed += realtimeAPI.Status.Updated.TotalFailed()
108+
totalStale += realtimeAPI.Status.Stale.Ready
109109

110-
if syncAPI.Metrics.NetworkStats != nil {
111-
total4XX += syncAPI.Metrics.NetworkStats.Code4XX
112-
total5XX += syncAPI.Metrics.NetworkStats.Code5XX
110+
if realtimeAPI.Metrics.NetworkStats != nil {
111+
total4XX += realtimeAPI.Metrics.NetworkStats.Code4XX
112+
total5XX += realtimeAPI.Metrics.NetworkStats.Code5XX
113113
}
114114
}
115115

116116
return table.Table{
117117
Headers: []table.Header{
118118
{Title: _titleEnvironment},
119-
{Title: _titleSyncAPI},
119+
{Title: _titleRealtimeAPI},
120120
{Title: _titleStatus},
121121
{Title: _titleUpToDate},
122122
{Title: _titleStale, Hidden: totalStale == 0},

0 commit comments

Comments
 (0)