
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "starterkit/Ex08_basf2_analysis_scaled.py"
.. LINE NUMBERS ARE GIVEN BELOW.

.. only:: html

    .. note::
        :class: sphx-glr-download-link-note

        :ref:`Go to the end <sphx_glr_download_starterkit_Ex08_basf2_analysis_scaled.py>`
        to download the full example code.

.. rst-class:: sphx-glr-example-title

.. _sphx_glr_starterkit_Ex08_basf2_analysis_scaled.py:


.. _exercise08_label:

Scaling up your analysis
========================

.. hint::
    This example demonstrates how to locally scale the analysis task from
    the previous example :ref:`exercise07_label`. This example is very similar
    to the basic ``luigi`` wrapper task example in :ref:`exercise03_label`. Additionally, we
    introduce the ``inherits`` method to inherit parameters from another task
    without requiring the task.

.. GENERATED FROM PYTHON SOURCE LINES 14-19

.. code-block:: Python


    import b2luigi
    from Ex07_basf2_analysis import AnalysisTask



.. GENERATED FROM PYTHON SOURCE LINES 20-27

The ``inherits`` decorater works similar to the already known ``requires``
decorator. It will also propagate the parameters of the inherited task to
the inheriting task. The difference is that the inheriting task does not
require the inherited task. It can e.g. be used in tasks that merge the
output of the tasks they require. These merger tasks don't need the
parameter they resolve anymore but should keep the same order of parameters,
therefore simplifying the directory

.. GENERATED FROM PYTHON SOURCE LINES 30-41

.. code-block:: Python

    @b2luigi.inherits(AnalysisTask, without="identifier")
    class AnalysisWrapperTask(b2luigi.WrapperTask):
        n_loops = b2luigi.IntParameter(default=1)

        def requires(self):
            for i in range(self.n_loops):
                yield AnalysisTask(n_events=self.n_events, identifier=f"loop_{i}")


    if __name__ == "__main__":
        b2luigi.process(AnalysisWrapperTask(n_events=10, n_loops=5), workers=5)


.. _sphx_glr_download_starterkit_Ex08_basf2_analysis_scaled.py:

.. only:: html

  .. container:: sphx-glr-footer sphx-glr-footer-example

    .. container:: sphx-glr-download sphx-glr-download-python

      :download:`Download Python source code: Ex08_basf2_analysis_scaled.py <Ex08_basf2_analysis_scaled.py>`

    .. container:: sphx-glr-download sphx-glr-download-zip

      :download:`Download zipped: Ex08_basf2_analysis_scaled.zip <Ex08_basf2_analysis_scaled.zip>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_
