Skip to content

Commit 9463c26

Browse files
author
Peter Amstutz
committed
Make do_update optional to override updating behavior.
Sanity check tool has been updated to expected internal version before executing.
1 parent ae048d5 commit 9463c26

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

cwltool/context.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def __init__(self, kwargs=None):
6464
self.host_provenance = False # type: bool
6565
self.user_provenance = False # type: bool
6666
self.prov_obj = None # type: Optional[ProvenanceProfile]
67-
self.do_update = True # type: bool
67+
self.do_update = None # type: Optional[bool]
6868
self.jobdefaults = None # type: Optional[MutableMapping[Text, Any]]
6969

7070
super(LoadingContext, self).__init__(kwargs)

cwltool/main.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,8 @@ def formatTime(self, record, datefmt=None):
625625
loadingContext.construct_tool_object = getdefault(
626626
loadingContext.construct_tool_object, workflow.default_make_tool)
627627
loadingContext.resolver = getdefault(loadingContext.resolver, tool_resolver)
628-
loadingContext.do_update = not (args.pack or args.print_subgraph)
628+
if loadingContext.do_update is None:
629+
loadingContext.do_update = not (args.pack or args.print_subgraph)
629630

630631
uri, tool_file_uri = resolve_tool_uri(
631632
args.workflow, resolver=loadingContext.resolver,
@@ -654,7 +655,7 @@ def formatTime(self, record, datefmt=None):
654655
= resolve_and_validate_document(loadingContext, workflowobj, uri,
655656
preprocess_only=(args.print_pre or args.pack),
656657
skip_schemas=args.skip_schemas)
657-
658+
658659
if loadingContext.loader is None:
659660
raise Exception("Impossible code path.")
660661
processobj, metadata = loadingContext.loader.resolve_ref(uri)

cwltool/process.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
4646
from .utils import (DEFAULT_TMP_PREFIX, aslist, cmp_like_py2,
4747
copytree_with_merge, onWindows, random_outdir)
4848
from .validate_js import validate_js_expressions
49+
from .update import INTERNAL_VERSION
50+
4951
try:
5052
from os import scandir # type: ignore
5153
except ImportError:
@@ -586,6 +588,10 @@ def __init__(self,
586588
def _init_job(self, joborder, runtime_context):
587589
# type: (Mapping[Text, Text], RuntimeContext) -> Builder
588590

591+
if self.metadata.get("cwlVersion") != INTERNAL_VERSION:
592+
raise WorkflowException("Process object loaded with version '%s', must update to '%s' in order to execute." % (
593+
self.metadata.get("cwlVersion"), INTERNAL_VERSION))
594+
589595
job = cast(Dict[Text, Union[Dict[Text, Any], List[Any], Text, None]],
590596
copy.deepcopy(joborder))
591597

cwltool/update.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ def fix_inputBinding(t):
8989
ALLUPDATES = UPDATES.copy()
9090
ALLUPDATES.update(DEVUPDATES)
9191

92+
INTERNAL_VERSION = u"v1.1.0-dev1"
93+
9294
def identity(doc, loader, baseuri): # pylint: disable=unused-argument
9395
# type: (Any, Loader, Text) -> Tuple[Any, Union[Text, Text]]
9496
"""The default, do-nothing, CWL document upgrade function."""

0 commit comments

Comments
 (0)