.. include:: ../global.inc .. role:: raw-html(raw) :format: html :raw-html:`` :raw-html:`` .. role:: highlight-red .. role:: highlight-blue .. :highlight-red:`Test.` .. _new_syntax: ################################################################################ New Object Orientated Syntax ################################################################################ Ruffus Pipelines can now be created and manipulated directly using :highlight-red:`Pipeline` and :highlight-red:`Task` objects instead of via decorators. .. note:: You may want to go through the :ref:`worked_example ` first. ============================================================================== Syntax ============================================================================== This traditional Ruffus code: .. <4->2->1) or three tasks) to produce the output. But if we are given 10 data files, we now find that we needed to have four tasks for four rounds of merging (10->5->3->2->1). There was previously no easy way to arrange different Ruffus topologies in response to the data. Now we can add as many extra merging tasks to our pipeline (all sharing the same underlying python function) as needed. ============================================================================== Compatability ============================================================================== * The changes are fully backwards compatibile. All valid Ruffus code continues to work * Decorators and ``Pipeline`` objects can be used interchangeably: Decorated functions are automatically part of a default constructed ``Pipeline`` named ``"main"``. .. code-block:: python main_pipeline = Pipeline.pipelines["main"] .. In the following example, a pipeline using the Ruffus with classes syntax :highlight-red:`(1)` and :highlight-red:`(3)` has a traditionally decorated task function in the middle :highlight-red:`(2)`. .. <`. .. toctree:: :maxdepth: 2 :hidden: new_syntax_worked_example.rst new_syntax_worked_example_code.rst