This repository has been archived by the owner on Oct 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 63
/
compiler.go
46 lines (39 loc) · 1.62 KB
/
compiler.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package impl
import (
"github.com/flyteorg/flyteadmin/pkg/errors"
"github.com/flyteorg/flyteadmin/pkg/workflowengine/interfaces"
"github.com/flyteorg/flyteidl/gen/pb-go/flyteidl/core"
"github.com/flyteorg/flytepropeller/pkg/compiler"
"github.com/flyteorg/flytepropeller/pkg/compiler/common"
"google.golang.org/grpc/codes"
)
type workflowCompiler struct {
}
func (c *workflowCompiler) CompileTask(task *core.TaskTemplate) (*core.CompiledTask, error) {
compiledTask, err := compiler.CompileTask(task)
if err != nil {
return nil, errors.NewFlyteAdminErrorf(codes.InvalidArgument, "task failed compilation with %v", err)
}
return compiledTask, nil
}
func (c *workflowCompiler) GetRequirements(fg *core.WorkflowTemplate, subWfs []*core.WorkflowTemplate) (
compiler.WorkflowExecutionRequirements, error) {
requirements, err := compiler.GetRequirements(fg, subWfs)
if err != nil {
return compiler.WorkflowExecutionRequirements{},
errors.NewFlyteAdminErrorf(codes.InvalidArgument, "failed to get workflow requirements with err %v", err)
}
return requirements, nil
}
func (c *workflowCompiler) CompileWorkflow(
primaryWf *core.WorkflowTemplate, subworkflows []*core.WorkflowTemplate, tasks []*core.CompiledTask,
launchPlans []common.InterfaceProvider) (*core.CompiledWorkflowClosure, error) {
compiledWorkflowClosure, err := compiler.CompileWorkflow(primaryWf, subworkflows, tasks, launchPlans)
if err != nil {
return nil, errors.NewFlyteAdminErrorf(codes.InvalidArgument, "failed to compile workflow with err %v", err)
}
return compiledWorkflowClosure, nil
}
func NewCompiler() interfaces.Compiler {
return &workflowCompiler{}
}