PageRenderTime 22ms CodeModel.GetById 13ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/doc/tutorials/simple_tutorial/step2_files_code.rst

https://code.google.com/p/ruffus/
ReStructuredText | 69 lines | 57 code | 12 blank | 0 comment | 0 complexity | 535fd28ca0126f92fa897112f49ec7bb MD5 | raw file
 1.. include:: ../../global.inc
 2.. _Simple_Tutorial_2nd_step_code:
 3
 4###################################################################
 5Code for Step 2: Passing parameters to the pipeline
 6###################################################################
 7* :ref:`Up <Simple_Tutorial>` 
 8* :ref:`Back <Simple_Tutorial_2nd_step>` 
 9* :ref:`@files syntax <decorators.files>` in detail
10
11************************************
12Code
13************************************
14    ::
15        
16        from ruffus import *
17        import time
18        
19        #---------------------------------------------------------------
20        #
21        #   first task
22        #
23        task1_param = [
24                            [ None, 'job1.stage1'], # 1st job
25                            [ None, 'job2.stage1'], # 2nd job
26                      ]
27                                            
28        @files(task1_param)
29        def first_task(no_input_file, output_file):
30            open(output_file, "w")
31
32
33        #---------------------------------------------------------------
34        #
35        #   second task
36        #
37        task2_param = [
38                            [ 'job1.stage1', "job1.stage2", "    1st_job"], # 1st job
39                            [ 'job2.stage1', "job2.stage2", "    2nd_job"], # 2nd job
40                      ]
41        
42        @follows(first_task)
43        @files(task2_param)
44        def second_task(input_file, output_file, extra_parameter):
45            open(output_file, "w")
46            print extra_parameter
47        
48        #---------------------------------------------------------------
49        #
50        #       Run
51        #
52        pipeline_run([second_task], multiprocess = 5)
53       
54
55************************************
56Resulting Output
57************************************
58    ::
59        
60        Start Task = first_task
61            Job = [None -> job1.stage1] completed
62            Job = [None -> job2.stage1] completed
63        Completed Task = first_task
64        Start Task = second_task
65            1st_job
66            Job = [job1.stage1 -> job1.stage2,     1st_job] completed
67            2nd_job
68            Job = [job2.stage1 -> job2.stage2,     2nd_job] completed
69        Completed Task = second_task