Skip to content

Commit

Permalink
Added hooks to the pipeline runners.
Browse files Browse the repository at this point in the history
  • Loading branch information
transientlunatic committed Sep 9, 2020
1 parent 708aad8 commit 3715021
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
21 changes: 21 additions & 0 deletions asimov/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,24 @@ def detect_completion(self):
else:
return False

def before_submit(self):
"""
Define a hook to run before the DAG file is generated and submitted.
Note, this method should take no arguments, and should be over-written in the
specific pipeline implementation if required.
"""
pass

def after_completion(self):
"""
Define a hook to run after the DAG has completed execution successfully.
Note, this method should take no arguments, and should be over-written in the
specific pipeline implementation if required.
"""
pass

def submit_dag(self):
"""
Submit a DAG file to the condor cluster.
Expand All @@ -124,6 +142,9 @@ def submit_dag(self):
This will be raised if the pipeline fails to submit the job.
"""
os.chdir(self.production.rundir)

self.before_submit()

try:
command = ["condor_submit_dag",
os.path.join(self.production.rundir, "multidag.dag")]
Expand Down
17 changes: 16 additions & 1 deletion docs/source/pipelines.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ An interface for any pipeline can be constructed, provided that pipeline can be

The ``asimov.pipeline`` module defines the factory classes for these interfaces, and individual interfaces can be found in the ``asimov.pipelines`` module.


Adding new pipelines
--------------------

Expand All @@ -17,6 +16,22 @@ The most important of these is the ``build_dag`` method, which is used by the as

An example of a complete pipeline interface can be seen in the code for :class:``asimov.pipelines.lalinference.LALinference``.


Pipeline hooks
--------------

It is possible to customise the run process of the asimov pipeline runner using hooks.
By overloading the hook methods (listed below) inherited from the ``asimov.pipeline.Pipeline`` class additional operations can
be conducted during the processing workflow.
Hooks should take no arguments.

Implemented hooks are:

::

before_submit() --- Executed immediately before the DAG file for a pipeline is generated.
after_completion() --- Executed once execution has successfully completed.

Supported Pipelines
-------------------

Expand Down

0 comments on commit 3715021

Please sign in to comment.