/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. Code for Step 2: Passing parameters to the pipeline
  5. ###################################################################
  6. * :ref:`Up <Simple_Tutorial>`
  7. * :ref:`Back <Simple_Tutorial_2nd_step>`
  8. * :ref:`@files syntax <decorators.files>` in detail
  9. ************************************
  10. Code
  11. ************************************
  12. ::
  13. from ruffus import *
  14. import time
  15. #---------------------------------------------------------------
  16. #
  17. # first task
  18. #
  19. task1_param = [
  20. [ None, 'job1.stage1'], # 1st job
  21. [ None, 'job2.stage1'], # 2nd job
  22. ]
  23. @files(task1_param)
  24. def first_task(no_input_file, output_file):
  25. open(output_file, "w")
  26. #---------------------------------------------------------------
  27. #
  28. # second task
  29. #
  30. task2_param = [
  31. [ 'job1.stage1', "job1.stage2", " 1st_job"], # 1st job
  32. [ 'job2.stage1', "job2.stage2", " 2nd_job"], # 2nd job
  33. ]
  34. @follows(first_task)
  35. @files(task2_param)
  36. def second_task(input_file, output_file, extra_parameter):
  37. open(output_file, "w")
  38. print extra_parameter
  39. #---------------------------------------------------------------
  40. #
  41. # Run
  42. #
  43. pipeline_run([second_task], multiprocess = 5)
  44. ************************************
  45. Resulting Output
  46. ************************************
  47. ::
  48. Start Task = first_task
  49. Job = [None -> job1.stage1] completed
  50. Job = [None -> job2.stage1] completed
  51. Completed Task = first_task
  52. Start Task = second_task
  53. 1st_job
  54. Job = [job1.stage1 -> job1.stage2, 1st_job] completed
  55. 2nd_job
  56. Job = [job2.stage1 -> job2.stage2, 2nd_job] completed
  57. Completed Task = second_task