Skip to content

Commit 984ad48

Browse files
authored
Add make_workflow_step which can be overridden by subclasses. (#968)
Also update extension points section in README
1 parent 0932350 commit 984ad48

File tree

2 files changed

+64
-31
lines changed

2 files changed

+64
-31
lines changed

README.rst

Lines changed: 55 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -609,33 +609,18 @@ Technical outline of how cwltool works internally, for maintainers.
609609
Extension points
610610
----------------
611611

612-
The following functions can be provided to main(), to load_tool(), or to the
613-
executor to override or augment the listed behaviors.
612+
The following functions can be passed to main() to override or augment
613+
the listed behaviors.
614614

615615
executor
616616
::
617617

618-
executor(tool, job_order_object, **kwargs)
619-
(Process, Dict[Text, Any], **Any) -> Tuple[Dict[Text, Any], Text]
618+
executor(tool, job_order_object, runtimeContext, logger)
619+
(Process, Dict[Text, Any], RuntimeContext) -> Tuple[Dict[Text, Any], Text]
620620

621-
A toplevel workflow execution loop, should synchronously execute a process
622-
object and return an output object.
623-
624-
construct_tool_object
625-
::
626-
627-
construct_tool_object(toolpath_object, **kwargs)
628-
(Dict[Text, Any], **Any) -> Process
629-
630-
Hook to construct a Process object (eg CommandLineTool) object from a document.
631-
632-
selectResources
633-
::
634-
635-
selectResources(request)
636-
(Dict[Text, int]) -> Dict[Text, int]
637-
638-
Take a resource request and turn it into a concrete resource assignment.
621+
An implementation of the toplevel workflow execution loop, should
622+
synchronously run a process object to completion and return the
623+
output object.
639624

640625
versionfunc
641626
::
@@ -645,13 +630,16 @@ versionfunc
645630

646631
Return version string.
647632

648-
make_fs_access
633+
logger_handler
649634
::
650635

651-
make_fs_access(basedir)
652-
(Text) -> StdFsAccess
636+
logger_handler
637+
logging.Handler
653638

654-
Return a file system access object.
639+
Handler object for logging.
640+
641+
The following functions can be set in LoadingContext to override or
642+
augment the listed behaviors.
655643

656644
fetcher_constructor
657645
::
@@ -669,10 +657,47 @@ resolver
669657

670658
Resolve a relative document identifier to an absolute one which can be fetched.
671659

672-
logger_handler
660+
The following functions can be set in RuntimeContext to override or
661+
augment the listed behaviors.
662+
663+
construct_tool_object
673664
::
674665

675-
logger_handler
676-
logging.Handler
666+
construct_tool_object(toolpath_object, loadingContext)
667+
(MutableMapping[Text, Any], LoadingContext) -> Process
677668

678-
Handler object for logging.
669+
Hook to construct a Process object (eg CommandLineTool) object from a document.
670+
671+
select_resources
672+
::
673+
674+
selectResources(request)
675+
(Dict[str, int], RuntimeContext) -> Dict[Text, int]
676+
677+
Take a resource request and turn it into a concrete resource assignment.
678+
679+
make_fs_access
680+
::
681+
682+
make_fs_access(basedir)
683+
(Text) -> StdFsAccess
684+
685+
Return a file system access object.
686+
687+
In addition, when providing custom subclasses of Process objects, you can override the following methods:
688+
689+
CommandLineTool.make_job_runner
690+
::
691+
692+
make_job_runner(RuntimeContext)
693+
(RuntimeContext) -> Type[JobBase]
694+
695+
Create and return a job runner object (this implements concrete execution of a command line tool).
696+
697+
Workflow.make_workflow_step
698+
::
699+
700+
make_workflow_step(toolpath_object, pos, loadingContext, parentworkflowProv)
701+
(Dict[Text, Any], int, LoadingContext, Optional[CreateProvProfile]) -> WorkflowStep
702+
703+
Create and return a workflow step object.

cwltool/workflow.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ def __init__(self,
527527
validation_errors = []
528528
for index, step in enumerate(self.tool.get("steps", [])):
529529
try:
530-
self.steps.append(WorkflowStep(step, index, loadingContext,
530+
self.steps.append(self.make_workflow_step(step, index, loadingContext,
531531
loadingContext.prov_obj))
532532
except validate.ValidationException as vexc:
533533
if _logger.isEnabledFor(logging.DEBUG):
@@ -555,6 +555,14 @@ def __init__(self,
555555
if getdefault(loadingContext.do_validate, True):
556556
static_checker(workflow_inputs, workflow_outputs, step_inputs, step_outputs, param_to_step)
557557

558+
def make_workflow_step(self,
559+
toolpath_object, # type: Dict[Text, Any]
560+
pos, # type: int
561+
loadingContext, # type: LoadingContext
562+
parentworkflowProv=None # type: Optional[CreateProvProfile]
563+
):
564+
# (...) -> WorkflowStep
565+
return WorkflowStep(toolpath_object, pos, loadingContext, parentworkflowProv)
558566

559567
def job(self,
560568
job_order, # type: MutableMapping[Text, Text]

0 commit comments

Comments
 (0)