Skip to content

Commit ef04398

Browse files
author
Miguel Varela Ramos
committed
Working task submission end to end
1 parent 75e7518 commit ef04398

File tree

3 files changed

+18
-34
lines changed

3 files changed

+18
-34
lines changed

pkg/operator/endpoints/submit_task.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
"github.com/cortexlabs/cortex/pkg/operator/resources"
2828
"github.com/cortexlabs/cortex/pkg/operator/resources/job/taskapi"
2929
"github.com/cortexlabs/cortex/pkg/operator/schema"
30+
"github.com/cortexlabs/cortex/pkg/types/spec"
3031
"github.com/cortexlabs/cortex/pkg/types/userconfig"
3132
"github.com/gorilla/mux"
3233
)
@@ -54,11 +55,16 @@ func SubmitTaskJob(w http.ResponseWriter, r *http.Request) {
5455
return
5556
}
5657

57-
submission := schema.TaskJobSubmission{}
58+
submission := schema.TaskJobSubmission{
59+
RuntimeJobConfig: spec.RuntimeJobConfig{Workers: 1},
60+
}
5861

5962
err = json.Unmarshal(bodyBytes, &submission)
6063
if err != nil {
61-
respondError(w, r, errors.Append(err, fmt.Sprintf("\n\ntask job submission schema can be found at https://docs.cortex.dev/v/%s/", consts.CortexVersionMinor)))
64+
respondError(w, r, errors.Append(err,
65+
fmt.Sprintf("\n\ntask job submission schema can be found at https://docs.cortex.dev/v/%s/",
66+
consts.CortexVersionMinor)),
67+
)
6268
return
6369
}
6470

pkg/operator/operator/k8s.go

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ import (
3636
istioclientnetworking "istio.io/client-go/pkg/apis/networking/v1beta1"
3737
kcore "k8s.io/api/core/v1"
3838
kresource "k8s.io/apimachinery/pkg/api/resource"
39-
kmeta "k8s.io/apimachinery/pkg/apis/meta/v1"
4039
intstr "k8s.io/apimachinery/pkg/util/intstr"
4140
)
4241

@@ -187,9 +186,9 @@ func TaskContainers(api *spec.API) ([]kcore.Container, []kcore.Volume) {
187186
Env: getTaskEnvVars(api, APIContainerName),
188187
EnvFrom: baseEnvVars(),
189188
VolumeMounts: apiPodVolumeMounts,
190-
ReadinessProbe: FileExistsProbe(_apiReadinessFile),
191-
LivenessProbe: _apiLivenessProbe,
192-
Lifecycle: nginxGracefulStopper(api.Kind),
189+
//ReadinessProbe: FileExistsProbe(_apiReadinessFile), // TODO: check if it makes sense to have probes
190+
//LivenessProbe: _apiLivenessProbe,
191+
Lifecycle: nginxGracefulStopper(api.Kind),
193192
Resources: kcore.ResourceRequirements{
194193
Requests: apiPodResourceList,
195194
Limits: apiPodResourceLimitsList,
@@ -652,6 +651,10 @@ func getTaskEnvVars(api *spec.API, container string) []kcore.EnvVar {
652651
Name: "CORTEX_PROJECT_DIR",
653652
Value: path.Join(_emptyDirMountPath, "project"),
654653
},
654+
kcore.EnvVar{
655+
Name: "CORTEX_CACHE_DIR",
656+
Value: _specCacheDir,
657+
},
655658
kcore.EnvVar{
656659
Name: "CORTEX_API_SPEC",
657660
Value: config.BucketPath(api.Key),
@@ -1059,13 +1062,3 @@ func GetEndpointFromVirtualService(virtualService *istioclientnetworking.Virtual
10591062

10601063
return endpoints.GetOne(), nil
10611064
}
1062-
1063-
func extractCortexAnnotations(obj kmeta.Object) map[string]string {
1064-
cortexAnnotations := make(map[string]string)
1065-
for key, value := range obj.GetAnnotations() {
1066-
if strings.Contains(key, "cortex.dev/") {
1067-
cortexAnnotations[key] = value
1068-
}
1069-
}
1070-
return cortexAnnotations
1071-
}

pkg/workloads/cortex/serve/start/task.py

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,12 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
import sys
16-
import os
17-
import argparse
18-
import inspect
19-
import time
2015
import json
21-
import threading
22-
import math
23-
import pathlib
24-
25-
import boto3
26-
import botocore
16+
import os
2717

28-
from cortex import consts
29-
from cortex.lib import util
30-
from cortex.lib.api import API, get_spec, get_api
18+
from cortex.lib.api import get_spec
3119
from cortex.lib.log import cx_logger as logger
32-
from cortex.lib.concurrency import LockedFile
33-
from cortex.lib.storage import S3, LocalStorage
34-
from cortex.lib.exceptions import UserRuntimeException
35-
20+
from cortex.lib.storage import S3
3621

3722
local_cache = {
3823
"api_spec": None,

0 commit comments

Comments
 (0)