Skip to content

Commit be6c843

Browse files
Merging link-based inheritance
1 parent fda9ab2 commit be6c843

45 files changed

Lines changed: 33648 additions & 46692 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ jobs:
7474
env:
7575
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
7676
with:
77-
fail_ci_if_error: true
77+
fail_ci_if_error: false
7878

7979
tox-style:
8080
name: CI linters via Tox

Makefile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,21 +194,25 @@ flake8: FORCE
194194
src/cwl_utils/parser/cwl_v1_0.py: FORCE
195195
schema-salad-tool --codegen python \
196196
--codegen-parser-info "org.w3id.cwl.v1_0" \
197-
https://github.com/common-workflow-language/common-workflow-language/raw/codegen/v1.0/extensions.yml \
197+
--codegen-parent "https://w3id.org/cwl/salad=schema_salad.metaschema" \
198+
https://github.com/common-workflow-language/common-workflow-language/raw/codegen/v1.0/CommonWorkflowLanguage.yml \
198199
> $@
199200

200201
src/cwl_utils/parser/cwl_v1_1.py: FORCE
201202
schema-salad-tool --codegen python \
202203
--codegen-parser-info "org.w3id.cwl.v1_1" \
203-
https://github.com/common-workflow-language/cwl-v1.1/raw/codegen/extensions.yml \
204+
--codegen-parent "https://w3id.org/cwl/salad=schema_salad.metaschema" \
205+
https://github.com/common-workflow-language/cwl-v1.1/raw/codegen/CommonWorkflowLanguage.yml \
204206
> $@
205207

206208
src/cwl_utils/parser/cwl_v1_2.py: FORCE
207209
schema-salad-tool --codegen python \
208210
--codegen-parser-info "org.w3id.cwl.v1_2" \
209-
https://github.com/common-workflow-language/cwl-v1.2/raw/codegen/extensions.yml \
211+
--codegen-parent "https://w3id.org/cwl/salad=schema_salad.metaschema" \
212+
https://github.com/common-workflow-language/cwl-v1.2/raw/codegen/CommonWorkflowLanguage.yml \
210213
> $@
211214

215+
212216
regen_parsers: src/cwl_utils/parser/cwl_v1_*.py
213217

214218
FORCE:

README.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,13 +173,13 @@ Regenerate parsers
173173
To regenerate install the ``schema_salad`` package and run:
174174

175175
``cwl_utils/parser/cwl_v1_0.py`` was created via
176-
``schema-salad-tool --codegen python https://github.com/common-workflow-language/common-workflow-language/raw/codegen/v1.0/extensions.yml --codegen-parser-info "org.w3id.cwl.v1_0" > cwl_utils/parser/cwl_v1_0.py``
176+
``schema-salad-tool --codegen python https://github.com/common-workflow-language/common-workflow-language/raw/codegen/v1.0/CommonWorkflowLanguage.yml --codegen-parent "https://w3id.org/cwl/salad=schema_salad.metaschema" --codegen-parser-info "org.w3id.cwl.v1_0" > src/cwl_utils/parser/cwl_v1_0.py``
177177

178178
``cwl_utils/parser/cwl_v1_1.py`` was created via
179-
``schema-salad-tool --codegen python https://github.com/common-workflow-language/cwl-v1.1/raw/codegen/extensions.yml --codegen-parser-info "org.w3id.cwl.v1_1" > cwl_utils/parser/cwl_v1_1.py``
179+
``schema-salad-tool --codegen python https://github.com/common-workflow-language/cwl-v1.1/raw/codegen/CommonWorkflowLanguage.yml --codegen-parent "https://w3id.org/cwl/salad=schema_salad.metaschema" --codegen-parser-info "org.w3id.cwl.v1_1" > src/cwl_utils/parser/cwl_v1_1.py``
180180

181181
``cwl_utils/parser/cwl_v1_2.py`` was created via
182-
``schema-salad-tool --codegen python https://github.com/common-workflow-language/cwl-v1.2/raw/codegen/extensions.yml --codegen-parser-info "org.w3id.cwl.v1_2" > cwl_utils/parser/cwl_v1_2.py``
182+
``schema-salad-tool --codegen python https://github.com/common-workflow-language/cwl-v1.2/raw/codegen/CommonWorkflowLanguage.yml --codegen-parent "https://w3id.org/cwl/salad=schema_salad.metaschema" --codegen-parser-info "org.w3id.cwl.v1_2" > src/cwl_utils/parser/cwl_v1_2.py``
183183

184184
Release
185185
~~~~~~~

pyproject.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ dependencies = [
3636
"packaging",
3737
"rdflib",
3838
"requests",
39-
"schema-salad >= 8.8.20250205075315,<9",
39+
"schema-salad @ git+https://github.com/common-workflow-language/schema_salad.git@refs/pull/993/head",
4040
"ruamel.yaml >= 0.17.6, < 0.20",
4141
"typing_extensions >= 4.10.0",
4242
]
@@ -71,6 +71,9 @@ cwl-pack = "cwl_utils.pack_cli:main"
7171
cwl-normalizer = "cwl_utils.normalizer:main"
7272
cwl-inputs-schema-gen = "cwl_utils.inputs_schema_gen:main"
7373

74+
[tool.hatch.metadata]
75+
allow-direct-references = true
76+
7477
[tool.pytest.ini_options]
7578
addopts = "-rsx -n auto --pyargs cwl_utils.tests"
7679

src/cwl_utils/cite_extract.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def get_process_from_step(step: cwl.WorkflowStep) -> cwl.Process:
6767
"""Return the process for this step, loading it if needed."""
6868
if isinstance(step.run, str):
6969
return cast(cwl.Process, cwl.load_document_by_uri(step.run))
70-
return cast(cwl.Process, step.run)
70+
return step.run
7171

7272

7373
def traverse_workflow(workflow: cwl.Workflow) -> Iterator[cwl.SoftwareRequirement]:

src/cwl_utils/cwl_v1_0_expression_refactor.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
from typing import Any, cast
1212

1313
from ruamel import yaml
14+
from schema_salad.metaschema import ArraySchema, RecordSchema
15+
from schema_salad.runtime import LoadingOptions
1416
from schema_salad.sourceline import SourceLine
1517
from schema_salad.utils import json_dumps
1618

@@ -71,12 +73,12 @@ def escape_expression_field(contents: str) -> str:
7173
def _clean_type_ids(
7274
cwltype: InputTypeSchemas | CommandOutputTypeSchemas,
7375
) -> None:
74-
if isinstance(cwltype, cwl.ArraySchema):
76+
if isinstance(cwltype, ArraySchema):
7577
if is_sequence(cwltype.items):
7678
for item in cwltype.items:
7779
if hasattr(item, "id"):
7880
item.id = item.id.split("#")[-1]
79-
elif isinstance(cwltype.items, cwl.RecordSchema):
81+
elif isinstance(cwltype.items, RecordSchema):
8082
if (
8183
isinstance(
8284
cwltype.items,
@@ -88,7 +90,7 @@ def _clean_type_ids(
8890
if cwltype.items.fields:
8991
for field in cwltype.items.fields:
9092
field.name = field.name.split("/")[-1]
91-
elif isinstance(cwltype, cwl.RecordSchema):
93+
elif isinstance(cwltype, RecordSchema):
9294
if cwltype.fields:
9395
for field in cwltype.fields:
9496
field.name = field.name.split("/")[-1]
@@ -1479,7 +1481,7 @@ def process_level_reqs(
14791481

14801482

14811483
def add_input_to_process(
1482-
process: cwl.Process, name: str, inptype: Any, loadingOptions: cwl.LoadingOptions
1484+
process: cwl.Process, name: str, inptype: Any, loadingOptions: LoadingOptions
14831485
) -> None:
14841486
"""Add a new InputParameter to the given CommandLineTool."""
14851487
if isinstance(process, cwl.CommandLineTool):
@@ -1555,7 +1557,7 @@ def traverse_CommandLineTool(
15551557
)
15561558
new_target_clt_arguments = list(target_clt.arguments or [])
15571559
new_target_clt_arguments[index] = cwl.CommandLineBinding(
1558-
valueFrom="$(inputs.{})".format(inp_id)
1560+
valueFrom=f"$(inputs.{inp_id})"
15591561
)
15601562
target_clt.arguments = new_target_clt_arguments
15611563
new_target_clt_inputs = list(target_clt.inputs)

src/cwl_utils/cwl_v1_1_expression_refactor.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
from typing import Any, cast
1212

1313
from ruamel import yaml
14+
from schema_salad.metaschema import ArraySchema, RecordSchema
15+
from schema_salad.runtime import LoadingOptions
1416
from schema_salad.sourceline import SourceLine
1517
from schema_salad.utils import json_dumps
1618

@@ -71,12 +73,12 @@ def escape_expression_field(contents: str) -> str:
7173
def _clean_type_ids(
7274
cwltype: InputTypeSchemas | CommandOutputTypeSchemas,
7375
) -> None:
74-
if isinstance(cwltype, cwl.ArraySchema):
76+
if isinstance(cwltype, ArraySchema):
7577
if is_sequence(cwltype.items):
7678
for item in cwltype.items:
7779
if hasattr(item, "id"):
7880
item.id = item.id.split("#")[-1]
79-
elif isinstance(cwltype.items, cwl.RecordSchema):
81+
elif isinstance(cwltype.items, RecordSchema):
8082
if (
8183
isinstance(
8284
cwltype.items,
@@ -88,7 +90,7 @@ def _clean_type_ids(
8890
if cwltype.items.fields:
8991
for field in cwltype.items.fields:
9092
field.name = field.name.split("/")[-1]
91-
elif isinstance(cwltype, cwl.RecordSchema):
93+
elif isinstance(cwltype, RecordSchema):
9294
if cwltype.fields:
9395
for field in cwltype.fields:
9496
field.name = field.name.split("/")[-1]
@@ -1490,7 +1492,7 @@ def process_level_reqs(
14901492

14911493

14921494
def add_input_to_process(
1493-
process: cwl.Process, name: str, inptype: Any, loadingOptions: cwl.LoadingOptions
1495+
process: cwl.Process, name: str, inptype: Any, loadingOptions: LoadingOptions
14941496
) -> None:
14951497
"""Add a new InputParameter to the given CommandLineTool."""
14961498
if isinstance(process, cwl.CommandLineTool):
@@ -1566,7 +1568,7 @@ def traverse_CommandLineTool(
15661568
)
15671569
new_target_clt_arguments = list(target_clt.arguments or [])
15681570
new_target_clt_arguments[index] = cwl.CommandLineBinding(
1569-
valueFrom="$(inputs.{})".format(inp_id)
1571+
valueFrom=f"$(inputs.{inp_id})"
15701572
)
15711573
target_clt.arguments = new_target_clt_arguments
15721574
new_target_clt_inputs = list(target_clt.inputs)

src/cwl_utils/cwl_v1_2_expression_refactor.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
from typing import Any, cast
1212

1313
from ruamel import yaml
14+
from schema_salad.metaschema import ArraySchema, RecordSchema
15+
from schema_salad.runtime import LoadingOptions
1416
from schema_salad.sourceline import SourceLine
1517
from schema_salad.utils import json_dumps
1618

@@ -71,12 +73,12 @@ def escape_expression_field(contents: str) -> str:
7173
def _clean_type_ids(
7274
cwltype: InputTypeSchemas | CommandOutputTypeSchemas,
7375
) -> None:
74-
if isinstance(cwltype, cwl.ArraySchema):
76+
if isinstance(cwltype, ArraySchema):
7577
if is_sequence(cwltype.items):
7678
for item in cwltype.items:
7779
if hasattr(item, "id"):
7880
item.id = item.id.split("#")[-1]
79-
elif isinstance(cwltype.items, cwl.RecordSchema):
81+
elif isinstance(cwltype.items, RecordSchema):
8082
if (
8183
isinstance(
8284
cwltype.items,
@@ -88,7 +90,7 @@ def _clean_type_ids(
8890
if cwltype.items.fields:
8991
for field in cwltype.items.fields:
9092
field.name = field.name.split("/")[-1]
91-
elif isinstance(cwltype, cwl.RecordSchema):
93+
elif isinstance(cwltype, RecordSchema):
9294
if cwltype.name:
9395
cwltype.name = cwltype.name.split("/")[-1]
9496
if cwltype.fields:
@@ -983,7 +985,7 @@ def process_workflow_inputs_and_outputs(
983985
else:
984986
sources = [s.split("#")[-1] for s in param2.outputSource]
985987
source_type_items = utils.type_for_source(workflow, sources)
986-
if isinstance(source_type_items, cwl.ArraySchema):
988+
if isinstance(source_type_items, ArraySchema):
987989
if is_sequence(source_type_items.items):
988990
if "null" not in source_type_items.items:
989991
new_source_type_items_items = list(source_type_items.items)
@@ -1650,7 +1652,7 @@ def process_level_reqs(
16501652

16511653

16521654
def add_input_to_process(
1653-
process: cwl.Process, name: str, inptype: Any, loadingOptions: cwl.LoadingOptions
1655+
process: cwl.Process, name: str, inptype: Any, loadingOptions: LoadingOptions
16541656
) -> None:
16551657
"""Add a new InputParameter to the given CommandLineTool."""
16561658
if isinstance(process, cwl.CommandLineTool):
@@ -1726,7 +1728,7 @@ def traverse_CommandLineTool(
17261728
)
17271729
new_target_clt_arguments = list(target_clt.arguments or [])
17281730
new_target_clt_arguments[index] = cwl.CommandLineBinding(
1729-
valueFrom="$(inputs.{})".format(inp_id)
1731+
valueFrom=f"$(inputs.{inp_id})"
17301732
)
17311733
target_clt.arguments = new_target_clt_arguments
17321734
new_target_clt_inputs = list(target_clt.inputs)

src/cwl_utils/docker_extract.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def get_process_from_step(step: cwl.WorkflowStep) -> cwl.Process:
127127
"""Return the process for this step, loading it if necessary."""
128128
if isinstance(step.run, str):
129129
return cast(cwl.Process, cwl.load_document_by_uri(step.run))
130-
return cast(cwl.Process, step.run)
130+
return step.run
131131

132132

133133
def traverse_workflow(workflow: cwl.Workflow) -> Iterator[cwl.DockerRequirement]:

src/cwl_utils/expression_refactor.py

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@
77
import logging
88
import shutil
99
import sys
10-
from collections.abc import Callable, MutableMapping, MutableSequence
10+
from collections.abc import Callable, MutableSequence
1111
from pathlib import Path
12-
from typing import Any, Protocol
12+
from typing import Any
1313

1414
from ruamel.yaml.main import YAML
1515
from ruamel.yaml.scalarstring import walk_tree
16+
from schema_salad.runtime import save
1617

1718
from cwl_utils import (
1819
cwl_v1_0_expression_refactor,
@@ -29,24 +30,6 @@
2930
_logger.setLevel(logging.INFO)
3031
_cwlutilslogger.setLevel(100)
3132

32-
save_type = (
33-
MutableMapping[str, Any] | MutableSequence[Any] | int | float | bool | str | None
34-
)
35-
36-
37-
class saveCWL(Protocol):
38-
"""Shortcut type for CWL v1.x parse.save()."""
39-
40-
def __call__(
41-
self,
42-
val: Any,
43-
top: bool = True,
44-
base_url: str = "",
45-
relative_uris: bool = True,
46-
) -> save_type:
47-
"""Must use this instead of a Callable due to the keyword args."""
48-
...
49-
5033

5134
def arg_parser() -> argparse.ArgumentParser:
5235
"""Build the argument parser."""
@@ -111,15 +94,12 @@ def refactor(args: argparse.Namespace) -> int:
11194
traverse: Callable[[Any, bool, bool, bool, bool], tuple[Any, bool]] = (
11295
cwl_v1_0_expression_refactor.traverse
11396
)
114-
save: saveCWL = cwl_v1_0.save
11597
case "v1.1":
11698
top = cwl_v1_1.load_document_by_yaml(result, uri)
11799
traverse = cwl_v1_1_expression_refactor.traverse
118-
save = cwl_v1_1.save
119100
case "v1.2":
120101
top = cwl_v1_2.load_document_by_yaml(result, uri)
121102
traverse = cwl_v1_2_expression_refactor.traverse
122-
save = cwl_v1_2.save
123103
case _:
124104
_logger.error(
125105
"Sorry, %s is not a supported CWL version by this tool.",

0 commit comments

Comments
 (0)