MCPcopy
hub / github.com/cortexlabs/cortex / GetJobState

Function GetJobState

pkg/operator/resources/job/state.go:165–182  ·  view source on GitHub ↗
(jobKey spec.JobKey)

Source from the content-addressed store, hash-verified

163}
164
165func GetJobState(jobKey spec.JobKey) (*State, error) {
166 s3Objects, err := config.AWS.ListS3Prefix(config.ClusterConfig.Bucket, jobKey.Prefix(config.ClusterConfig.ClusterUID), false, nil, nil)
167 if err != nil {
168 return nil, errors.Wrap(err, "failed to get job state", jobKey.UserString())
169 }
170
171 if len(s3Objects) == 0 {
172 return nil, errors.Wrap(ErrorJobNotFound(jobKey), "failed to get job state")
173 }
174
175 lastUpdatedMap := map[string]time.Time{}
176 for _, object := range s3Objects {
177 lastUpdatedMap[filepath.Base(*object.Key)] = *object.LastModified
178 }
179
180 jobState := getJobStateFromFiles(jobKey, lastUpdatedMap)
181 return &jobState, nil
182}
183
184func getJobStateFromFiles(jobKey spec.JobKey, lastUpdatedFileMap map[string]time.Time) State {
185 var statusCode status.JobCode

Callers 5

StopJobFunction · 0.92
GetJobStatusFunction · 0.92
getJobStatusFromK8sJobFunction · 0.92
ManageJobResourcesFunction · 0.92
getJobFromS3Function · 0.92

Calls 6

WrapFunction · 0.92
ErrorJobNotFoundFunction · 0.85
getJobStateFromFilesFunction · 0.85
ListS3PrefixMethod · 0.80
PrefixMethod · 0.80
UserStringMethod · 0.45

Tested by

no test coverage detected