File: posttask.rst

package info (click to toggle)
python-ruffus 2.6.3%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 20,828 kB
  • ctags: 2,843
  • sloc: python: 15,745; makefile: 180; sh: 14
file content (71 lines) | stat: -rw-r--r-- 2,199 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
.. include:: ../global.inc
.. _decorators.posttask:
.. index::
    pair: @posttask; Syntax

.. seealso::

    * :ref:`@posttask <new_manual.posttask>` in the **Ruffus** Manual
    * :ref:`Decorators <decorators>` for more decorators

.. |function| replace:: `function`
.. _function: `decorators.posttask.function`_
.. |file_name| replace:: `file_name`
.. _file_name: `decorators.posttask.file_name`_

########################
@posttask
########################

*****************************************************************************************************************************************
*@posttask* (|function|_ | :ref:`touch_file<decorators.touch_file>`\ *(*\ |file_name|_\ *)*\)
*****************************************************************************************************************************************
    **Purpose:**
        Calls functions to signal the completion of each task

    **Example**::

        from ruffus import *

        def task_finished():
            print "hooray"

        @posttask(task_finished)
        @files(None, "a.1")
        def create_if_necessary(input_file, output_file):
            open(output_file, "w")

        pipeline_run([create_if_necessary])

    **Parameters:**

.. _decorators.posttask.function:

    * *function*:
        ``function()`` will be called when the ruffus passes through a task.

        This may happen even if all of the jobs are up-to-date:
        when a upstream task is out-of-date, and the execution passes through
        this point in the pipeline

.. _decorators.posttask.file_name:

    * *file_name*
        Files to be ``touch``\ -ed after the task is executed.

        This will change the date/time stamp of the ``file_name`` to the current date/time.
        If the file does not exist, an empty file will be created.

        Requires to be wrapped in a :ref:`touch_file<decorators.touch_file>` indicator object::

            from ruffus import *

            @posttask(touch_file("task_completed.flag"))
            @files(None, "a.1")
            def create_if_necessary(input_file, output_file):
                open(output_file, "w")

            pipeline_run([create_if_necessary])