diff --git a/pkg/manager/impl/testutils/mock_requests.go b/pkg/manager/impl/testutils/mock_requests.go index fda9482e1..c0e765f3e 100644 --- a/pkg/manager/impl/testutils/mock_requests.go +++ b/pkg/manager/impl/testutils/mock_requests.go @@ -300,3 +300,7 @@ func GetWorkflowRequestInterfaceBytes() []byte { bytes, _ := proto.Marshal(GetWorkflowRequest().Spec.Template.Interface) return bytes } + +func GetWorkflowRequestInterface() *core.TypedInterface { + return GetWorkflowRequest().Spec.Template.Interface +} diff --git a/pkg/manager/impl/workflow_manager_test.go b/pkg/manager/impl/workflow_manager_test.go index cc30e8aaf..d8c56b53c 100644 --- a/pkg/manager/impl/workflow_manager_test.go +++ b/pkg/manager/impl/workflow_manager_test.go @@ -454,6 +454,13 @@ func TestListWorkflows(t *testing.T) { assert.Equal(t, fmt.Sprintf("version %v", idx), workflow.Id.Version) assert.True(t, proto.Equal(&admin.WorkflowClosure{ CreatedAt: testutils.MockCreatedAtProto, + CompiledWorkflow: &core.CompiledWorkflowClosure{ + Primary: &core.CompiledWorkflow{ + Template: &core.WorkflowTemplate{ + Interface: &core.TypedInterface{}, + }, + }, + }, }, workflow.Closure)) } assert.Empty(t, workflowList.Token) diff --git a/pkg/repositories/transformers/workflow.go b/pkg/repositories/transformers/workflow.go index ce9b75e00..b9160a772 100644 --- a/pkg/repositories/transformers/workflow.go +++ b/pkg/repositories/transformers/workflow.go @@ -1,6 +1,8 @@ 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" @@ -47,11 +49,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 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 interface. Error message: %v", workflowModel.ID, err.Error())) + } + } + // 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 diff --git a/pkg/repositories/transformers/workflow_test.go b/pkg/repositories/transformers/workflow_test.go index 282bd6c7a..ac35b4735 100644 --- a/pkg/repositories/transformers/workflow_test.go +++ b/pkg/repositories/transformers/workflow_test.go @@ -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)) } @@ -122,8 +134,18 @@ func TestFromWorkflowModels(t *testing.T) { Version: "version a", }, workflowList[0].Id)) + workflowInterface := testutils.GetWorkflowRequestInterface() + assert.NoError(t, err) + assert.True(t, proto.Equal(&admin.WorkflowClosure{ CreatedAt: createdAtAProto, + CompiledWorkflow: &core.CompiledWorkflowClosure{ + Primary: &core.CompiledWorkflow{ + Template: &core.WorkflowTemplate{ + Interface: workflowInterface, + }, + }, + }, }, workflowList[0].Closure)) assert.True(t, proto.Equal(&core.Identifier{ @@ -133,7 +155,15 @@ func TestFromWorkflowModels(t *testing.T) { Name: "name b", Version: "version b", }, workflowList[1].Id)) + assert.True(t, proto.Equal(&admin.WorkflowClosure{ CreatedAt: createdAtBProto, + CompiledWorkflow: &core.CompiledWorkflowClosure{ + Primary: &core.CompiledWorkflow{ + Template: &core.WorkflowTemplate{ + Interface: &core.TypedInterface{}, + }, + }, + }, }, workflowList[1].Closure)) }