Skip to content

Commit

Permalink
CLI: allow compound inputs as JSON (#688)
Browse files Browse the repository at this point in the history
  • Loading branch information
mlin authored May 1, 2024
1 parent c4db595 commit 2086bb9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
10 changes: 10 additions & 0 deletions WDL/CLI.py
Original file line number Diff line number Diff line change
Expand Up @@ -1260,6 +1260,16 @@ def runner_input_value(s_value, ty, downloadable, root):
return Value.Array(
ty.item_type, [runner_input_value(s_value, ty.item_type, downloadable, root)]
)
if isinstance(ty, (Type.Pair, Type.Map, Type.StructInstance)):
# parse JSON for compound types
try:
return Value.from_json(ty, json.loads(s_value))
except json.JSONDecodeError as exn:
raise Error.InputError(
"Invalid JSON for input of type {}, check syntax and shell quoting: {}".format(
str(ty), exn
)
)
if isinstance(ty, Type.Any):
# infer dynamically-typed runtime overrides
try:
Expand Down
6 changes: 1 addition & 5 deletions tests/runner.t
Original file line number Diff line number Diff line change
Expand Up @@ -621,9 +621,5 @@ task test_task {
>>>
}
EOF
$miniwdl run issue686.wdl -i '{
"read_group": {
"ID": "test"
}
}'
$miniwdl run issue686.wdl read_group='{"ID":"test"}'
is "$?" "0" "ensure optional fields in structs initialized from JSON (issue 686 regression)"

0 comments on commit 2086bb9

Please sign in to comment.