Skip to content

Commit efc17cc

Browse files
author
Peter Amstutz
committed
WES client supports referencing job document over http.
1 parent c1824a9 commit efc17cc

File tree

2 files changed

+18
-19
lines changed

2 files changed

+18
-19
lines changed

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
'connexion',
3131
'bravado',
3232
'ruamel.yaml >= 0.12.4, < 0.15',
33-
'cwlref-runner'
33+
'cwlref-runner',
34+
'schema-salad'
3435
],
3536
entry_points={
3637
'console_scripts': [ "wes-server=wes_service:main",

wes_client/__init__.py

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from wes_service.util import visit
1414
import urllib
1515
import ruamel.yaml as yaml
16-
16+
import schema_salad.ref_resolver
1717

1818
def main(argv=sys.argv[1:]):
1919
parser = argparse.ArgumentParser(description='Workflow Execution Service')
@@ -75,22 +75,20 @@ def main(argv=sys.argv[1:]):
7575
json.dump(response.result(), sys.stdout, indent=4)
7676
return 0
7777

78-
with open(args.job_order) as f:
79-
input = yaml.safe_load(f)
80-
basedir = os.path.dirname(args.job_order)
81-
82-
def fixpaths(d):
83-
if isinstance(d, dict) and "path" in d:
84-
local_path = os.path.normpath(
85-
os.path.join(os.getcwd(), basedir, d["path"]))
86-
del d["path"]
87-
d["location"] = urllib.pathname2url(local_path)
88-
if isinstance(d, dict) and "location" in d:
89-
if ":" not in d["location"]:
90-
local_path = os.path.normpath(
91-
os.path.join(os.getcwd(), basedir, d["location"]))
92-
d["location"] = urllib.pathname2url(local_path)
93-
visit(input, fixpaths)
78+
loader = schema_salad.ref_resolver.Loader({
79+
"location": {"@type": "@id"}
80+
})
81+
input, _ = loader.resolve_ref(args.job_order)
82+
83+
basedir = os.path.dirname(args.job_order)
84+
85+
def fixpaths(d):
86+
if isinstance(d, dict) and "path" in d:
87+
local_path = os.path.normpath(
88+
os.path.join(os.getcwd(), basedir, d["path"]))
89+
del d["path"]
90+
d["location"] = urllib.pathname2url(local_path)
91+
visit(input, fixpaths)
9492

9593
workflow_url = args.workflow_url
9694
if not workflow_url.startswith("/") and ":" not in workflow_url:
@@ -130,7 +128,7 @@ def fixpaths(d):
130128
del s["outputs"]["fields"]
131129
json.dump(s["outputs"], sys.stdout, indent=4)
132130

133-
if r["state"] == "Complete":
131+
if r["state"] == "COMPLETE":
134132
return 0
135133
else:
136134
return 1

0 commit comments

Comments
 (0)