Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add wait flag for jobs, fix go proto path for dataset service #138

Merged
merged 1 commit into from
Feb 20, 2019
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
32 changes: 32 additions & 0 deletions cli/feast/cmd/jobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,18 @@ import (
"errors"
"fmt"
"io/ioutil"
"time"

"github.com/gojek/feast/cli/feast/pkg/parse"
"github.com/gojek/feast/protos/generated/go/feast/core"

"github.com/spf13/cobra"
)

var (
waitJobComplete = false
)

// jobsCmd represents the jobs command
var jobsCmd = &cobra.Command{
Use: "jobs",
Expand Down Expand Up @@ -63,6 +68,7 @@ var jobsAbortCmd = &cobra.Command{
}

func init() {
jobsRunCmd.Flags().BoolVar(&waitJobComplete, "wait", false, "wait for job to run to completion")
jobsCmd.AddCommand(jobsRunCmd)
jobsCmd.AddCommand(jobsAbortCmd)
rootCmd.AddCommand(jobsCmd)
Expand All @@ -86,9 +92,35 @@ func runJob(ctx context.Context, path string) error {
return fmt.Errorf("[jobs] failed to start job: %v", err)
}
fmt.Printf("[jobs] started job with ID: %s", out.GetJobId())
if waitJobComplete {
return waitJob(ctx, jobsClient, out.GetJobId())
}
return nil
}

func waitJob(ctx context.Context, jobsClient core.JobServiceClient, jobID string) error {
for {
response, err := jobsClient.GetJob(ctx, &core.JobServiceTypes_GetJobRequest{
Id: jobID,
})
if err != nil {
return fmt.Errorf("[jobs] error while querying job id %s: %v", jobID, err)
}

status := response.GetJob().GetStatus()
fmt.Printf("\r[jobs] job id %s is currently: %s\n", jobID, status)
switch status {
case "COMPLETED":
return nil
case "ABORTED":
return fmt.Errorf("[jobs] job id %s failed: Job was aborted", jobID)
case "ERROR":
return fmt.Errorf("[jobs] job id %s failed: Job terminated with error. For more information, refer to job logs", jobID)
}
time.Sleep(5 * time.Second)
}
}

func abortJob(ctx context.Context, id string) error {
initConn()
jobsClient := core.NewJobServiceClient(coreConn)
Expand Down
2 changes: 1 addition & 1 deletion protos/feast/core/DatasetService.proto
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import "google/protobuf/timestamp.proto";

option java_package = "feast.core";
option java_outer_classname = "DatasetServiceProto";
option go_package = "github.com/gojektech/feast/protos/generated/go/feast/core";
option go_package = "github.com/gojek/feast/protos/generated/go/feast/core";

service DatasetService {
// Create training dataset for a feature set
Expand Down
Loading