Skip to content

Commit 20d664e

Browse files
authored
Merge pull request #1242 from common-workflow-language/control-cache
Control doc cache
2 parents 227f35a + a54f2c5 commit 20d664e

File tree

6 files changed

+33
-6
lines changed

6 files changed

+33
-6
lines changed

cwltool/argparser.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,22 @@ def arg_parser() -> argparse.ArgumentParser:
340340
dest="skip_schemas",
341341
)
342342

343+
exgroup = parser.add_mutually_exclusive_group()
344+
exgroup.add_argument(
345+
"--no-doc-cache",
346+
action="store_false",
347+
help="Disable disk cache for documents loaded over HTTP",
348+
default=True,
349+
dest="doc_cache",
350+
)
351+
exgroup.add_argument(
352+
"--doc-cache",
353+
action="store_true",
354+
help="Enable disk cache for documents loaded over HTTP",
355+
default=True,
356+
dest="doc_cache",
357+
)
358+
343359
exgroup = parser.add_mutually_exclusive_group()
344360
exgroup.add_argument("--verbose", action="store_true", help="Default logging")
345361
exgroup.add_argument(

cwltool/context.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ def __init__(self, kwargs: Optional[Dict[str, Any]] = None) -> None:
7171
self.prov_obj = None # type: Optional[ProvenanceProfile]
7272
self.do_update = None # type: Optional[bool]
7373
self.jobdefaults = None # type: Optional[CommentedMap]
74+
self.doc_cache = True # type: bool
7475

7576
super(LoadingContext, self).__init__(kwargs)
7677

cwltool/load_tool.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,13 @@
6464
ResolverType = Callable[[Loader, Union[str, Dict[str, Any]]], str]
6565

6666

67-
def default_loader(fetcher_constructor=None, enable_dev=False):
68-
# type: (Optional[FetcherConstructorType], bool) -> Loader
67+
def default_loader(fetcher_constructor=None, enable_dev=False, doc_cache=True):
68+
# type: (Optional[FetcherConstructorType], bool, bool) -> Loader
6969
return Loader(
7070
jobloaderctx,
7171
fetcher_constructor=fetcher_constructor,
7272
allow_attachments=lambda r: enable_dev,
73+
doc_cache=doc_cache,
7374
)
7475

7576

@@ -113,7 +114,11 @@ def fetch_document(
113114
else:
114115
loadingContext = loadingContext.copy()
115116
if loadingContext.loader is None:
116-
loadingContext.loader = default_loader(loadingContext.fetcher_constructor)
117+
loadingContext.loader = default_loader(
118+
loadingContext.fetcher_constructor,
119+
enable_dev=loadingContext.enable_dev,
120+
doc_cache=loadingContext.doc_cache,
121+
)
117122

118123
if isinstance(argsworkflow, str):
119124
uri, fileuri = resolve_tool_uri(
@@ -321,6 +326,7 @@ def resolve_and_validate_document(
321326
cache=sch_document_loader.cache,
322327
fetcher_constructor=loadingContext.fetcher_constructor,
323328
skip_schemas=skip_schemas,
329+
doc_cache=loadingContext.doc_cache,
324330
)
325331

326332
if cwlVersion == "v1.0":

cwltool/main.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,9 @@ def setup_loadingContext(
667667
else:
668668
loadingContext = loadingContext.copy()
669669
loadingContext.loader = default_loader(
670-
loadingContext.fetcher_constructor, enable_dev=args.enable_dev
670+
loadingContext.fetcher_constructor,
671+
enable_dev=args.enable_dev,
672+
doc_cache=args.doc_cache,
671673
)
672674
loadingContext.research_obj = runtimeContext.research_obj
673675
loadingContext.disable_js_validation = args.disable_js_validation or (

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
"ruamel.yaml >= 0.12.4, <= 0.16.5",
6262
"rdflib >= 4.2.2, < 4.3.0",
6363
"shellescape >= 3.4.1, < 3.5",
64-
"schema-salad >= 5, < 6",
64+
"schema-salad >= 5.0.20200126033820, < 6",
6565
"mypy-extensions",
6666
"psutil",
6767
"prov == 1.5.1",

tests/test_pack.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ def test_pack():
4747

4848

4949
def test_pack_input_named_name():
50-
loadingContext, workflowobj, uri = fetch_document(get_data("tests/wf/trick_revsort.cwl"))
50+
loadingContext, workflowobj, uri = fetch_document(
51+
get_data("tests/wf/trick_revsort.cwl")
52+
)
5153
loadingContext.do_update = False
5254
loadingContext, uri = resolve_and_validate_document(
5355
loadingContext, workflowobj, uri

0 commit comments

Comments
 (0)