File: split.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 (104 lines) | stat: -rw-r--r-- 2,914 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
.. include:: ../global.inc
.. _decorators.split:
.. index::
    pair: @split; Syntax

.. role:: raw-html(raw)
   :format: html

:raw-html:`<style> .red {color:red} </style>`

.. role:: red



.. seealso::

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

########################################################################
@split ( |input|_, |output|_, [|extras|_,...]  )
########################################################################

.. |input| replace:: `input`
.. _input: `decorators.split.input`_
.. |extras| replace:: `extras`
.. _extras: `decorators.split.extras`_
.. |output| replace:: `output`
.. _output: `decorators.split.output`_

    **Purpose:**
        | Splits a single set of |input|_ into multiple |output|_, where the number of
          |output|_ may not be known beforehand.
        | Only out of date tasks (comparing |input|_ and |output|_ files) will be run

    **Example**::

        @split("big_file", '*.little_files')
        def split_big_to_small(input_file, output_files):
            print "input_file = %s" % input_file
            print "output_file = %s" % output_file

    .

        will produce::

            input_file = big_file
            output_file = *.little_files


    **Parameters:**

.. _decorators.split.input:


    * **input** = *tasks_or_file_names*
       can be a:

       #.  (Nested) list of file name strings (as in the example above).

            | File names containing ``*[]?`` will be expanded as a |glob|_.
            | E.g.:``"a.*" => "a.1", "a.2"``

       #.  Task / list of tasks.

            File names are taken from the output of the specified task(s)


.. _decorators.split.output:

    * **output** = *output*
       Specifies the resulting output file name(s) after string substitution

       Can include glob patterns (e.g. ``"*.txt"``)

       | These are used **only** to check if the task is up to date.
       | Normally you would use either a |glob|_ (e.g. ``*.little_files`` as above) or  a "sentinel file"
         to indicate that the task has completed successfully.
       | You can of course do both:

        ::

            @split("big_file", ["sentinel.file", "*.little_files"])
            def split_big_to_small(input_file, output_files):
                pass


.. _decorators.split.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.



.. warning::

    Deprecated since Ruffus v 2.5

    :red:`@split( input, output, filter =` ``regex(...)``, ``add_inputs(...)`` | ``inputs(...)``, :red:`[|extras|_,...]  )` is a synonym for :ref:`@subdivide <decorators.subdivide>`.