Skip to content

Commit 13cf533

Browse files
committed
WIP
1 parent f86cec0 commit 13cf533

7 files changed

Lines changed: 995 additions & 380 deletions

cwl_utils/cwl_v1_0_expression_refactor.py

Lines changed: 13 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import uuid
88
from collections.abc import MutableSequence, Sequence
99
from contextlib import suppress
10-
from typing import Any, Literal, TypeAlias, TypeVar, cast
10+
from typing import Any, cast
1111

1212
from ruamel import yaml
1313
from schema_salad.sourceline import SourceLine
@@ -17,6 +17,17 @@
1717
import cwl_utils.parser.cwl_v1_0_utils as utils
1818
from cwl_utils.errors import JavascriptException, WorkflowException
1919
from cwl_utils.expression import do_eval, interpolate
20+
from cwl_utils.parser.cwl_v1_0_utils import (
21+
AnyTypeSchema,
22+
BasicCommandInputTypeSchemas,
23+
BasicCommandOutputTypeSchemas,
24+
BasicInputTypeSchemas,
25+
BasicOutputTypeSchemas,
26+
CommandInputTypeSchemas,
27+
CommandOutputTypeSchemas,
28+
InputTypeSchemas,
29+
OutputTypeSchemas,
30+
)
2031
from cwl_utils.types import (
2132
CWLDirectoryType,
2233
CWLFileType,
@@ -56,91 +67,6 @@ def escape_expression_field(contents: str) -> str:
5667
return contents.replace("${", "$/{").replace("$(", "$/(")
5768

5869

59-
BasicInputTypeSchemas: TypeAlias = (
60-
cwl.InputArraySchema
61-
| cwl.InputEnumSchema
62-
| cwl.InputRecordSchema
63-
| str
64-
| Literal[
65-
"null",
66-
"boolean",
67-
"int",
68-
"long",
69-
"float",
70-
"double",
71-
"string",
72-
"File",
73-
"Directory",
74-
]
75-
)
76-
InputTypeSchemas: TypeAlias = (
77-
BasicInputTypeSchemas | Sequence[BasicInputTypeSchemas] | None
78-
)
79-
BasicCommandInputTypeSchemas: TypeAlias = (
80-
cwl.CommandInputArraySchema
81-
| cwl.CommandInputEnumSchema
82-
| cwl.CommandInputRecordSchema
83-
| str
84-
| Literal[
85-
"null",
86-
"boolean",
87-
"int",
88-
"long",
89-
"float",
90-
"double",
91-
"string",
92-
"File",
93-
"Directory",
94-
]
95-
)
96-
CommandInputTypeSchemas: TypeAlias = (
97-
BasicCommandInputTypeSchemas | Sequence[BasicCommandInputTypeSchemas] | None
98-
)
99-
BasicOutputTypeSchemas: TypeAlias = (
100-
cwl.OutputArraySchema
101-
| cwl.OutputEnumSchema
102-
| cwl.OutputRecordSchema
103-
| str
104-
| Literal[
105-
"null",
106-
"boolean",
107-
"int",
108-
"long",
109-
"float",
110-
"double",
111-
"string",
112-
"File",
113-
"Directory",
114-
]
115-
)
116-
OutputTypeSchemas: TypeAlias = (
117-
BasicOutputTypeSchemas | Sequence[BasicOutputTypeSchemas] | None
118-
)
119-
BasicCommandOutputTypeSchemas: TypeAlias = (
120-
cwl.CommandOutputArraySchema
121-
| cwl.CommandOutputEnumSchema
122-
| cwl.CommandOutputRecordSchema
123-
| str
124-
| Literal[
125-
"null",
126-
"boolean",
127-
"int",
128-
"long",
129-
"float",
130-
"double",
131-
"string",
132-
"File",
133-
"Directory",
134-
]
135-
)
136-
CommandOutputTypeSchemas: TypeAlias = (
137-
BasicCommandOutputTypeSchemas | Sequence[BasicCommandOutputTypeSchemas] | None
138-
)
139-
AnyTypeSchema = TypeVar(
140-
"AnyTypeSchema", bound=InputTypeSchemas | CommandOutputTypeSchemas
141-
)
142-
143-
14470
def _clean_type_ids(
14571
cwltype: InputTypeSchemas | CommandOutputTypeSchemas,
14672
) -> None:
@@ -162,8 +88,6 @@ def _clean_type_ids(
16288
for field in cwltype.items.fields:
16389
field.name = field.name.split("/")[-1]
16490
elif isinstance(cwltype, cwl.RecordSchema):
165-
if cwltype.name:
166-
cwltype.name = cwltype.name.split("/")[-1]
16791
if cwltype.fields:
16892
for field in cwltype.fields:
16993
field.name = field.name.split("/")[-1]
@@ -686,7 +610,7 @@ def get_input_for_id(
686610
"""Determine the CommandInputParameter for the given input name."""
687611
name = name.split("/")[-1]
688612

689-
for inp in cast(list[cwl.InputParameter], tool.inputs):
613+
for inp in cast(list[cwl.CommandInputParameter], tool.inputs):
690614
if inp.id and inp.id.split("#")[-1].split("/")[-1] == name:
691615
return cwl.CommandInputParameter.fromDoc(
692616
inp.save(), inp.loadingOptions.baseuri, inp.loadingOptions

cwl_utils/cwl_v1_1_expression_refactor.py

Lines changed: 12 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import uuid
88
from collections.abc import MutableSequence, Sequence
99
from contextlib import suppress
10-
from typing import Any, Literal, TypeAlias, TypeVar, cast
10+
from typing import Any, cast
1111

1212
from ruamel import yaml
1313
from schema_salad.sourceline import SourceLine
@@ -17,6 +17,17 @@
1717
import cwl_utils.parser.cwl_v1_1_utils as utils
1818
from cwl_utils.errors import JavascriptException, WorkflowException
1919
from cwl_utils.expression import do_eval, interpolate
20+
from cwl_utils.parser.cwl_v1_1_utils import (
21+
AnyTypeSchema,
22+
BasicCommandInputTypeSchemas,
23+
BasicCommandOutputTypeSchemas,
24+
BasicInputTypeSchemas,
25+
BasicOutputTypeSchemas,
26+
CommandInputTypeSchemas,
27+
CommandOutputTypeSchemas,
28+
InputTypeSchemas,
29+
OutputTypeSchemas,
30+
)
2031
from cwl_utils.types import (
2132
CWLDirectoryType,
2233
CWLFileType,
@@ -56,93 +67,6 @@ def escape_expression_field(contents: str) -> str:
5667
return contents.replace("${", "$/{").replace("$(", "$/(")
5768

5869

59-
BasicInputTypeSchemas: TypeAlias = (
60-
cwl.InputArraySchema
61-
| cwl.InputEnumSchema
62-
| cwl.InputRecordSchema
63-
| str
64-
| Literal[
65-
"null",
66-
"boolean",
67-
"int",
68-
"long",
69-
"float",
70-
"double",
71-
"string",
72-
"File",
73-
"Directory",
74-
"stdin",
75-
]
76-
)
77-
InputTypeSchemas: TypeAlias = BasicInputTypeSchemas | Sequence[BasicInputTypeSchemas]
78-
BasicCommandInputTypeSchemas: TypeAlias = (
79-
cwl.CommandInputArraySchema
80-
| cwl.CommandInputEnumSchema
81-
| cwl.CommandInputRecordSchema
82-
| str
83-
| Literal[
84-
"null",
85-
"boolean",
86-
"int",
87-
"long",
88-
"float",
89-
"double",
90-
"string",
91-
"File",
92-
"Directory",
93-
"stdin",
94-
]
95-
)
96-
CommandInputTypeSchemas: TypeAlias = (
97-
BasicCommandInputTypeSchemas | Sequence[BasicCommandInputTypeSchemas]
98-
)
99-
BasicOutputTypeSchemas: TypeAlias = (
100-
cwl.OutputArraySchema
101-
| cwl.OutputEnumSchema
102-
| cwl.OutputRecordSchema
103-
| str
104-
| Literal[
105-
"null",
106-
"boolean",
107-
"int",
108-
"long",
109-
"float",
110-
"double",
111-
"string",
112-
"File",
113-
"Directory",
114-
"stdout",
115-
"stderr",
116-
]
117-
)
118-
OutputTypeSchemas: TypeAlias = BasicOutputTypeSchemas | Sequence[BasicOutputTypeSchemas]
119-
BasicCommandOutputTypeSchemas: TypeAlias = (
120-
cwl.CommandOutputArraySchema
121-
| cwl.CommandOutputEnumSchema
122-
| cwl.CommandOutputRecordSchema
123-
| str
124-
| Literal[
125-
"null",
126-
"boolean",
127-
"int",
128-
"long",
129-
"float",
130-
"double",
131-
"string",
132-
"File",
133-
"Directory",
134-
"stdout",
135-
"stderr",
136-
]
137-
)
138-
CommandOutputTypeSchemas: TypeAlias = (
139-
BasicCommandOutputTypeSchemas | Sequence[BasicCommandOutputTypeSchemas]
140-
)
141-
AnyTypeSchema = TypeVar(
142-
"AnyTypeSchema", bound=InputTypeSchemas | CommandOutputTypeSchemas
143-
)
144-
145-
14670
def _clean_type_ids(
14771
cwltype: InputTypeSchemas | CommandOutputTypeSchemas,
14872
) -> None:
@@ -164,8 +88,6 @@ def _clean_type_ids(
16488
for field in cwltype.items.fields:
16589
field.name = field.name.split("/")[-1]
16690
elif isinstance(cwltype, cwl.RecordSchema):
167-
if cwltype.name:
168-
cwltype.name = cwltype.name.split("/")[-1]
16991
if cwltype.fields:
17092
for field in cwltype.fields:
17193
field.name = field.name.split("/")[-1]

cwl_utils/cwl_v1_2_expression_refactor.py

Lines changed: 12 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import uuid
88
from collections.abc import MutableSequence, Sequence
99
from contextlib import suppress
10-
from typing import Any, Literal, TypeAlias, TypeVar, cast
10+
from typing import Any, cast
1111

1212
from ruamel import yaml
1313
from schema_salad.sourceline import SourceLine
@@ -17,6 +17,17 @@
1717
import cwl_utils.parser.cwl_v1_2_utils as utils
1818
from cwl_utils.errors import JavascriptException, WorkflowException
1919
from cwl_utils.expression import do_eval, interpolate
20+
from cwl_utils.parser.cwl_v1_2_utils import (
21+
AnyTypeSchema,
22+
BasicCommandInputTypeSchemas,
23+
BasicCommandOutputTypeSchemas,
24+
BasicInputTypeSchemas,
25+
BasicOutputTypeSchemas,
26+
CommandInputTypeSchemas,
27+
CommandOutputTypeSchemas,
28+
InputTypeSchemas,
29+
OutputTypeSchemas,
30+
)
2031
from cwl_utils.types import (
2132
CWLDirectoryType,
2233
CWLFileType,
@@ -56,93 +67,6 @@ def escape_expression_field(contents: str) -> str:
5667
return contents.replace("${", "$/{").replace("$(", "$/(")
5768

5869

59-
BasicInputTypeSchemas: TypeAlias = (
60-
cwl.InputArraySchema
61-
| cwl.InputEnumSchema
62-
| cwl.InputRecordSchema
63-
| str
64-
| Literal[
65-
"null",
66-
"boolean",
67-
"int",
68-
"long",
69-
"float",
70-
"double",
71-
"string",
72-
"File",
73-
"Directory",
74-
"stdin",
75-
]
76-
)
77-
InputTypeSchemas: TypeAlias = BasicInputTypeSchemas | Sequence[BasicInputTypeSchemas]
78-
BasicCommandInputTypeSchemas: TypeAlias = (
79-
cwl.CommandInputArraySchema
80-
| cwl.CommandInputEnumSchema
81-
| cwl.CommandInputRecordSchema
82-
| str
83-
| Literal[
84-
"null",
85-
"boolean",
86-
"int",
87-
"long",
88-
"float",
89-
"double",
90-
"string",
91-
"File",
92-
"Directory",
93-
"stdin",
94-
]
95-
)
96-
CommandInputTypeSchemas: TypeAlias = (
97-
BasicCommandInputTypeSchemas | Sequence[BasicCommandInputTypeSchemas]
98-
)
99-
BasicOutputTypeSchemas: TypeAlias = (
100-
cwl.OutputArraySchema
101-
| cwl.OutputEnumSchema
102-
| cwl.OutputRecordSchema
103-
| str
104-
| Literal[
105-
"null",
106-
"boolean",
107-
"int",
108-
"long",
109-
"float",
110-
"double",
111-
"string",
112-
"File",
113-
"Directory",
114-
"stdout",
115-
"stderr",
116-
]
117-
)
118-
OutputTypeSchemas: TypeAlias = BasicOutputTypeSchemas | Sequence[BasicOutputTypeSchemas]
119-
BasicCommandOutputTypeSchemas: TypeAlias = (
120-
cwl.CommandOutputArraySchema
121-
| cwl.CommandOutputEnumSchema
122-
| cwl.CommandOutputRecordSchema
123-
| str
124-
| Literal[
125-
"null",
126-
"boolean",
127-
"int",
128-
"long",
129-
"float",
130-
"double",
131-
"string",
132-
"File",
133-
"Directory",
134-
"stdout",
135-
"stderr",
136-
]
137-
)
138-
CommandOutputTypeSchemas: TypeAlias = (
139-
BasicCommandOutputTypeSchemas | Sequence[BasicCommandOutputTypeSchemas]
140-
)
141-
AnyTypeSchema = TypeVar(
142-
"AnyTypeSchema", bound=InputTypeSchemas | CommandOutputTypeSchemas
143-
)
144-
145-
14670
def _clean_type_ids(
14771
cwltype: InputTypeSchemas | CommandOutputTypeSchemas,
14872
) -> None:

0 commit comments

Comments
 (0)