Skip to content

Commit a941a07

Browse files
committed
Revert "Update utils & test to match renamed fields"
This reverts commit 74d4e7a.
1 parent 3491c8b commit a941a07

9 files changed

+295
-317
lines changed

create_cwl_from_objects.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99

1010
def main() -> None:
1111
"""Generate a CWL object to match "cat-tool.cwl"."""
12-
inputs = [cwl.CommandInputParameter(id="file1", type_="File")]
12+
inputs = [cwl.CommandInputParameter(id="file1", type="File")]
1313
outputs = [
1414
cwl.CommandOutputParameter(
1515
id="output",
16-
type_="File",
16+
type="File",
1717
outputBinding=cwl.CommandOutputBinding(glob="output"),
1818
)
1919
]

cwl_utils/cwl_v1_0_expression_refactor.py

Lines changed: 58 additions & 62 deletions
Large diffs are not rendered by default.

cwl_utils/cwl_v1_1_expression_refactor.py

Lines changed: 55 additions & 59 deletions
Large diffs are not rendered by default.

cwl_utils/cwl_v1_2_expression_refactor.py

Lines changed: 62 additions & 70 deletions
Large diffs are not rendered by default.

cwl_utils/parser/cwl_v1_0_utils.py

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ def _compare_records(
3030
This handles normalizing record names, which will be relative to workflow
3131
step, so that they can be compared.
3232
"""
33-
srcfields = {cwl.shortname(field.name): field.type_ for field in (src.fields or {})}
33+
srcfields = {cwl.shortname(field.name): field.type for field in (src.fields or {})}
3434
sinkfields = {
35-
cwl.shortname(field.name): field.type_ for field in (sink.fields or {})
35+
cwl.shortname(field.name): field.type for field in (sink.fields or {})
3636
}
3737
for key in sinkfields.keys():
3838
if (
@@ -63,10 +63,10 @@ def _compare_type(type1: Any, type2: Any) -> bool:
6363
return _compare_type(type1.items, type2.items)
6464
elif isinstance(type1, cwl.RecordSchema) and isinstance(type2, cwl.RecordSchema):
6565
fields1 = {
66-
cwl.shortname(field.name): field.type_ for field in (type1.fields or {})
66+
cwl.shortname(field.name): field.type for field in (type1.fields or {})
6767
}
6868
fields2 = {
69-
cwl.shortname(field.name): field.type_ for field in (type2.fields or {})
69+
cwl.shortname(field.name): field.type for field in (type2.fields or {})
7070
}
7171
if fields1.keys() != fields2.keys():
7272
return False
@@ -184,7 +184,7 @@ def check_types(
184184
return "exception"
185185
if linkMerge == "merge_nested":
186186
return check_types(
187-
cwl.ArraySchema(items=srctype, type_="array"), sinktype, None, None
187+
cwl.ArraySchema(items=srctype, type="array"), sinktype, None, None
188188
)
189189
if linkMerge == "merge_flattened":
190190
return check_types(merge_flatten_type(srctype), sinktype, None, None)
@@ -212,7 +212,7 @@ def content_limit_respected_read(f: IO[bytes]) -> str:
212212
def convert_stdstreams_to_files(clt: cwl.CommandLineTool) -> None:
213213
"""Convert stdout and stderr type shortcuts to files."""
214214
for out in clt.outputs:
215-
if out.type_ == "stdout":
215+
if out.type == "stdout":
216216
if out.outputBinding is not None:
217217
raise ValidationException(
218218
"Not allowed to specify outputBinding when using stdout shortcut."
@@ -223,9 +223,9 @@ def convert_stdstreams_to_files(clt: cwl.CommandLineTool) -> None:
223223
json_dumps(clt.save(), sort_keys=True).encode("utf-8")
224224
).hexdigest()
225225
)
226-
out.type_ = "File"
226+
out.type = "File"
227227
out.outputBinding = cwl.CommandOutputBinding(glob=clt.stdout)
228-
elif out.type_ == "stderr":
228+
elif out.type == "stderr":
229229
if out.outputBinding is not None:
230230
raise ValidationException(
231231
"Not allowed to specify outputBinding when using stderr shortcut."
@@ -236,7 +236,7 @@ def convert_stdstreams_to_files(clt: cwl.CommandLineTool) -> None:
236236
json_dumps(clt.save(), sort_keys=True).encode("utf-8")
237237
).hexdigest()
238238
)
239-
out.type_ = "File"
239+
out.type = "File"
240240
out.outputBinding = cwl.CommandOutputBinding(glob=clt.stderr)
241241

242242

@@ -246,7 +246,7 @@ def merge_flatten_type(src: Any) -> Any:
246246
return [merge_flatten_type(t) for t in src]
247247
if isinstance(src, cwl.ArraySchema):
248248
return src
249-
return cwl.ArraySchema(type_="array", items=src)
249+
return cwl.ArraySchema(type="array", items=src)
250250

251251

252252
def type_for_step_input(
@@ -264,9 +264,9 @@ def type_for_step_input(
264264
cast(str, step_input.id).split("#")[-1]
265265
== cast(str, in_.id).split("#")[-1]
266266
):
267-
input_type = step_input.type_
267+
input_type = step_input.type
268268
if step.scatter is not None and in_.id in aslist(step.scatter):
269-
input_type = cwl.ArraySchema(items=input_type, type_="array")
269+
input_type = cwl.ArraySchema(items=input_type, type="array")
270270
return input_type
271271
return "Any"
272272

@@ -284,15 +284,15 @@ def type_for_step_output(
284284
step_output.id.split("#")[-1].split("/")[-1]
285285
== sourcename.split("#")[-1].split("/")[-1]
286286
):
287-
output_type = step_output.type_
287+
output_type = step_output.type
288288
if step.scatter is not None:
289289
if step.scatterMethod == "nested_crossproduct":
290290
for _ in range(len(aslist(step.scatter))):
291291
output_type = cwl.ArraySchema(
292-
items=output_type, type_="array"
292+
items=output_type, type="array"
293293
)
294294
else:
295-
output_type = cwl.ArraySchema(items=output_type, type_="array")
295+
output_type = cwl.ArraySchema(items=output_type, type="array")
296296
return output_type
297297
raise ValidationException(
298298
"param {} not found in {}.".format(
@@ -312,44 +312,42 @@ def type_for_source(
312312
scatter_context: List[Optional[Tuple[int, str]]] = []
313313
params = param_for_source_id(process, sourcenames, parent, scatter_context)
314314
if not isinstance(params, list):
315-
new_type = params.type_
315+
new_type = params.type
316316
if scatter_context[0] is not None:
317317
if scatter_context[0][1] == "nested_crossproduct":
318318
for _ in range(scatter_context[0][0]):
319-
new_type = cwl.ArraySchema(items=new_type, type_="array")
319+
new_type = cwl.ArraySchema(items=new_type, type="array")
320320
else:
321-
new_type = cwl.ArraySchema(items=new_type, type_="array")
321+
new_type = cwl.ArraySchema(items=new_type, type="array")
322322
if linkMerge == "merge_nested":
323-
new_type = cwl.ArraySchema(items=new_type, type_="array")
323+
new_type = cwl.ArraySchema(items=new_type, type="array")
324324
elif linkMerge == "merge_flattened":
325325
new_type = merge_flatten_type(new_type)
326326
return new_type
327327
new_type = []
328328
for p, sc in zip(params, scatter_context):
329329
if isinstance(p, str) and not any(_compare_type(t, p) for t in new_type):
330330
cur_type = p
331-
elif hasattr(p, "type_") and not any(
332-
_compare_type(t, p.type_) for t in new_type
333-
):
334-
cur_type = p.type_
331+
elif hasattr(p, "type") and not any(_compare_type(t, p.type) for t in new_type):
332+
cur_type = p.type
335333
else:
336334
cur_type = None
337335
if cur_type is not None:
338336
if sc is not None:
339337
if sc[1] == "nested_crossproduct":
340338
for _ in range(sc[0]):
341-
cur_type = cwl.ArraySchema(items=cur_type, type_="array")
339+
cur_type = cwl.ArraySchema(items=cur_type, type="array")
342340
else:
343-
cur_type = cwl.ArraySchema(items=cur_type, type_="array")
341+
cur_type = cwl.ArraySchema(items=cur_type, type="array")
344342
new_type.append(cur_type)
345343
if len(new_type) == 1:
346344
new_type = new_type[0]
347345
if linkMerge == "merge_nested":
348-
return cwl.ArraySchema(items=new_type, type_="array")
346+
return cwl.ArraySchema(items=new_type, type="array")
349347
elif linkMerge == "merge_flattened":
350348
return merge_flatten_type(new_type)
351349
elif isinstance(sourcenames, List) and len(sourcenames) > 1:
352-
return cwl.ArraySchema(items=new_type, type_="array")
350+
return cwl.ArraySchema(items=new_type, type="array")
353351
else:
354352
return new_type
355353

cwl_utils/parser/cwl_v1_1_utils.py

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ def _compare_records(
3030
This handles normalizing record names, which will be relative to workflow
3131
step, so that they can be compared.
3232
"""
33-
srcfields = {cwl.shortname(field.name): field.type_ for field in (src.fields or {})}
33+
srcfields = {cwl.shortname(field.name): field.type for field in (src.fields or {})}
3434
sinkfields = {
35-
cwl.shortname(field.name): field.type_ for field in (sink.fields or {})
35+
cwl.shortname(field.name): field.type for field in (sink.fields or {})
3636
}
3737
for key in sinkfields.keys():
3838
if (
@@ -63,10 +63,10 @@ def _compare_type(type1: Any, type2: Any) -> bool:
6363
return _compare_type(type1.items, type2.items)
6464
elif isinstance(type1, cwl.RecordSchema) and isinstance(type2, cwl.RecordSchema):
6565
fields1 = {
66-
cwl.shortname(field.name): field.type_ for field in (type1.fields or {})
66+
cwl.shortname(field.name): field.type for field in (type1.fields or {})
6767
}
6868
fields2 = {
69-
cwl.shortname(field.name): field.type_ for field in (type2.fields or {})
69+
cwl.shortname(field.name): field.type for field in (type2.fields or {})
7070
}
7171
if fields1.keys() != fields2.keys():
7272
return False
@@ -184,7 +184,7 @@ def check_types(
184184
return "exception"
185185
if linkMerge == "merge_nested":
186186
return check_types(
187-
cwl.ArraySchema(items=srctype, type_="array"), sinktype, None, None
187+
cwl.ArraySchema(items=srctype, type="array"), sinktype, None, None
188188
)
189189
if linkMerge == "merge_flattened":
190190
return check_types(merge_flatten_type(srctype), sinktype, None, None)
@@ -212,7 +212,7 @@ def content_limit_respected_read(f: IO[bytes]) -> str:
212212
def convert_stdstreams_to_files(clt: cwl.CommandLineTool) -> None:
213213
"""Convert stdin, stdout and stderr type shortcuts to files."""
214214
for out in clt.outputs:
215-
if out.type_ == "stdout":
215+
if out.type == "stdout":
216216
if out.outputBinding is not None:
217217
raise ValidationException(
218218
"Not allowed to specify outputBinding when using stdout shortcut."
@@ -223,9 +223,9 @@ def convert_stdstreams_to_files(clt: cwl.CommandLineTool) -> None:
223223
json_dumps(clt.save(), sort_keys=True).encode("utf-8")
224224
).hexdigest()
225225
)
226-
out.type_ = "File"
226+
out.type = "File"
227227
out.outputBinding = cwl.CommandOutputBinding(glob=clt.stdout)
228-
elif out.type_ == "stderr":
228+
elif out.type == "stderr":
229229
if out.outputBinding is not None:
230230
raise ValidationException(
231231
"Not allowed to specify outputBinding when using stderr shortcut."
@@ -236,10 +236,10 @@ def convert_stdstreams_to_files(clt: cwl.CommandLineTool) -> None:
236236
json_dumps(clt.save(), sort_keys=True).encode("utf-8")
237237
).hexdigest()
238238
)
239-
out.type_ = "File"
239+
out.type = "File"
240240
out.outputBinding = cwl.CommandOutputBinding(glob=clt.stderr)
241241
for inp in clt.inputs:
242-
if inp.type_ == "stdin":
242+
if inp.type == "stdin":
243243
if inp.inputBinding is not None:
244244
raise ValidationException(
245245
"Not allowed to specify unputBinding when using stdin shortcut."
@@ -253,7 +253,7 @@ def convert_stdstreams_to_files(clt: cwl.CommandLineTool) -> None:
253253
"$(inputs.%s.path)"
254254
% cast(str, inp.id).rpartition("#")[2].split("/")[-1]
255255
)
256-
inp.type_ = "File"
256+
inp.type = "File"
257257

258258

259259
def merge_flatten_type(src: Any) -> Any:
@@ -262,7 +262,7 @@ def merge_flatten_type(src: Any) -> Any:
262262
return [merge_flatten_type(t) for t in src]
263263
if isinstance(src, cwl.ArraySchema):
264264
return src
265-
return cwl.ArraySchema(type_="array", items=src)
265+
return cwl.ArraySchema(type="array", items=src)
266266

267267

268268
def type_for_step_input(
@@ -280,9 +280,9 @@ def type_for_step_input(
280280
cast(str, step_input.id).split("#")[-1]
281281
== cast(str, in_.id).split("#")[-1]
282282
):
283-
input_type = step_input.type_
283+
input_type = step_input.type
284284
if step.scatter is not None and in_.id in aslist(step.scatter):
285-
input_type = cwl.ArraySchema(items=input_type, type_="array")
285+
input_type = cwl.ArraySchema(items=input_type, type="array")
286286
return input_type
287287
return "Any"
288288

@@ -300,15 +300,15 @@ def type_for_step_output(
300300
output.id.split("#")[-1].split("/")[-1]
301301
== sourcename.split("#")[-1].split("/")[-1]
302302
):
303-
output_type = output.type_
303+
output_type = output.type
304304
if step.scatter is not None:
305305
if step.scatterMethod == "nested_crossproduct":
306306
for _ in range(len(aslist(step.scatter))):
307307
output_type = cwl.ArraySchema(
308-
items=output_type, type_="array"
308+
items=output_type, type="array"
309309
)
310310
else:
311-
output_type = cwl.ArraySchema(items=output_type, type_="array")
311+
output_type = cwl.ArraySchema(items=output_type, type="array")
312312
return output_type
313313
raise ValidationException(
314314
"param {} not found in {}.".format(
@@ -328,44 +328,42 @@ def type_for_source(
328328
scatter_context: List[Optional[Tuple[int, str]]] = []
329329
params = param_for_source_id(process, sourcenames, parent, scatter_context)
330330
if not isinstance(params, list):
331-
new_type = params.type_
331+
new_type = params.type
332332
if scatter_context[0] is not None:
333333
if scatter_context[0][1] == "nested_crossproduct":
334334
for _ in range(scatter_context[0][0]):
335-
new_type = cwl.ArraySchema(items=new_type, type_="array")
335+
new_type = cwl.ArraySchema(items=new_type, type="array")
336336
else:
337-
new_type = cwl.ArraySchema(items=new_type, type_="array")
337+
new_type = cwl.ArraySchema(items=new_type, type="array")
338338
if linkMerge == "merge_nested":
339-
new_type = cwl.ArraySchema(items=new_type, type_="array")
339+
new_type = cwl.ArraySchema(items=new_type, type="array")
340340
elif linkMerge == "merge_flattened":
341341
new_type = merge_flatten_type(new_type)
342342
return new_type
343343
new_type = []
344344
for p, sc in zip(params, scatter_context):
345345
if isinstance(p, str) and not any(_compare_type(t, p) for t in new_type):
346346
cur_type = p
347-
elif hasattr(p, "type_") and not any(
348-
_compare_type(t, p.type_) for t in new_type
349-
):
350-
cur_type = p.type_
347+
elif hasattr(p, "type") and not any(_compare_type(t, p.type) for t in new_type):
348+
cur_type = p.type
351349
else:
352350
cur_type = None
353351
if cur_type is not None:
354352
if sc is not None:
355353
if sc[1] == "nested_crossproduct":
356354
for _ in range(sc[0]):
357-
cur_type = cwl.ArraySchema(items=cur_type, type_="array")
355+
cur_type = cwl.ArraySchema(items=cur_type, type="array")
358356
else:
359-
cur_type = cwl.ArraySchema(items=cur_type, type_="array")
357+
cur_type = cwl.ArraySchema(items=cur_type, type="array")
360358
new_type.append(cur_type)
361359
if len(new_type) == 1:
362360
new_type = new_type[0]
363361
if linkMerge == "merge_nested":
364-
return cwl.ArraySchema(items=new_type, type_="array")
362+
return cwl.ArraySchema(items=new_type, type="array")
365363
elif linkMerge == "merge_flattened":
366364
return merge_flatten_type(new_type)
367365
elif isinstance(sourcenames, List) and len(sourcenames) > 1:
368-
return cwl.ArraySchema(items=new_type, type_="array")
366+
return cwl.ArraySchema(items=new_type, type="array")
369367
else:
370368
return new_type
371369

0 commit comments

Comments
 (0)