Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions src/main/java/nl/esciencecenter/controller/dto/WorkflowsZip.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package nl.esciencecenter.controller.dto;

import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -82,15 +83,24 @@ public List<Path> getSnakemakePaths() {
}

/**
* Get the paths to the CWL, Snakemake and the SVG files.
* Get the paths to the existing CWL, Snakemake and the SVG files.
*
* @return List of paths to the CWL, Snakemake and the SVG files.
* @return List of paths to the existing CWL, Snakemake and the SVG files.
*/
public List<Path> getAllPaths() {
List<Path> paths = new ArrayList<>();
for (String fileName : workflows) {
paths.add(RestApeUtils.calculatePath(runID, "CWL", fileName));
paths.add(RestApeUtils.calculatePath(runID, "Snakemake", fileName.replace(".cwl", ".smk")));

Path cwlPath = RestApeUtils.calculatePath(runID, "CWL", fileName);
if(Files.exists(cwlPath)) {
paths.add(cwlPath);
}

Path smkPath = RestApeUtils.calculatePath(runID, "Snakemake", fileName.replace(".cwl", ".smk"));
if(Files.exists(smkPath)) {
paths.add(smkPath);
}

paths.add(RestApeUtils.calculatePath(runID, "Figures", fileName.replace(".cwl", ".svg")));
}
return paths;
Expand Down
26 changes: 22 additions & 4 deletions src/main/java/nl/esciencecenter/restape/APEWorkflowMetadata.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
import lombok.NoArgsConstructor;
import nl.uu.cs.ape.solver.solutionStructure.SolutionWorkflow;

import java.nio.file.Files;
import java.nio.file.Path;

/**
* The {@link APEWorkflowMetadata} class represents metadata for a workflow solution from the APE solver.
* This class encapsulates the details and metadata of a workflow solution,
Expand Down Expand Up @@ -50,11 +53,26 @@ public APEWorkflowMetadata(SolutionWorkflow sol, String runID, boolean benchmark
this.description = sol.getDescription();
this.workflowLength = sol.getSolutionLength();
this.runId = runID;
this.cwlName = sol.getFileName() + ".cwl";
this.snakemakeName = sol.getFileName() + ".smk";
this.figureName = sol.getFileName();

String fileName = sol.getFileName();

Path cwlPath = RestApeUtils.calculatePath(runID, "CWL", fileName + ".cwl");
if(Files.notExists(cwlPath)) {
this.cwlName = "";
} else {
this.cwlName = fileName + ".cwl";
}

Path smkPath = RestApeUtils.calculatePath(runID, "Snakemake", fileName + ".smk");
if(Files.notExists(smkPath)) {
this.snakemakeName = "";
} else {
this.snakemakeName = fileName + ".smk";
}

this.figureName = fileName;
if (benchmark) {
this.benchmarkFile = sol.getFileName() + ".json";
this.benchmarkFile = fileName + ".json";
}
}

Expand Down
22 changes: 19 additions & 3 deletions src/main/java/nl/esciencecenter/restape/ApeAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,27 @@ public static List<APEWorkflowMetadata> runSynthesis(JSONObject configJson, bool
// Define the synthesis run ID
String runID = RestApeUtils.generateRunID(configJson.toString());

SolutionsList candidateSolutions = executeSynthesis(configJson, runID);
String solutionPath = RestApeUtils.createDirectory(runID);

APE apeFramework = new APE(configJson);

APERunConfig runConfig = new APERunConfig(configJson, apeFramework.getDomainSetup());

runConfig.setSolutionPath(solutionPath);
int maxSol = runConfig.getMaxNoSolutions();
runConfig.setNoCWL(maxSol);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be even better if Workflomics would provide these in the configJson, but not crucial atm

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean that APERunConfig sets the count of CWL/SMK/Graphs based on what is written in the configJson or that configJson contains an attribute for count of CWL/SMK/Graphs?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aah, I get it, @vedran-kasalica. You mean that workflomics-frontend sets the existing fields number_of_generated_graphs and number_of_cwl_files in configJson and RestAPE just collects the info from there. I will open an issue.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issue opened.

runConfig.setNoSnakemake(maxSol);
runConfig.setNoGraphs(maxSol);
runConfig.setDebugMode(true);

boolean createPartialScripts = runConfig.getCreatePartialScripts();
Comment thread
vedran-kasalica marked this conversation as resolved.

// run the synthesis and retrieve the solutions
SolutionsList candidateSolutions = apeFramework.runSynthesis(runConfig);

// Write solutions (as CWL and Snakemake files and figures) to the file system.
APE.writeCWLWorkflows(candidateSolutions, true);
APE.writeSnakemakeWorkflows(candidateSolutions, true);
APE.writeCWLWorkflows(candidateSolutions, createPartialScripts);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Totally unrelated, but I just looked up the original implementation and made an issue as this might be redundant to define as such. Workflomics/ape#158

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Set myself as assignee, can refactor this.

APE.writeSnakemakeWorkflows(candidateSolutions, createPartialScripts);
APE.writeTavernaDesignGraphs(candidateSolutions, Format.SVG);
APE.writeTavernaDesignGraphs(candidateSolutions, Format.PNG);

Expand Down
Loading