Skip to content

Commit 1d6d2cf

Browse files
author
Peter Amstutz
committed
Updated
1 parent 2033372 commit 1d6d2cf

File tree

3 files changed

+106
-42
lines changed

3 files changed

+106
-42
lines changed

swagger/proto/workflow_execution.swagger.json

Lines changed: 70 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -211,38 +211,6 @@
211211
},
212212
"title": "Log and other info"
213213
},
214-
"ga4gh_wes_parameter": {
215-
"type": "object",
216-
"properties": {
217-
"name": {
218-
"type": "string",
219-
"title": "REQUIRED\nname of the parameter"
220-
},
221-
"value": {
222-
"type": "string",
223-
"title": "OPTIONAL\nValue"
224-
},
225-
"location": {
226-
"type": "string",
227-
"title": "REQUIRED\nlocation in long term storage, is a url specific to the implementing\nsystem. For example s3://my-object-store/file1 or gs://my-bucket/file2 or\nfile:///path/to/my/file"
228-
},
229-
"type": {
230-
"$ref": "#/definitions/ga4gh_wes_parameter_types",
231-
"title": "REQUIRED\nType of data, \"Parameter\", \"File\" or \"Directory\"\nif used for an output all the files in the directory\nwill be copied to the storage location"
232-
}
233-
},
234-
"description": "Parameters for workflows or tasks, these are either output parameters, files, or directories, the latter two are stagged to an object store or something similar for hand back to the caller."
235-
},
236-
"ga4gh_wes_parameter_types": {
237-
"type": "string",
238-
"enum": [
239-
"Directory",
240-
"File",
241-
"Parameter"
242-
],
243-
"default": "Directory",
244-
"title": "Enum for parameter types"
245-
},
246214
"ga4gh_wes_service_info": {
247215
"type": "object",
248216
"properties": {
@@ -387,10 +355,7 @@
387355
"title": "the logs, and other key info like timing and exit code, for each step in the workflow"
388356
},
389357
"outputs": {
390-
"type": "array",
391-
"items": {
392-
"$ref": "#/definitions/ga4gh_wes_parameter"
393-
},
358+
"$ref": "#/definitions/protobufStruct",
394359
"title": "the outputs"
395360
}
396361
}
@@ -400,10 +365,10 @@
400365
"properties": {
401366
"workflow_descriptor": {
402367
"type": "string",
403-
"title": "OPTIONAL\nthe workflow CWL or WDL document"
368+
"title": "OPTIONAL\nthe workflow CWL or WDL document, must provide either this or workflow_url"
404369
},
405370
"workflow_params": {
406-
"type": "string",
371+
"$ref": "#/definitions/protobufStruct",
407372
"title": "REQUIRED\nthe workflow parameterization document (typically a JSON file), includes all parameterizations for the workflow including input and output file locations"
408373
},
409374
"workflow_type": {
@@ -423,7 +388,7 @@
423388
},
424389
"workflow_url": {
425390
"type": "string",
426-
"title": "OPTIONAL\nthe workflow CWL or WDL document"
391+
"title": "OPTIONAL\nthe workflow CWL or WDL document, must provide either this or workflow_descriptor"
427392
}
428393
},
429394
"title": "workflow request object"
@@ -462,6 +427,72 @@
462427
}
463428
},
464429
"title": "available workflow types supported by this WES"
430+
},
431+
"protobufListValue": {
432+
"type": "object",
433+
"properties": {
434+
"values": {
435+
"type": "array",
436+
"items": {
437+
"$ref": "#/definitions/protobufValue"
438+
},
439+
"description": "Repeated field of dynamically typed values."
440+
}
441+
},
442+
"description": "`ListValue` is a wrapper around a repeated field of values.\n\nThe JSON representation for `ListValue` is JSON array."
443+
},
444+
"protobufNullValue": {
445+
"type": "string",
446+
"enum": [
447+
"NULL_VALUE"
448+
],
449+
"default": "NULL_VALUE",
450+
"description": "`NullValue` is a singleton enumeration to represent the null value for the\n`Value` type union.\n\n The JSON representation for `NullValue` is JSON `null`.\n\n - NULL_VALUE: Null value."
451+
},
452+
"protobufStruct": {
453+
"type": "object",
454+
"properties": {
455+
"fields": {
456+
"type": "object",
457+
"additionalProperties": {
458+
"$ref": "#/definitions/protobufValue"
459+
},
460+
"description": "Unordered map of dynamically typed values."
461+
}
462+
},
463+
"description": "`Struct` represents a structured data value, consisting of fields\nwhich map to dynamically typed values. In some languages, `Struct`\nmight be supported by a native representation. For example, in\nscripting languages like JS a struct is represented as an\nobject. The details of that representation are described together\nwith the proto support for the language.\n\nThe JSON representation for `Struct` is JSON object."
464+
},
465+
"protobufValue": {
466+
"type": "object",
467+
"properties": {
468+
"null_value": {
469+
"$ref": "#/definitions/protobufNullValue",
470+
"description": "Represents a null value."
471+
},
472+
"number_value": {
473+
"type": "number",
474+
"format": "double",
475+
"description": "Represents a double value."
476+
},
477+
"string_value": {
478+
"type": "string",
479+
"description": "Represents a string value."
480+
},
481+
"bool_value": {
482+
"type": "boolean",
483+
"format": "boolean",
484+
"description": "Represents a boolean value."
485+
},
486+
"struct_value": {
487+
"$ref": "#/definitions/protobufStruct",
488+
"description": "Represents a structured value."
489+
},
490+
"list_value": {
491+
"$ref": "#/definitions/protobufListValue",
492+
"description": "Represents a repeated `Value`."
493+
}
494+
},
495+
"description": "`Value` represents a dynamically typed value which can be either\nnull, a number, a string, a boolean, a recursive struct value, or a\nlist of values. A producer of value is expected to set one of that\nvariants, absence of any variant indicates an error.\n\nThe JSON representation for `Value` is JSON value."
465496
}
466497
}
467498
}

wes_client.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env python
2+
3+
from bravado.client import SwaggerClient
4+
from bravado.requests_client import RequestsClient
5+
import json
6+
import time
7+
import pprint
8+
import sys
9+
10+
f = open("swagger/proto/workflow_execution.swagger.json")
11+
client = SwaggerClient.from_spec(json.load(f), origin_url="http://localhost:8080")
12+
13+
with open(sys.argv[2]) as f:
14+
input = json.load(f)
15+
16+
r = client.WorkflowExecutionService.RunWorkflow(body={
17+
"workflow_url": sys.argv[1],
18+
"workflow_params": input,
19+
"workflow_type": "CWL",
20+
"workflow_type_version": "v1.0"}).result()
21+
22+
sys.stderr.write(r.workflow_id+"\n")
23+
24+
r = client.WorkflowExecutionService.GetWorkflowStatus(workflow_id=r.workflow_id).result()
25+
while r.state == "Running":
26+
time.sleep(1)
27+
r = client.WorkflowExecutionService.GetWorkflowStatus(workflow_id=r.workflow_id).result()
28+
29+
s = client.WorkflowExecutionService.GetWorkflowLog(workflow_id=r.workflow_id).result()
30+
sys.stderr.write(s.workflow_log.stderr+"\n")
31+
32+
d = {k: s.outputs[k] for k in s.outputs if k != "fields"}
33+
json.dump(d, sys.stdout, indent=4)

cwl_runner_wes.py renamed to wes_service.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def run(self, request):
2525
json.dump(request, f)
2626

2727
with open(os.path.join(self.workdir, "cwl.input.json"), "w") as inputtemp:
28-
inputtemp.write(request["workflow_params"])
28+
json.dump(request["workflow_params"], inputtemp)
2929

3030
if request.get("workflow_descriptor"):
3131
with open(os.path.join(self.workdir, "workflow.cwl"), "w") as f:
@@ -109,7 +109,7 @@ def getlog(self):
109109
"exitCode": exit_code
110110
},
111111
"task_logs": [],
112-
"outputs": []
112+
"outputs": outputobj
113113
}
114114

115115
def cancel(self):
@@ -165,7 +165,7 @@ def GetWorkflowStatus(workflow_id):
165165
def main():
166166
app = connexion.App(__name__, specification_dir='swagger/')
167167
def rs(x):
168-
return utils.get_function_from_name("cwl_runner_wes." + x)
168+
return utils.get_function_from_name("wes_service." + x)
169169

170170
app.add_api('proto/workflow_execution.swagger.json', resolver=Resolver(rs))
171171

0 commit comments

Comments
 (0)