Skip to content

Commit 6451581

Browse files
author
Peter Amstutz
committed
Arvados support works
1 parent 24e0ffe commit 6451581

File tree

2 files changed

+24
-15
lines changed

2 files changed

+24
-15
lines changed

wes_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def main(argv=sys.argv[1:]):
5757
input = json.load(f)
5858

5959
workflow_url = args.workflow_url
60-
if not workflow_url.startswith("/") or ":" in workflow_url:
60+
if not workflow_url.startswith("/") and ":" not in workflow_url:
6161
workflow_url = os.path.abspath(workflow_url)
6262

6363
if args.quiet:
@@ -74,7 +74,7 @@ def main(argv=sys.argv[1:]):
7474
logging.info("Workflow id is %s", r["workflow_id"])
7575

7676
r = client.WorkflowExecutionService.GetWorkflowStatus(workflow_id=r["workflow_id"]).result()
77-
while r["state"] == "Running":
77+
while r["state"] in ("Queued", "Initializing", "Running"):
7878
time.sleep(1)
7979
r = client.WorkflowExecutionService.GetWorkflowStatus(workflow_id=r["workflow_id"]).result()
8080

wes_service/arvados_wes.py

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,10 @@ def ListWorkflows(body=None):
4242

4343
api = get_api()
4444

45-
requests = api.container_requests().list(filters=[["requesting_container_uuid", "=", None]]).execute()
46-
containers = api.containers().list(filters=[["uuid", "in", [w["container_uuid"] for w in requests["items"]]]]).execute()
45+
requests = api.container_requests().list(filters=[["requesting_container_uuid", "=", None]],
46+
select=["uuid", "command", "container_uuid"]).execute()
47+
containers = api.containers().list(filters=[["uuid", "in", [w["container_uuid"] for w in requests["items"]]]],
48+
select=["uuid", "state"]).execute()
4749

4850
uuidmap = {c["uuid"]: statemap[c["state"]] for c in containers["items"]}
4951

@@ -60,14 +62,16 @@ def RunWorkflow(body):
6062
return
6163

6264
env = {
65+
"PATH": os.environ["PATH"],
6366
"ARVADOS_API_HOST": os.environ["ARVADOS_API_HOST"],
6467
"ARVADOS_API_TOKEN": connexion.request.headers['Authorization'],
6568
"ARVADOS_API_HOST_INSECURE": os.environ.get("ARVADOS_API_HOST_INSECURE", "false")
6669
}
6770
with tempfile.NamedTemporaryFile() as inputtemp:
68-
json.dump(request["workflow_params"], inputtemp)
69-
workflow_id = subprocess.check_output(["arvados-cwl-runner", "--submit", "--no-wait",
70-
request.get("workflow_url"), inputtemp.name], env=env)
71+
json.dump(body["workflow_params"], inputtemp)
72+
inputtemp.flush()
73+
workflow_id = subprocess.check_output(["arvados-cwl-runner", "--submit", "--no-wait", "--api=containers",
74+
body.get("workflow_url"), inputtemp.name], env=env).strip()
7175
return {"workflow_id": workflow_id}
7276

7377
def visit(d, op):
@@ -102,7 +106,7 @@ def keepref(d):
102106
with c.open("stderr.txt") as f:
103107
stderr = f.read()
104108

105-
return {
109+
r = {
106110
"workflow_id": request["uuid"],
107111
"request": {},
108112
"state": statemap[container["state"]],
@@ -111,19 +115,24 @@ def keepref(d):
111115
"startTime": "",
112116
"endTime": "",
113117
"stdout": "",
114-
"stderr": stderr,
115-
"exitCode": container["exit_code"]
118+
"stderr": stderr
116119
},
117120
"task_logs": [],
118121
"outputs": outputobj
119122
}
123+
if container["exit_code"] is not None:
124+
r["workflow_log"]["exitCode"] = container["exit_code"]
125+
return r
120126

121127

122128
def CancelJob(workflow_id):
123-
job = Workflow(workflow_id)
124-
job.cancel()
125-
return {"workflow_id": workflow_id}
129+
api = get_api()
130+
request = api.container_requests().update(body={"priority": 0}).execute()
131+
return {"workflow_id": request["uuid"]}
126132

127133
def GetWorkflowStatus(workflow_id):
128-
job = Workflow(workflow_id)
129-
return job.getstatus()
134+
api = get_api()
135+
request = api.container_requests().get(uuid=workflow_id).execute()
136+
container = api.containers().get(uuid=request["container_uuid"]).execute()
137+
return {"workflow_id": request["uuid"],
138+
"state": statemap[container["state"]]}

0 commit comments

Comments
 (0)