File: originate.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 (81 lines) | stat: -rw-r--r-- 2,388 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
72
73
74
75
76
77
78
79
80
81
.. include:: ../global.inc
.. _decorators.originate:
.. index::
    pair: @originate; Syntax

.. seealso::

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

################################################
*@originate* ( |output|_, [|extras|_,...] )
################################################

.. |output| replace:: `output`
.. _output: `decorators.originate.output`_
.. |extras| replace:: `extras`
.. _extras: `decorators.originate.extras`_


    **Purpose:**
        * Creates (originates) a set of starting file without dependencies from scratch  (*ex nihilo*!)
        * Only called to create files which do not exist.
        * Invoked onces (a job created) per item in the |output|_ list.

        .. note::

            The first argument for the task function is the |output|_. There is by definition no
            *input* for ``@originate``

    **Example**:

        .. code-block:: python

            from ruffus import *
            @originate(["a", "b", "c", "d"], "extra")
            def test(output_file, extra):
                open(output_file, "w")

            pipeline_run()

        .. code-block:: pycon
            :emphasize-lines: 8,11

            >>> pipeline_run()
                Job  = [None -> a, extra] completed
                Job  = [None -> b, extra] completed
                Job  = [None -> c, extra] completed
                Job  = [None -> d, extra] completed
            Completed Task = test

            >>> # all files exist: nothing to do
            >>> pipeline_run()

            >>> # delete 'a' so that it is missing
            >>> import os
            >>> os.unlink("a")

            >>> pipeline_run()
                Job  = [None -> a, extra] completed
            Completed Task = test

    **Parameters:**


.. _decorators.originate.output:

    * **output** = *output*
       * Can be a single file name or a list of files
       * Each item in the list is treated as the |output|_ of a separate job


.. _decorators.originate.extras:

    * **extras** = *extras*
       Any extra parameters are passed verbatim to the task function

       If you are using named parameters, these can be passed as a list, i.e. ``extras= [...]``

       Any extra parameters are consumed by the task function and not forwarded further down the pipeline.