Skip to content

Commit 520acbf

Browse files
committed
upgrade to schema salad 7
1 parent 814bd04 commit 520acbf

File tree

6 files changed

+51
-27
lines changed

6 files changed

+51
-27
lines changed

cwltool/load_tool.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,17 @@
2121

2222
from ruamel.yaml.comments import CommentedMap, CommentedSeq
2323
from schema_salad.exceptions import ValidationException
24-
from schema_salad.ref_resolver import (
24+
from schema_salad.fetcher import Fetcher
25+
from schema_salad.ref_resolver import Loader, file_uri
26+
from schema_salad.schema import validate_doc
27+
from schema_salad.sourceline import SourceLine, cmap
28+
from schema_salad.utils import (
2529
ContextType,
26-
Fetcher,
2730
FetcherCallableType,
2831
IdxResultType,
29-
Loader,
3032
ResolveType,
31-
file_uri,
33+
json_dumps,
3234
)
33-
from schema_salad.schema import validate_doc
34-
from schema_salad.sourceline import SourceLine, cmap
35-
from schema_salad.utils import json_dumps
3635

3736
from . import process, update
3837
from .context import LoadingContext

cwltool/provenance_profile.py

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -340,8 +340,7 @@ def declare_file(self, value: CWLObjectType) -> Tuple[ProvEntity, ProvEntity, st
340340
file_id = value.setdefault("@id", uuid.uuid4().urn)
341341
# A specialized entity that has just these names
342342
file_entity = self.document.entity(
343-
file_id,
344-
[(PROV_TYPE, WFPROV["Artifact"]), (PROV_TYPE, WF4EVER["File"])],
343+
file_id, [(PROV_TYPE, WFPROV["Artifact"]), (PROV_TYPE, WF4EVER["File"])],
345344
) # type: ProvEntity
346345

347346
if "basename" in value:
@@ -399,8 +398,7 @@ def declare_directory(self, value: CWLObjectType) -> ProvEntity:
399398
)
400399
# ORE description of ro:Folder, saved separately
401400
coll_b = dir_bundle.entity(
402-
dir_id,
403-
[(PROV_TYPE, RO["Folder"]), (PROV_TYPE, ORE["Aggregation"])],
401+
dir_id, [(PROV_TYPE, RO["Folder"]), (PROV_TYPE, ORE["Aggregation"])],
404402
)
405403
self.document.mentionOf(dir_id + "#ore", dir_id, dir_bundle.identifier)
406404

@@ -515,8 +513,7 @@ def declare_artefact(self, value: Optional[CWLOutputType]) -> ProvEntity:
515513
# FIXME: Don't naively assume add_data_file uses hash in filename!
516514
data_id = "data:%s" % PurePosixPath(data_file).stem
517515
return self.document.entity(
518-
data_id,
519-
{PROV_TYPE: WFPROV["Artifact"], PROV_VALUE: str(value)},
516+
data_id, {PROV_TYPE: WFPROV["Artifact"], PROV_VALUE: str(value)},
520517
)
521518

522519
if isinstance(value, MutableMapping):
@@ -584,10 +581,7 @@ def declare_artefact(self, value: Optional[CWLOutputType]) -> ProvEntity:
584581
# If we reached this, then we were allowed to iterate
585582
coll = self.document.entity(
586583
uuid.uuid4().urn,
587-
[
588-
(PROV_TYPE, WFPROV["Artifact"]),
589-
(PROV_TYPE, PROV["Collection"]),
590-
],
584+
[(PROV_TYPE, WFPROV["Artifact"]), (PROV_TYPE, PROV["Collection"]),],
591585
)
592586
if not members:
593587
coll.add_asserted_type(PROV["EmptyCollection"])
@@ -603,9 +597,7 @@ def declare_artefact(self, value: Optional[CWLOutputType]) -> ProvEntity:
603597
except TypeError:
604598
_logger.warning("Unrecognized type %s of %r", type(value), value)
605599
# Let's just fall back to Python repr()
606-
entity = self.document.entity(
607-
uuid.uuid4().urn, {PROV_LABEL: repr(value)}
608-
)
600+
entity = self.document.entity(uuid.uuid4().urn, {PROV_LABEL: repr(value)})
609601
self.research_object.add_uri(entity.identifier.uri)
610602
return entity
611603

@@ -698,8 +690,7 @@ def prospective_prov(self, job: JobsType) -> None:
698690
stepnametemp = "wf:main/" + str(step.name)[5:]
699691
stepname = urllib.parse.quote(stepnametemp, safe=":/,#")
700692
provstep = self.document.entity(
701-
stepname,
702-
{PROV_TYPE: WFDESC["Process"], "prov:type": PROV["Plan"]},
693+
stepname, {PROV_TYPE: WFDESC["Process"], "prov:type": PROV["Plan"]},
703694
)
704695
self.document.entity(
705696
"wf:main",

release-test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ run_tests() {
1515
mod_loc=$(pip show ${package} |
1616
grep ^Location | awk '{print $2}')/${module}
1717
${test_prefix}bin/py.test "--ignore=${mod_loc}/schemas/" \
18-
--pyarg -x ${module} -n auto --dist=loadfile
18+
--pyargs -x ${module} -n auto --dist=loadfile
1919
}
2020
pipver=7.0.2 # minimum required version of pip
2121
setuptoolsver=24.2.0 # required to generate correct metadata for

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ requests>=2.4.3
22
ruamel.yaml>=0.12.4,<=0.16.5
33
rdflib>=4.2.2,<4.3
44
shellescape>=3.4.1,<3.5
5-
schema-salad>=6,<7
5+
schema-salad>=7,<8
66
typing>=3.5.3; python_version<"3.6"
77
prov==1.5.1
88
bagit==1.6.4

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
"ruamel.yaml >= 0.12.4, <= 0.16.5",
9898
"rdflib >= 4.2.2, < 4.3.0",
9999
"shellescape >= 3.4.1, < 3.5",
100-
"schema-salad >= 6, < 7",
100+
"schema-salad >= 7, < 8",
101101
"mypy-extensions",
102102
"psutil",
103103
"prov == 1.5.1",

tests/test_fetch.py

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import os
22
from pathlib import Path
3-
from typing import Any
3+
from typing import Any, Optional
4+
from urllib.parse import urljoin, urlsplit
45

56
import pytest # type: ignore
6-
from schema_salad.tests.other_fetchers import CWLTestFetcher
7+
import requests
8+
from schema_salad.fetcher import Fetcher
9+
from schema_salad.utils import CacheType
710

811
from cwltool.context import LoadingContext
912
from cwltool.load_tool import load_tool
@@ -15,6 +18,37 @@
1518
from .util import get_data, working_directory
1619

1720

21+
class CWLTestFetcher(Fetcher):
22+
def __init__(
23+
self, cache: CacheType, session: Optional[requests.sessions.Session],
24+
) -> None:
25+
pass
26+
27+
def fetch_text(self, url): # type: (str) -> str
28+
if url == "baz:bar/foo.cwl":
29+
return """
30+
cwlVersion: v1.0
31+
class: CommandLineTool
32+
baseCommand: echo
33+
inputs: []
34+
outputs: []
35+
"""
36+
raise RuntimeError("Not foo.cwl, was %s" % url)
37+
38+
def check_exists(self, url): # type: (str) -> bool
39+
return url == "baz:bar/foo.cwl"
40+
41+
def urljoin(self, base: str, url: str) -> str:
42+
urlsp = urlsplit(url)
43+
if urlsp.scheme:
44+
return url
45+
basesp = urlsplit(base)
46+
47+
if basesp.scheme == "keep":
48+
return base + "/" + url
49+
return urljoin(base, url)
50+
51+
1852
def test_fetcher() -> None:
1953
def test_resolver(d: Any, a: str) -> str:
2054
if a.startswith("baz:bar/"):

0 commit comments

Comments
 (0)