Skip to content

Commit 3d20546

Browse files
author
Peter Amstutz
committed
Update README. Add --wait/--no-wait flags.
1 parent d92225b commit 3d20546

File tree

3 files changed

+83
-42
lines changed

3 files changed

+83
-42
lines changed

README.md

Lines changed: 70 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,85 @@
1-
This is a proof of concept web service for the Common Workflow Language. It
2-
works with any `cwl-runner` that supports the CWL standard command line interface:
3-
http://www.commonwl.org/draft-3/CommandLineTool.html#Executing_CWL_documents_as_scripts
1+
# Workflow as a Service
42

5-
Theory of operation:
3+
This provides client and server implementations of the [GA4GH Workflow
4+
Execution Service](https://github.com/ga4gh/workflow-execution-schemas) API for
5+
the Common Workflow Language.
66

7-
* Accept job order via HTTP POST, create job and redirect to job URL
8-
* Client can poll for job status
9-
* Client can get streaming logs (stderr of `cwl-runner`)
7+
It provides an (Arvados)[https://github.com/curoverse/arvados] backend. It
8+
also works with any `cwl-runner` that supports the CWL standard command line
9+
interface: http://www.commonwl.org/v1.0/CommandLineTool.html#Executing_CWL_documents_as_scripts
1010

1111
Installation:
1212

1313
```
14-
python setup.py install
14+
pip install wes-service
1515
```
1616

17-
Run standalone server:
17+
Run a standalone server with default `cwl-runner` backend:
1818

1919
```
20-
cwl-server
20+
$ wes-server
2121
```
2222

23-
Run a job, get status, get log:
23+
Submit a workflow to run:
2424

2525
```
26-
$ echo '{"message": "It works"}' | curl -L -X POST -d@- http://localhost:5000/run?wf=https://raw.githubusercontent.com/common-workflow-language/common-workflow-language/master/draft-3/examples/1st-tool.cwl
27-
{
28-
"state": "Running",
29-
"run": "https://raw.githubusercontent.com/common-workflow-language/common-workflow-language/master/draft-3/examples/1st-tool.cwl",
30-
"log": "http://localhost:5000/jobs/0/log",
31-
"input": {
32-
"message": "It works"
33-
},
34-
"output": null,
35-
"id": "http://localhost:5000/jobs/0"
36-
}
37-
$ curl http://localhost:5000/jobs/0
38-
{
39-
"state": "Success",
40-
"run": "https://raw.githubusercontent.com/common-workflow-language/common-workflow-language/master/draft-3/examples/1st-tool.cwl",
41-
"log": "http://localhost:5000/jobs/0/log",
42-
"input": {
43-
"message": "It works"
44-
},
45-
"output": {},
46-
"id": "http://localhost:5000/jobs/0"
47-
}
48-
$ curl http://localhost:5000/jobs/0/log
49-
cwl-runner 1.0.20160518201549
50-
[job 1st-tool.cwl] /tmp/tmpKcoc_I$ echo \
51-
'It works'
52-
It works
53-
Final process status is success
26+
$ wes-client --host=localhost:8080 myworkflow.cwl myjob.json
27+
```
28+
29+
List workflows:
30+
31+
```
32+
$ wes-client --list
33+
```
34+
35+
Get workflow status:
36+
37+
```
38+
$ wes-client --get <workflow-id>
39+
```
40+
41+
Get stderr log from workflow:
42+
43+
```
44+
$ wes-client --log <workflow-id>
45+
```
46+
47+
# Server Options
48+
49+
## Run a standalone server with Arvados backend:
50+
51+
```
52+
$ wes-server --backend=wes_service.arvados_wes
53+
```
54+
55+
## Use a different executable with cwl_runner backend
56+
57+
```
58+
$ wes-server --backend=wes_service.cwl_runner --opt runner=cwltoil
59+
```
60+
61+
## Pass parameters to cwl-runner
62+
63+
```
64+
$ wes-server --backend=wes_service.cwl_runner --opt extra=--workDir=/
65+
```
66+
67+
# Client environment options
68+
69+
Set service endpoint:
70+
71+
```
72+
$ export WES_API_HOST=localhost:8080
73+
```
74+
75+
Set the value to pass in the `Authorization` header:
76+
77+
```
78+
$ export WES_API_AUTH=my_api_token
79+
```
80+
81+
Set the protocol (one of http, https)
82+
83+
```
84+
$ export WES_API_PROTO=http
5485
```

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
SETUP_DIR = os.path.dirname(__file__)
1111
README = os.path.join(SETUP_DIR, 'README.md')
1212

13-
setup(name='wes_service',
14-
version='2.0',
13+
setup(name='wes-service',
14+
version='2.1',
1515
description='GA4GH Workflow Execution Service reference implementation',
1616
long_description=open(README).read(),
1717
author='GA4GH Containers and Workflows task team',

wes_client/__init__.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ def main(argv=sys.argv[1:]):
3131
exgroup.add_argument("--list", action="store_true", default=False)
3232
exgroup.add_argument("--version", action="store_true", default=False)
3333

34+
exgroup = parser.add_mutually_exclusive_group()
35+
exgroup.add_argument("--wait", action="store_true", default=True, dest="wait")
36+
exgroup.add_argument("--no-wait", action="store_false", default=True, dest="wait")
37+
3438
parser.add_argument("workflow_url", type=str, nargs="?", default=None)
3539
parser.add_argument("job_order", type=str, nargs="?", default=None)
3640
args = parser.parse_args(argv)
@@ -88,7 +92,11 @@ def fixpaths(d):
8892
"workflow_type": "CWL",
8993
"workflow_type_version": "v1.0"}).result()
9094

91-
logging.info("Workflow id is %s", r["workflow_id"])
95+
if args.wait:
96+
logging.info("Workflow id is %s", r["workflow_id"])
97+
else:
98+
sys.stdout.write(r["workflow_id"]+"\n")
99+
exit(0)
92100

93101
r = client.WorkflowExecutionService.GetWorkflowStatus(workflow_id=r["workflow_id"]).result()
94102
while r["state"] in ("Queued", "Initializing", "Running"):
@@ -100,6 +108,8 @@ def fixpaths(d):
100108
s = client.WorkflowExecutionService.GetWorkflowLog(workflow_id=r["workflow_id"]).result()
101109
logging.info(s["workflow_log"]["stderr"])
102110

111+
if "fields" in s["outputs"] and s["outputs"]["fields"] is None:
112+
del s["outputs"]["fields"]
103113
json.dump(s["outputs"], sys.stdout, indent=4)
104114

105115
if r["state"] == "Complete":

0 commit comments

Comments
 (0)