use of com.epam.pipeline.controller.vo.TaskGraphVO in project cloud-pipeline by epam.
the class PipelineDocumentTemplateManager method applyTools.
private void applyTools(PipelineDocumentTemplate template) {
TaskGraphVO taskGraph = pipelineVersionManager.getWorkflowGraph(template.getPipeline().getId(), template.getVersion().getName());
template.setWorkflowGraph(taskGraph);
List<Tool> tools = taskGraph.getTasks().stream().filter(t -> t.getTool() != null).map(TaskNode::getTool).collect(Collectors.toList());
template.setOpenSourceSoftware(tools);
}
use of com.epam.pipeline.controller.vo.TaskGraphVO in project cloud-pipeline by epam.
the class PipelineVersionManager method getWorkflowGraph.
public TaskGraphVO getWorkflowGraph(Long id, String version) {
Pipeline pipeline = pipelineManager.load(id);
try {
gitManager.loadRevision(pipeline, version);
} catch (GitClientException e) {
LOGGER.error(e.getMessage(), e);
throw new IllegalArgumentException(e.getMessage());
}
File config = gitManager.getConfigFile(pipeline, version);
TaskGraphVO result = new GraphReader().readGraph(graphScript, config.getParentFile().getAbsolutePath(), CONFIG_FILE_NAME);
mergeToolsRequirements(result);
try {
FileUtils.deleteDirectory(config.getParentFile());
} catch (IOException e) {
LOGGER.error(e.getMessage(), e);
}
return result;
}
use of com.epam.pipeline.controller.vo.TaskGraphVO in project cloud-pipeline by epam.
the class GraphReader method createGraphFromScriptOutput.
protected TaskGraphVO createGraphFromScriptOutput(String output) {
String[] lines = output.split("\\n");
if (lines.length == 0) {
return new TaskGraphVO(new TaskNode(new PipelineTask()));
}
// first line is always name of the root task
String mainTaskName = lines[0].trim();
// important: for main task inputs and outputs are reverted, due
// to luigi's approach to graph calculation
TaskNode mainTask = new TaskNode(new PipelineTask(mainTaskName));
TaskNode currentTask = mainTask;
Map<String, TaskNode> tasks = new HashMap<>();
tasks.put(mainTaskName, mainTask);
mainTask.getTask().setId(1L);
for (int i = 1; i < lines.length; i++) {
String line = lines[i];
if (line.isEmpty()) {
continue;
}
if (line.startsWith(INPUT_START) && currentTask != null) {
String value = line.substring(INPUT_START.length());
parseValue(currentTask.getInputs(), value);
} else if (line.startsWith(OUTPUT_START) && currentTask != null) {
String value = line.substring(OUTPUT_START.length());
parseValue(currentTask.getOutputs(), value);
} else if (line.startsWith(TOOL_START) && currentTask != null) {
parseTool(currentTask, line);
} else if (line.contains(DEPENDENCY_DELIMITER)) {
String[] dependency = line.split(DEPENDENCY_DELIMITER);
TaskNode fromTask = getOrCreateNode(dependency[0].trim(), tasks);
String secondTaskName = dependency.length > 1 ? dependency[1].trim() : "";
// input to all pipeline
if (dependency.length == 1 || secondTaskName.isEmpty()) {
currentTask = null;
mainTask.getOutputs().addAll(fromTask.getInputs());
} else {
TaskNode toTask = getOrCreateNode(secondTaskName, tasks);
currentTask = toTask;
toTask.addParent(fromTask.getTask().getId());
}
}
}
// switch output and input for main task
mainTask.switchInputOutput();
TaskGraphVO graph = new TaskGraphVO(mainTask);
graph.setTasks(new ArrayList<>(tasks.values()));
return graph;
}
use of com.epam.pipeline.controller.vo.TaskGraphVO in project cloud-pipeline by epam.
the class GraphReaderTest method testParsing.
@Test
public void testParsing() {
String output = "SimplePipeline(sample=&sample&, run_id=&run_id&)\n" + "IN:R1_001_fastqc.zip;L001_R2_001_fastqc.zip;AlignmentSummaryMetrics.txt;\n" + "OUT:\n" + "SimplePipeline(sample=&sample&, run_id=&run_id&) => " + "FastQC(sample=&sample&, run_id=&run_id&, first=True)\n" + "IN:L001_R1_001.fastq.gz;L001_R2_001.fastq.gz;\n" + "OUT:L001_R1_001_fastqc.zip;L001_R1_001_fastqc.html;\n" + "FastQC(sample=&sample&, run_id=&run_id&, first=True) => \n" + "IN:\n" + "OUT:L001_R1_001.fastq.gz;L001_R2_001.fastq.gz;\n" + "SimplePipeline(sample=&sample&, run_id=&run_id&) => " + "FastQC(sample=&sample&, run_id=&run_id&, first=False)\n" + "IN:L001_R1_001.fastq.gz;L001_R2_001.fastq.gz;\n" + "OUT:L001_R2_001_fastqc.zip;L001_R2_001_fastqc.html;\n" + "FastQC(sample=&sample&, run_id=&run_id&, first=False) => \n" + "IN:\n" + "OUT:L001_R1_001.fastq.gz;L001_R2_001.fastq.gz;\n" + "SimplePipeline(sample=&sample&, run_id=&run_id&) =>" + " AlignmentSummaryMetrics(sample=&sample&, run_id=&run_id&)\n" + "IN:sample.bai\n" + "OUT:AlignmentSummaryMetrics.txt\n";
GraphReader reader = new GraphReader();
TaskGraphVO graph = reader.createGraphFromScriptOutput(output);
Assert.assertNotNull(graph);
Assert.assertEquals(4, graph.getTasks().size());
}
Aggregations