Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

Commit

Permalink
update FromWorkflowModel call to include typed interface in response …
Browse files Browse the repository at this point in the history
…object. updated tests

Signed-off-by: Guest Account <[email protected]>
  • Loading branch information
squiishyy committed Sep 22, 2023
1 parent dc8cc9d commit ed9e9d3
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
16 changes: 16 additions & 0 deletions pkg/repositories/transformers/workflow.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package transformers

import (
"fmt"
"github.com/flyteorg/flyteadmin/pkg/errors"
"github.com/flyteorg/flyteadmin/pkg/repositories/models"
"github.com/flyteorg/flyteidl/gen/pb-go/flyteidl/admin"
Expand Down Expand Up @@ -47,11 +48,26 @@ func FromWorkflowModel(workflowModel models.Workflow) (admin.Workflow, error) {
return admin.Workflow{}, errors.NewFlyteAdminErrorf(codes.Internal, "failed to read created at timestamp")
}

var workflowInterface core.TypedInterface
if workflowModel.TypedInterface != nil && len(workflowModel.TypedInterface) > 0 {
err = proto.Unmarshal(workflowModel.TypedInterface, &workflowInterface)
if err != nil {
return admin.Workflow{}, errors.NewFlyteAdminErrorf(codes.Internal, fmt.Sprintf("failed to unmarshal workflow %v inputs", workflowModel.ID))
}
}

// Because the spec if offloaded, it is not populated in the model returned here.
return admin.Workflow{
Id: &id,
Closure: &admin.WorkflowClosure{
CreatedAt: createdAt,
CompiledWorkflow: &core.CompiledWorkflowClosure{
Primary: &core.CompiledWorkflow{
Template: &core.WorkflowTemplate{
Interface: &workflowInterface,
},
},
},
},
ShortDescription: workflowModel.ShortDescription,
}, nil
Expand Down
36 changes: 36 additions & 0 deletions pkg/repositories/transformers/workflow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,20 @@ func TestFromWorkflowModel(t *testing.T) {
Name: "name",
Version: "version",
}, workflow.Id))

var workflowInterface core.TypedInterface
err = proto.Unmarshal(workflowModel.TypedInterface, &workflowInterface)
assert.NoError(t, err)

assert.True(t, proto.Equal(&admin.WorkflowClosure{
CreatedAt: createdAtProto,
CompiledWorkflow: &core.CompiledWorkflowClosure{
Primary: &core.CompiledWorkflow{
Template: &core.WorkflowTemplate{
Interface: &workflowInterface,
},
},
},
}, workflow.Closure))
}

Expand Down Expand Up @@ -122,8 +134,19 @@ func TestFromWorkflowModels(t *testing.T) {
Version: "version a",
}, workflowList[0].Id))

var workflowInterface0 core.TypedInterface
err = proto.Unmarshal(workflowModels[0].TypedInterface, &workflowInterface0)
assert.NoError(t, err)

assert.True(t, proto.Equal(&admin.WorkflowClosure{
CreatedAt: createdAtAProto,
CompiledWorkflow: &core.CompiledWorkflowClosure{
Primary: &core.CompiledWorkflow{
Template: &core.WorkflowTemplate{
Interface: &workflowInterface0,
},
},
},
}, workflowList[0].Closure))

assert.True(t, proto.Equal(&core.Identifier{
Expand All @@ -133,7 +156,20 @@ func TestFromWorkflowModels(t *testing.T) {
Name: "name b",
Version: "version b",
}, workflowList[1].Id))

// Expected to be nil
var workflowInterface1 core.TypedInterface
err = proto.Unmarshal(workflowModels[1].TypedInterface, &workflowInterface1)
assert.NoError(t, err)

assert.True(t, proto.Equal(&admin.WorkflowClosure{
CreatedAt: createdAtBProto,
CompiledWorkflow: &core.CompiledWorkflowClosure{
Primary: &core.CompiledWorkflow{
Template: &core.WorkflowTemplate{
Interface: &workflowInterface1,
},
},
},
}, workflowList[1].Closure))
}

0 comments on commit ed9e9d3

Please sign in to comment.