Skip to content
This repository has been archived by the owner on May 31, 2024. It is now read-only.

fix: Converts WDL log exit_code from string to int32 per WES spec #380

Merged
merged 6 commits into from
Mar 30, 2022
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
12 changes: 12 additions & 0 deletions packages/cdk/go.mod
Original file line number Diff line number Diff line change
@@ -1,2 +1,14 @@
// Exclude CDK directory from Go module parsing
module ignore

go 1.17

require (
github.com/aws/aws-cdk-go/awscdk v1.149.0-devpreview
github.com/aws/aws-cdk-go/awscdk/v2 v2.17.0
github.com/aws/constructs-go/constructs/v10 v10.0.92
github.com/aws/constructs-go/constructs/v3 v3.3.246
github.com/aws/jsii-runtime-go v1.55.1
)

require github.com/Masterminds/semver/v3 v3.1.1 // indirect
28 changes: 28 additions & 0 deletions packages/cdk/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc=
github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs=
github.com/aws/aws-cdk-go/awscdk v1.149.0-devpreview h1:gpdOA2oRX0MLXysVFJJUTVjmCFEdukYi3v48j0G93eI=
github.com/aws/aws-cdk-go/awscdk v1.149.0-devpreview/go.mod h1:KsYzWfJFb/1ERW2gWbFTue6veTWoBygVCgy/pX2eMnU=
github.com/aws/aws-cdk-go/awscdk/v2 v2.17.0 h1:nAdo4anojORKe2thFI7glrvixJCBs5XRYZDQ7EabhtM=
github.com/aws/aws-cdk-go/awscdk/v2 v2.17.0/go.mod h1:EBLkGLkGx7DGQHTqth6V+0STQVzJbkrC7WlIQvy54Vs=
github.com/aws/constructs-go/constructs/v10 v10.0.9/go.mod h1:RC6w8bOwxLmPX7Jfo9dkEZ9iVfgH4QnaVnfWvaNOHy0=
github.com/aws/constructs-go/constructs/v10 v10.0.92 h1:D9WDPCUjQRa12yHexsL2PJ9zl4P9oa2yF/3nKNRwYg0=
github.com/aws/constructs-go/constructs/v10 v10.0.92/go.mod h1:nJ+TOsvImM5avqQ9apT6TQaMlZt1LYdBS573ztfcr7k=
github.com/aws/constructs-go/constructs/v3 v3.3.237/go.mod h1:tLZgYT2LxttX7vn2MkqDI/oXP3Kno4obsg6hN4ShfuA=
github.com/aws/constructs-go/constructs/v3 v3.3.246 h1:RjcCROeM7B6wObOxN6TMUD+HAo5jG1J6qPk939ua9M4=
github.com/aws/constructs-go/constructs/v3 v3.3.246/go.mod h1:4FvBHW1fYWFF+3421qEXzPFqJTEHzwvH17Sa0ZJwS6I=
github.com/aws/jsii-runtime-go v1.37.0/go.mod h1:6tZnlstx8bAB3vnLFF9n8bbkI//LDblAek9zFyMXV3E=
github.com/aws/jsii-runtime-go v1.54.0/go.mod h1:9htokR2a9XpRcbNf3fwqPaTs0CpC3KJCOUDMMJvEgZQ=
github.com/aws/jsii-runtime-go v1.55.1 h1:naQzHp7NMVpQ6lElj5tn5HcnBvVjiP+g6XmNzs22Bvs=
github.com/aws/jsii-runtime-go v1.55.1/go.mod h1:9htokR2a9XpRcbNf3fwqPaTs0CpC3KJCOUDMMJvEgZQ=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
9 changes: 8 additions & 1 deletion packages/cli/internal/pkg/cli/workflow/workflow_tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package workflow
import (
"fmt"
"io"
"strconv"
"strings"
"time"

Expand Down Expand Up @@ -103,12 +104,18 @@ func (m *Manager) getTasks() ([]Task, error) {
if len(nameParts) != 2 {
return nil, fmt.Errorf("unable to parse job ID from task name '%s'", taskName)
}

exitCode := "NA"
if taskLog.ExitCode != nil {
exitCode = strconv.FormatInt(int64(*taskLog.ExitCode), 10)
}

tasks[i] = Task{
Name: nameParts[0],
JobId: nameParts[1],
StartTime: parseLogTime(taskLog.StartTime),
StopTime: parseLogTime(taskLog.EndTime),
ExitCode: taskLog.ExitCode,
ExitCode: exitCode,
}
}

Expand Down
57 changes: 56 additions & 1 deletion packages/cli/internal/pkg/cli/workflow/workflow_tasks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
storagemocks "github.com/aws/amazon-genomics-cli/internal/pkg/mocks/storage"
wesmocks "github.com/aws/amazon-genomics-cli/internal/pkg/mocks/wes"
"github.com/aws/amazon-genomics-cli/internal/pkg/wes"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/golang/mock/gomock"
"github.com/rsc/wes_client"
"github.com/stretchr/testify/suite"
Expand Down Expand Up @@ -97,7 +98,7 @@ func (s *GetWorkflowTasksTestSuite) TestGetWorkflowTasks_WithTask() {
Name: testTaskCompositeName,
StartTime: testStartTime.UTC().Format("2006-01-02T15:04:05Z"),
EndTime: testStopTime.UTC().Format("2006-01-02T15:04:05Z"),
ExitCode: testExitCode,
ExitCode: aws.Int32(0),
}},
}, nil)

Expand Down Expand Up @@ -200,6 +201,60 @@ func (s *GetWorkflowTasksTestSuite) TestGetWorkflowTasks_WithTaskNameFailure() {
}
}

func (s *GetWorkflowTasksTestSuite) TestGetWorkflowTasks_WithExitCodeNil() {
defer s.ctrl.Finish()
s.mockProjectClient.EXPECT().Read().Return(s.testProjSpec, nil)
s.mockConfigClient.EXPECT().GetUserId().Return(testUserId, nil)
s.mockDdb.EXPECT().GetWorkflowInstanceById(ctx.Background(), testProjectName, testUserId, testRunId).Return(ddb.WorkflowInstance{ContextName: testContext1Name}, nil)
s.mockCfn.EXPECT().GetStackInfo(testContext1Stack).Return(cfn.StackInfo{Outputs: map[string]string{"WesUrl": testWes1Url}}, nil)
s.mockWes.EXPECT().GetRunLog(ctx.Background(), testRunId).Return(wes_client.RunLog{
RunId: testRunId,
TaskLogs: []wes_client.Log{{
Name: testTaskCompositeName,
StartTime: testStartTime.UTC().Format("2006-01-02T15:04:05Z"),
EndTime: testStopTime.UTC().Format("2006-01-02T15:04:05Z"),
ExitCode: nil,
}},
}, nil)

tasks, err := s.manager.GetWorkflowTasks(testRunId)
s.Assert().NoError(err)
{
s.Assert().Equal(testTaskName, tasks[0].Name)
s.Assert().Equal(testTaskJobId, tasks[0].JobId)
s.Assert().True(tasks[0].StartTime.Equal(testStartTime.Truncate(time.Second)))
s.Assert().True(tasks[0].StopTime.Equal(testStopTime.Truncate(time.Second)))
s.Assert().Equal(tasks[0].ExitCode, "NA")
}
}

func (s *GetWorkflowTasksTestSuite) TestGetWorkflowTasks_WithExitCodeExists() {
defer s.ctrl.Finish()
s.mockProjectClient.EXPECT().Read().Return(s.testProjSpec, nil)
s.mockConfigClient.EXPECT().GetUserId().Return(testUserId, nil)
s.mockDdb.EXPECT().GetWorkflowInstanceById(ctx.Background(), testProjectName, testUserId, testRunId).Return(ddb.WorkflowInstance{ContextName: testContext1Name}, nil)
s.mockCfn.EXPECT().GetStackInfo(testContext1Stack).Return(cfn.StackInfo{Outputs: map[string]string{"WesUrl": testWes1Url}}, nil)
s.mockWes.EXPECT().GetRunLog(ctx.Background(), testRunId).Return(wes_client.RunLog{
RunId: testRunId,
TaskLogs: []wes_client.Log{{
Name: testTaskCompositeName,
StartTime: testStartTime.UTC().Format("2006-01-02T15:04:05Z"),
EndTime: testStopTime.UTC().Format("2006-01-02T15:04:05Z"),
ExitCode: aws.Int32(0),
}},
}, nil)

tasks, err := s.manager.GetWorkflowTasks(testRunId)
s.Assert().NoError(err)
{
s.Assert().Equal(testTaskName, tasks[0].Name)
s.Assert().Equal(testTaskJobId, tasks[0].JobId)
s.Assert().True(tasks[0].StartTime.Equal(testStartTime.Truncate(time.Second)))
s.Assert().True(tasks[0].StopTime.Equal(testStopTime.Truncate(time.Second)))
s.Assert().Equal(testExitCode, "0")
}
}

func TestGetWorkflowTasksTestSuite(t *testing.T) {
suite.Run(t, new(GetWorkflowTasksTestSuite))
}
Original file line number Diff line number Diff line change
Expand Up @@ -230,15 +230,14 @@ def to_log(job_details: JobDetailTypeDef) -> Log:

start_time = to_iso(job_details.get("startedAt"))
end_time = to_iso(job_details.get("stoppedAt"))
exitCode = job_details["container"].get("exitCode")

return Log(
name=task_name,
cmd=job_details["container"]["command"],
start_time=start_time,
end_time=end_time,
stdout=job_details["container"].get("logStreamName"),
exit_code=("" if exitCode == None else str(exitCode)),
exit_code=job_details["container"].get("exitCode"),
)


Expand Down
2 changes: 1 addition & 1 deletion packages/wes_api/client/model_log.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ type Log struct {
Stderr string `json:"stderr,omitempty"`

// Exit code of the program
ExitCode string `json:"exit_code,omitempty"`
ExitCode *int32 `json:"exit_code,omitempty"`
}