Skip to content

Commit

Permalink
Fix inputs for WES endpoints (#2367)
Browse files Browse the repository at this point in the history
Fix parameters for Arvados endpoint
  • Loading branch information
Walter Shands committed Apr 16, 2019
1 parent 0b68261 commit 84d3e8b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import com.google.common.io.Files;
import io.dockstore.client.cli.SwaggerUtility;
import io.dockstore.common.FileProvisioning;
import io.dockstore.common.LanguageType;
import io.openapi.wes.client.api.WorkflowExecutionServiceApi;
import io.openapi.wes.client.model.RunId;
Expand All @@ -24,16 +22,13 @@

public class WESLauncher extends BaseLauncher {
private static final Logger LOG = LoggerFactory.getLogger(WESLauncher.class);
private static final String TAGS = "WorkflowExecutionService";
private static final String TAGS = "{\"Client\":\"Dockstore\"}";
private static final String WORKFLOW_TYPE_VERSION = "1.0";

// Cromwell currently supports draft-2 of the WDL specification
// https://cromwell.readthedocs.io/en/stable/LanguageSupport/
private static final String WDL_WORKFLOW_TYPE_VERSION = "draft-2";

protected List<String> command;
protected Map<String, List<FileProvisioning.FileInfo>> outputMap;
protected WorkflowExecutionServiceApi clientWorkflowExecutionServiceApi;
private WorkflowExecutionServiceApi clientWorkflowExecutionServiceApi;


public WESLauncher(AbstractEntryClient abstractEntryClient, LanguageType language, boolean script) {
Expand Down Expand Up @@ -65,7 +60,7 @@ public List<String> buildRunCommand() {
* Provisions output files defined in the parameter file
* @param stdout stdout of running entry
* @param stderr stderr of running entry
* @param wdlOutputTarget
* @param wdlOutputTarget remote path to provision outputs files to (ex: s3://oicr.temp/testing-launcher/)
*/
@Override
public void provisionOutputFiles(String stdout, String stderr, String wdlOutputTarget) {
Expand All @@ -84,8 +79,8 @@ protected void addFilesToWorkflowAttachment(List<File> workflowAttachment, File
try {
SwaggerUtility.unzipFile(zippedEntry, tempDir);
} catch (IOException e) {
System.out.println("Could not get files from workflow attachment " + zippedEntry.getName() + " Request not sent.");
exceptionMessage(e, "Unable to get workflow attachment files from zip file " + zippedEntry.getName(), IO_ERROR);
exceptionMessage(e, "Unable to get workflow attachment files from zip file " + zippedEntry.getName()
+ " Request not sent.", IO_ERROR);
}

try {
Expand All @@ -105,13 +100,12 @@ protected void addFilesToWorkflowAttachment(List<File> workflowAttachment, File
workflowAttachment.add(afile);
}
} catch (Exception e) {
LOG.error("Unable to traverse directory " + tempDir.getName() + " to get workflow attachment files", e);
exceptionMessage(e, "Unable to traverse directory " + tempDir.getName() + " to get workflow "
+ "attachment files", GENERIC_ERROR);
}
}

public void runWESCommand(String jsonString, File localPrimaryDescriptorFile, File zippedEntry) {
public void runWESCommand(String jsonInputFilePath, File localPrimaryDescriptorFile, File zippedEntry) {
String workflowURL = localPrimaryDescriptorFile.getName();
final File tempDir = Files.createTempDir();

Expand All @@ -124,12 +118,21 @@ public void runWESCommand(String jsonString, File localPrimaryDescriptorFile, Fi
// Including it twice should not cause a problem
workflowAttachment.add(localPrimaryDescriptorFile);

addFilesToWorkflowAttachment(workflowAttachment, this.zippedEntry, tempDir);

File jsonInputFile = new File(jsonString);
addFilesToWorkflowAttachment(workflowAttachment, zippedEntry, tempDir);

// add the input file so the endpoint has it; not sure if this is needed
File jsonInputFile = new File(jsonInputFilePath);
workflowAttachment.add(jsonInputFile);

String jsonString = null;
try {
jsonString = abstractEntryClient.fileToJSON(jsonInputFilePath);
} catch (IOException ex) {
exceptionMessage(ex, "Could not construct JSON from " + jsonInputFilePath + ". Request will not be sent to WES "
+ "endpoint. Please check that the input file is proper JSON.", IO_ERROR);
}

String languageType = this.languageType.toString().toUpperCase();

// CWL uses workflow type version with a 'v' prefix, e.g 'v1.0', but WDL uses '1.0'
Expand All @@ -141,8 +144,8 @@ public void runWESCommand(String jsonString, File localPrimaryDescriptorFile, Fi
}

try {
RunId response = clientWorkflowExecutionServiceApi.runWorkflow(jsonInputFile, languageType, workflowTypeVersion, TAGS,
"", workflowURL, workflowAttachment);
RunId response = clientWorkflowExecutionServiceApi.runWorkflow(jsonString, languageType, workflowTypeVersion, TAGS,
"{}", workflowURL, workflowAttachment);
System.out.println("Launched WES run with id: " + response.toString());
} catch (io.openapi.wes.client.ApiException e) {
LOG.error("Error launching WES run", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ paths:
properties:
workflow_params:
type: string
format: binary
format: application/json
workflow_type:
type: string
workflow_type_version:
Expand Down

0 comments on commit 84d3e8b

Please sign in to comment.