Skip to content

Commit

Permalink
Separate workflow_name from task_name
Browse files Browse the repository at this point in the history
  • Loading branch information
komamitsu committed Apr 11, 2017
1 parent 58e06fe commit 03fe130
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
Expand Up @@ -4,6 +4,10 @@
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;

import io.digdag.client.config.Config;
import io.digdag.client.config.ConfigException;
import io.digdag.client.config.ConfigFactory;
Expand Down Expand Up @@ -71,8 +75,16 @@ public static Config buildRuntimeParams(ConfigFactory cf, TaskRequest request)

params.set("retry_attempt_name", request.getRetryAttemptName().orNull());

LinkedList<String> taskNames = new LinkedList<>(Arrays.asList(request.getTaskName().split("\\+")));
// Remove the head empty item
taskNames.remove(0);
String workflowName = taskNames.remove(0);

// workflow_*
params.set("workflow_name", workflowName);

// task_*
params.set("task_name", request.getTaskName());
params.set("task_name", taskNames);

return params;
}
Expand Down
3 changes: 2 additions & 1 deletion digdag-docs/src/workflow_definition.rst
Expand Up @@ -63,7 +63,8 @@ Name Description Exam
**session_local_time** Local time format of session_time 2016-01-30 00:00:00
**session_tz_offset** Time zone offset part of session_time -0800
**session_unixtime** Seconds since the epoch time 1454140800
**task_name** Name of this task +my_workflow+parent_task+child_task0
**workflow_name** Name of this workflow my_workflow
**task_name** Parts of this task name separated with nest [parent_task,child_task3]
=============================== =========================================== ==========================

If `schedule: option is set <scheduling_workflow.html>`_, **last_session_time** and **next_session_time** are also available as following:
Expand Down
Expand Up @@ -73,7 +73,9 @@ public void testRun()
.put("next_session_local_time", is("2016-01-03 00:00:00"))
.put("next_session_tz_offset", is("+0000"))
.put("next_session_unixtime", is("1451779200"))
.put("task_name", is("+built_in_variables+get_variables+task_name"))
.put("workflow_name", is("built_in_variables"))
.put("task_name_full", is("[get_variables,task_name_full]"))
.put("task_name_edge", is("task_name_edge"))
.build();

assertThat(values.entrySet().size(), is(expectedOutput.size()));
Expand Down
Expand Up @@ -50,5 +50,9 @@ schedule:
sh>: "echo next_session_tz_offset: \\'${next_session_tz_offset}\\' >> output.yml"
+next_session_unixtime:
sh>: "echo next_session_unixtime: \\'${next_session_unixtime}\\' >> output.yml"
+task_name:
sh>: "echo task_name: \\'${task_name}\\' >> output.yml"
+workflow_name:
sh>: "echo workflow_name: \\'${workflow_name}\\' >> output.yml"
+task_name_full:
sh>: "echo task_name_full: \\'${task_name}\\' >> output.yml"
+task_name_edge:
sh>: "echo task_name_edge: \\'${task_name[task_name.length - 1]}\\' >> output.yml"

0 comments on commit 03fe130

Please sign in to comment.