use of org.flyte.api.v1.TaskIdentifier in project flytekit-java by flyteorg.
the class ProjectClosure method createTaskTemplates.
static Map<TaskIdentifier, TaskTemplate> createTaskTemplates(ExecutionConfig config, Map<TaskIdentifier, RunnableTask> runnableTasks, Map<TaskIdentifier, DynamicWorkflowTask> dynamicWorkflowTasks) {
Map<TaskIdentifier, TaskTemplate> taskTemplates = new HashMap<>();
runnableTasks.forEach((id, task) -> {
TaskTemplate taskTemplate = createTaskTemplateForRunnableTask(task, config.image());
taskTemplates.put(id, taskTemplate);
});
dynamicWorkflowTasks.forEach((id, task) -> {
TaskTemplate taskTemplate = createTaskTemplateForDynamicWorkflow(task, config.image());
taskTemplates.put(id, taskTemplate);
});
return taskTemplates;
}
use of org.flyte.api.v1.TaskIdentifier in project flytekit-java by flyteorg.
the class ProtoUtilTest method shouldDeserializeTaskId.
@Test
void shouldDeserializeTaskId() {
TaskIdentifier taskId = ProtoUtil.deserializeTaskId(IdentifierOuterClass.Identifier.newBuilder().setResourceType(TASK).setProject(PROJECT).setDomain(DOMAIN).setName(TASK_NAME).setVersion(VERSION).build());
assertThat(taskId, equalTo(TaskIdentifier.builder().project(PROJECT).domain(DOMAIN).name(TASK_NAME).version(VERSION).build()));
}
use of org.flyte.api.v1.TaskIdentifier in project flytekit-java by flyteorg.
the class ProtoUtilTest method shouldSerializeTaskIdentifiers.
@Test
void shouldSerializeTaskIdentifiers() {
String name = "task-a";
TaskIdentifier id = TaskIdentifier.builder().domain(DOMAIN).project(PROJECT).name(name).version(VERSION).build();
IdentifierOuterClass.Identifier serializedId = ProtoUtil.serialize(id);
assertThat(serializedId, equalTo(IdentifierOuterClass.Identifier.newBuilder().setResourceType(TASK).setDomain(DOMAIN).setProject(PROJECT).setName(name).setVersion(VERSION).build()));
}
use of org.flyte.api.v1.TaskIdentifier in project flytekit-java by flyteorg.
the class SdkDynamicWorkflowTaskRegistrar method load.
@Override
@SuppressWarnings("rawtypes")
public Map<TaskIdentifier, DynamicWorkflowTask> load(Map<String, String> env, ClassLoader classLoader) {
ServiceLoader<SdkDynamicWorkflowTask> loader = ServiceLoader.load(SdkDynamicWorkflowTask.class, classLoader);
LOG.fine("Discovering SdkDynamicWorkflowTask");
Map<TaskIdentifier, DynamicWorkflowTask> tasks = new HashMap<>();
SdkConfig sdkConfig = SdkConfig.load(env);
for (SdkDynamicWorkflowTask<?, ?> sdkTask : loader) {
String name = sdkTask.getName();
TaskIdentifier taskId = TaskIdentifier.builder().domain(sdkConfig.domain()).project(sdkConfig.project()).name(name).version(sdkConfig.version()).build();
LOG.fine(String.format("Discovered [%s]", name));
DynamicWorkflowTask task = new DynamicWorkflowTaskImpl<>(sdkTask);
DynamicWorkflowTask previous = tasks.put(taskId, task);
if (previous != null) {
throw new IllegalArgumentException(String.format("Discovered a duplicate dynamic workflow task [%s] [%s] [%s]", name, task, previous));
}
}
return tasks;
}
use of org.flyte.api.v1.TaskIdentifier in project flytekit-java by flyteorg.
the class SdkRunnableTaskRegistrar method load.
@Override
@SuppressWarnings("rawtypes")
public Map<TaskIdentifier, RunnableTask> load(Map<String, String> env, ClassLoader classLoader) {
ServiceLoader<SdkRunnableTask> loader = ServiceLoader.load(SdkRunnableTask.class, classLoader);
LOG.fine("Discovering SdkRunnableTask");
Map<TaskIdentifier, RunnableTask> tasks = new HashMap<>();
SdkConfig sdkConfig = SdkConfig.load(env);
for (SdkRunnableTask<?, ?> sdkTask : loader) {
String name = sdkTask.getName();
TaskIdentifier taskId = TaskIdentifier.builder().domain(sdkConfig.domain()).project(sdkConfig.project()).name(name).version(sdkConfig.version()).build();
LOG.fine(String.format("Discovered [%s]", name));
RunnableTask task = new RunnableTaskImpl<>(sdkTask);
RunnableTask previous = tasks.put(taskId, task);
if (previous != null) {
throw new IllegalArgumentException(String.format("Discovered a duplicate task [%s] [%s] [%s]", name, task, previous));
}
}
return tasks;
}
Aggregations