Commit c0f3d362 authored by Maude Le Jeune's avatar Maude Le Jeune
Browse files

Merge branch 'master' of gitorious.org:pipelet/pipelet

parents 39736832 7e4fc243
# -*- coding: utf-8 -*-
#
# Pipelet documentation build configuration file, created by
# sphinx-quickstart on Mon Sep 23 11:54:20 2013.
#
# This file is execfile()d with the current directory set to its containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.
import sys, os
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#sys.path.insert(0, os.path.abspath('.'))
# -- General configuration -----------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
#needs_sphinx = '1.0'
# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
#autoclass_content = 'both'
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.todo', 'sphinx.ext.coverage', 'sphinx.ext.pngmath', 'sphinx.ext.viewcode']
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# The suffix of source filenames.
source_suffix = '.rst'
# The encoding of source files.
#source_encoding = 'utf-8-sig'
# The master toctree document.
master_doc = 'index'
# General information about the project.
project = u'Pipelet'
copyright = u'2013, M. Betoule, M. Le Jeune'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '1.1'
# The full version, including alpha/beta/rc tags.
release = '1.1'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#language = None
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
#today = ''
# Else, today_fmt is used as the format for a strftime call.
#today_fmt = '%B %d, %Y'
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = ['_build']
# The reST default role (used for this markup: `text`) to use for all documents.
#default_role = None
# If true, '()' will be appended to :func: etc. cross-reference text.
#add_function_parentheses = True
# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
#add_module_names = True
# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
#show_authors = False
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
# A list of ignored prefixes for module index sorting.
#modindex_common_prefix = []
# -- Options for HTML output ---------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = 'default'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#html_theme_options = {}
# Add any paths that contain custom themes here, relative to this directory.
#html_theme_path = []
# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
#html_title = None
# A shorter title for the navigation bar. Default is the same as html_title.
#html_short_title = None
# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
#html_logo = None
# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
#html_favicon = None
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
#html_last_updated_fmt = '%b %d, %Y'
# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
#html_use_smartypants = True
# Custom sidebar templates, maps document names to template names.
#html_sidebars = {}
html_sidebars = {
'**': ['globaltoc.html', 'sourcelink.html', 'searchbox.html'],
'using/windows': ['windowssidebar.html', 'searchbox.html'],
}
# Additional templates that should be rendered to pages, maps page names to
# template names.
#html_additional_pages = {}
# If false, no module index is generated.
#html_domain_indices = True
# If false, no index is generated.
#html_use_index = True
# If true, the index is split into individual pages for each letter.
#html_split_index = False
# If true, links to the reST sources are added to the pages.
#html_show_sourcelink = True
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
#html_show_sphinx = True
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
#html_show_copyright = True
# If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it. The value of this option must be the
# base URL from which the finished HTML is served.
#html_use_opensearch = ''
# This is the file name suffix for HTML files (e.g. ".xhtml").
#html_file_suffix = None
# Output file base name for HTML help builder.
htmlhelp_basename = 'Pipeletdoc'
# -- Options for LaTeX output --------------------------------------------------
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#'preamble': '',
}
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
('index', 'Pipelet.tex', u'Pipelet Documentation',
u'M. Betoule, M. Le Jeune', 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
# the title page.
#latex_logo = None
# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
#latex_use_parts = False
# If true, show page references after internal links.
#latex_show_pagerefs = False
# If true, show URL addresses after external links.
#latex_show_urls = False
# Documents to append as an appendix to all manuals.
#latex_appendices = []
# If false, no module index is generated.
#latex_domain_indices = True
# -- Options for manual page output --------------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'pipelet', u'Pipelet Documentation',
[u'M. Betoule, M. Le Jeune'], 1)
]
# If true, show URL addresses after external links.
#man_show_urls = False
# -- Options for Texinfo output ------------------------------------------------
# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
('index', 'Pipelet', u'Pipelet Documentation',
u'M. Betoule, M. Le Jeune', 'Pipelet', 'One line description of project.',
'Miscellaneous'),
]
# Documents to append as an appendix to all manuals.
#texinfo_appendices = []
# If false, no module index is generated.
#texinfo_domain_indices = True
# How to display URL addresses: 'footnote', 'no', or 'inline'.
#texinfo_show_urls = 'footnote'
:mod:`environment` Module
-------------------
.. py:module:: environment
.. automodule:: pipelet.environment
:members: Environment
:undoc-members:
:show-inheritance:
.. Pipelet documentation master file, created by
sphinx-quickstart on Mon Sep 23 11:54:20 2013.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to Pipelet's documentation!
===================================
.. automodule:: pipelet
:members:
:undoc-members:
:private-members:
:special-members:
Pipelet is a free framework to handle the creation, execution and
browsing of scientific data processing pipelines. It provides:
+ easy chaining of interdependent elementary tasks,
+ web access to data products,
+ branch handling,
+ automated distribution of computational tasks.
Both engine and web interface are written in Python.
.. As Pipelet is all about chaining processing written in Python or using Python as a glue language, prior knowledge of this language is required.
Table of contents
=================
.. toctree::
:maxdepth: 2
Tutorial <tutorial>
Advanced usage <userguide>
API <pipelet>
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
:mod:`launchers` Module
-------------------
.. automodule:: pipelet.launchers
:members:
:undoc-members:
:show-inheritance:
pipelet
=======
.. toctree::
:maxdepth: 4
pipelet
:mod:`directive` Module
-------------------
.. automodule:: pipelet.directive
:members:
:undoc-members:
:show-inheritance:
.. automodule:: pipelet.multiplex
:members:
:undoc-members:
:show-inheritance:
pipelet Package
===============
:mod:`pipelet` Package
----------------------
.. automodule:: pipelet
:members:
:undoc-members:
:show-inheritance:
.. toctree::
:maxdepth: 2
environment module <environment>
repository module <repository>
pipeline module <pipeline>
directive module <multiplex>
launchers module <launchers>
scheduler module <scheduler>
worker module <worker>
task module <task>
tracker module <tracker>
utils module <utils>
web module <web>
treeview module <treeview>
:mod:`pipeline` Module
-------------------
.. automodule:: pipelet.pipeline
:members:
:undoc-members:
:show-inheritance:
:mod:`repository` Module
-------------------
.. automodule:: pipelet.repository
:members: Repository, LocalRepository
:undoc-members:
:show-inheritance:
:mod:`scheduler` Module
-------------------
.. automodule:: pipelet.scheduler
:members:
:undoc-members:
:show-inheritance:
:mod:`task` Module
-------------------
.. automodule:: pipelet.task
:members:
:undoc-members:
:show-inheritance:
:mod:`tracker` Module
-------------------
.. automodule:: pipelet.tracker
:members:
:undoc-members:
:show-inheritance:
:mod:`treeview` Module
-------------------
.. automodule:: pipelet.treeview
:members:
:undoc-members:
:show-inheritance:
This diff is collapsed.
Advanced usage
--------------
This section describe more complicated (and useful) features and
requires good familiarity with the concept introduced in the previous section.
Multiplex directive
~~~~~~~~~~~~~~~~~~~
The default behavior can be altered by specifying a ``#multiplex``
directive in the commentary of the segment code. If several multiplex
directives are present in the segment code the last one is retained.
The multiplex directive can be one of:
+ ``#multiplex cross_prod`` : default behavior, return the Cartesian product.
+ ``#multiplex union`` : make the union of the inputs
Moreover the ``#multiplex cross_prod`` directive admits filtering and
grouping by class similarly to SQL requests::
#multiplex cross_prod where "condition" group_by "class_function"
``condition`` and ``class_function`` are python code evaluated for each element
of the product set.
The argument of ``where`` is a condition. The element will be part of the
input set only if it evaluates to ``True``.
The ``group_by`` directive groups elements into class according to the
result of the evaluation of the given class function. The input set
contains all the resulting class. For example, if the function is a
constant, the input set will contain only one element: the class
containing all elements.
During the evaluation, the values of the tuple elements are accessible
as variable wearing the name of the corresponding parents.
Given the Cartesian product set::
[('Lancelot','the Brave'), ('Lancelot','the Pure'), ('Galahad','the Brave'), ('Galahad','the Pure')]
one can use ::
#multiplex cross_prod where "quality=='the Brave'"
to get 2 instances of the following segment (``melt``) running on ``('Lancelot','the Brave'), ('Galahad','the Brave')``
or::
#multiplex cross_prod group_by "knights"
to get 2 instances of the ``melt`` segment running on ``('Lancelot'), ('Galahad')``
or::
#multiplex cross_prod group_by "0"
to get 1 instance of the ``melt`` segment running on: (0)
Note that to make use of ``group_by``, elements of the output set have to be
hashable.
Another caution on the use of group: segment input data type is no
longer a dictionary in those cases as the original tuple is
lost and replaced by the result of the class function.
See section :ref:`The segment environment<my-reference-label>` section for more details.
Depend directive
~~~~~~~~~~~~~~~~
As explained in the introduction section, Pipelet offers the
possibility to spare CPU time by saving intermediate products on disk.
We call intermediate products the input/output data files of the
different segments.
Each segment repository is identified by a unique key which depends
on:
- the segment processing code and parameters (segment and hook
scripts)
- the input data (identified from the key of the parent segments)
Every change made on a segment (new parameter or new parent) will then
give a different key, and tell the Pipelet engine to compute a new
segment instance.
It is possible to add some external dependencies to the key
computation using the depend directive::
#depend file1 file2
At the very beginning of the pipeline execution, all dependencies will
be stored, to prevent any change (code edition) between the key
computation and actual processing.
Note that this mechanism works only for segment and hook
scripts. External dependencies are also read as the beginning of the
pipeline execution, but only used for the key computation.
Database reconstruction
~~~~~~~~~~~~~~~~~~~~~~~
In case of unfortunate lost of the pipeline sql data base, it is
possible to reconstruct it from the disk ::
import pipelet
pipelet.utils.rebuild_db_from_disk (prefix, sqlfile)
All information will be retrieve, but with new identifiers.
The hooking system
~~~~~~~~~~~~~~~~~~
As described in the :ref:`The segment environment<my-reference-label>` section, Pipelet supports
an hooking system which allows the use of generic processing code, and
code sectioning.
Let's consider a set of instructions that have to be systematically
applied at the end of a segment (post processing), one can put those
instruction in the separate script file named for example
``segname_postproc.py`` and calls the hook function::
hook('postproc', globals())
A specific dictionary can be passed to the hook script to avoid
confusion.
The hook scripts are included into the hash key computation.
Segment script repository
~~~~~~~~~~~~~~~~~~~~~~~~~
Local repository
****************
By default, segment scripts are read from a local directory, specified
at the pipeline initialization with the parameter named ``code_dir``::
from pipelet.pipeline import Pipeline
P = Pipeline(pipedot, code_dir="./", prefix="./")
The segment script contents are immediatly stored, to prevent from
any modification between the pipeline start time and the actual execution
of each segment.
It is generally a good idea to make this directory controlled by an
RCS, to ease the reproducibility of the pipeline (even if the pipelet
engine makes a copy of the segment script in the segment output
directory).
If using Git, the revision number will be stored at the beginning of
the copy of the segment script.
Writing custom environments
~~~~~~~~~~~~~~~~~~~~~~~~~~~
The Pipelet software provides a set of default utilities available
from the segment environment. It is possible to extend this default
environment or even re-write a completely new one.
Extending the default environment
*********************************
The different environment utilities are actually methods of the class
Environment. It is possible to add new functionalities by using the
python heritage mechanism:
File : ``myenvironment.py``::
from pipelet.environment import *
class MyEnvironment(Environment):
def my_function (self):
""" My function do nothing
"""
return
The Pipelet engine objects (segments, tasks, pipeline) are available
from the worker attribut ``self._worker``. See the :ref:`The pipelet actors<act-sec>` section for more details about the Pipelet machinery.
Writing new environment
***********************
In order to start with a completely new environment, extend the base
environment:
File : ``myenvironment.py``::
from pipelet.environment import *
class MyEnvironment(EnvironmentBase):
def my_get_data_fn (self, x):
""" New name for get_data_fn
"""
return self._get_data_fn(x)
def _close(self, glo):
""" Post processing code
"""
return glo['seg_output']
From the base environment, the basic functionalities for getting file
names and executing hook scripts are still available through:
- ``self._get_data_fn``
- ``self._hook``
The segment input argument is also stored in ``self._seg_input``
The segment output argument has to be returned by the ``_close(self, glo)``
method.
The pipelet engine objects (segments, tasks, pipeline) are available
from the worker attribut ``self._worker``. See doxygen documentation for
more details about the Pipelet machinery.
Loading another environment
***************************
To load another environment, set the pipeline environment attribute
accordingly. ::
Pipeline(pipedot, codedir=, prefix=, env=MyEnvironment)