Search in sources :

Example 1 with ExecutionListener

use of org.flyte.localengine.ExecutionListener in project flytekit-java by flyteorg.

the class ExecuteLocal method call.

@Override
public Integer call() {
    Map<String, ClassLoader> modules = ExecuteLocalLoader.loadModules(packageDir);
    Map<String, String> env = ImmutableMap.of("FLYTE_INTERNAL_DOMAIN", "development", "FLYTE_INTERNAL_VERSION", "test", "FLYTE_INTERNAL_PROJECT", "flytetester");
    Map<String, RunnableTask> runnableTasks = ExecuteLocalLoader.loadTasks(modules, env);
    Map<String, DynamicWorkflowTask> dynamicWorkflowTasks = // TODO support dynamic tasks
    emptyMap();
    Map<String, WorkflowTemplate> workflows = ExecuteLocalLoader.loadWorkflows(modules, env);
    WorkflowTemplate workflow = Preconditions.checkNotNull(workflows.get(workflowName), "workflow not found [%s]", workflowName);
    String synopsis = getCustomSynopsis();
    List<String> inputArgsList = inputArgs == null ? Collections.emptyList() : Arrays.asList(inputArgs);
    Map<String, Literal> inputs = getArgsParser().parseInputs(synopsis, workflow.interface_().inputs(), inputArgsList);
    try {
        // TODO, use logging listener here
        ExecutionListener listener = NoopExecutionListener.create();
        Map<String, Literal> outputs = LocalEngine.compileAndExecute(workflow, runnableTasks, dynamicWorkflowTasks, inputs, listener);
        LOG.info("Outputs: " + StringUtil.serializeLiteralMap(outputs));
        return 0;
    } catch (Throwable e) {
        return handleException(e);
    }
}
Also used : WorkflowTemplate(org.flyte.api.v1.WorkflowTemplate) NoopExecutionListener(org.flyte.localengine.NoopExecutionListener) ExecutionListener(org.flyte.localengine.ExecutionListener) DynamicWorkflowTask(org.flyte.api.v1.DynamicWorkflowTask) Literal(org.flyte.api.v1.Literal) RunnableTask(org.flyte.api.v1.RunnableTask)

Aggregations

DynamicWorkflowTask (org.flyte.api.v1.DynamicWorkflowTask)1 Literal (org.flyte.api.v1.Literal)1 RunnableTask (org.flyte.api.v1.RunnableTask)1 WorkflowTemplate (org.flyte.api.v1.WorkflowTemplate)1 ExecutionListener (org.flyte.localengine.ExecutionListener)1 NoopExecutionListener (org.flyte.localengine.NoopExecutionListener)1