芹菜的声明式工作流。
capillar的Python项目详细描述
…亮点:python
…currentmodule::毛细血管
==
:状态:alpha(欢迎API反馈,API可能破坏兼容性)
:生成日期:今天
:版本:发布日期:
:许可证:BSD 3条款
:作者:Domen Ko_ar和Aaron McMillin
。topic::introduction
:mod:`毛细血管`是一个小型集成包,用于
:mod:`celeri`分布式任务队列,目的是在声明性manne中设计
`workflows(canvas)<;http://celeri.readthedocs.org/en/latest/userguide/canvas.html>;`\br/>r<;http://stackoverflow.com/questions/1784664/>;`
使用python decorators。
1。扫描定义的python包中的所有芹菜任务
2。基于传递给:func:`@pipeline` decorators的元数据执行任务
:mod:`毛细血管`使用:
-:mod:`venusian`发现芹菜任务使用延迟的decorators
-:mod:`networkx`处理图形操作以跟踪工作流中的任务_简单示例:
dule包含管道的步骤。步骤用`@pipeline``decorator标记,decorator有可选参数
,表示此步骤必须在其他步骤之后执行,或者
该步骤有特定的标记,允许任务组一起执行。
代码::python
@pipeline()
def foo(芹菜任务):
返回"简单任务流"
@pipeline(after='foo')
def bar(芹菜任务,l):
return l.upper()
"myapp.py"模块然后创建一个:c类:`pipelineconfigurator`
将组装声明步骤的实例:
…代码::python
…代码::bash
$celeri worker-a myapp-d
,并在python shell中执行管道:
……代码::python
>;>;来自myapp import pc
>;>;asyncResult=pc.run()
>;>;asyncResult.get()
simple task flow
*此示例将作为基础在整个用户指南中使用。*
。注意:
此示例假设redis代理正在使用默认设置运行,但任何
`芹菜代理<;http://celeri.readthedocs.org/en/latest/getting started/brokers/>;` `
`都可以。
` backend``仅用于使用`.get()`,i检索结果t是
否则不需要的。
核心概念:处理输入和输出参数
-----------------------------
芹菜使用名为"partials"的概念<;http://celeri.readthedocs.org/en/latest/userguide/canvas.html"partials">;`
(有时也被称为"currying"http s://en.wikipedia.org/wiki/currying>;````创建函数'签名<;http://celeri.readthedocs.org/en/latest/userguide/canvas.html ``签名>;``执行任务。从任务"foo"返回的值将传递到任务"bar"。
如
:ref:`extra parameters`.
core concept:标记管道默认情况下:meth:`pipelineconfigurator.run`将按拓扑顺序执行所有不带标记的扫描任务。
如果将"tags=['foobar']``传递给:func:`@pipeline`,则当将"taged=['foobar']``传递给:meth:`pipelineconfigurator.run`.
有关如何减少样板文件的信息,请参见:ref:`predefined\u defaults`,并按标记对管道进行分组。
ng管道
---------
如果某个步骤需要停止当前管道(意味着管道中不再处理任何其他任务),只需升高:exc:`毛细血管。中止管道`
管道任务中的任何位置。
。_额外参数:
将额外参数传递给特定任务
----------
某些:func:`@pipeline'元素可能需要额外的参数,这些参数仅在调用:meth:`pipelineconfigurator.run`时已知。
代码::python
>;@pipeline(
…必需的_kwarg_names=['param'],
…)
…def foobar(芹菜任务,参数=无):
…打印参数
…返回"simple task flow"
调用:meth:`pipelineconfigurator.run`时,它需要在
`Required Kwargs`内部传递'param',否则:exc:`missingargument`将被抛出。
----
最典型的两个:func:`@pipeline`修饰符有用的用例是当
您希望为两个不同的管道重用一个函数,每个管道都有不同的标记。
代码::python
@pipeline(
after=['first','second',
tags=['some_pipeline',
)
@pipeline(
after=['third',
tags=['other_pipeline',
)
def foobar(芹菜任务):
return'simple task flow'
执行"configurepipeline.run(tagged_as=['some_pipeline'])`
将在完成"第一个"和"第二个"任务后作为任务运行"foobar"函数。
但是执行"configurepipeline.run(tagged_as=['other_pipeline'])`
将在"第三个"任务wa之后运行"foobar"函数完成。
…注意:
特德。_预定义的默认值:
基于预定义的默认值创建管道
——:func:`make_pipeline_from_defaults`允许您为管道创建自定义的
预定义默认值。此示例生成一个"foobar_pipeline"`
decorator,它将对每个步骤应用相同的标记:
…代码::python
>;>from毛细管导入make_pipeline_from_defaults
>;>foobar_pipeline=make_pipeline_from_defaults(
>;>tags=["foobar"]
>;)
eline`而所有的
定义都将使用'foobar'作为标记。
…注意:
/>:方法:`configurepipeline.run`
…代码::python
>;>pc.prettyprint(args=[],kwargs={})
task s.foo()tasks.bar()
代码::python
>;>来自毛细血管导入all,pipeline
>;@pipeline(
…毕竟,
…)
…最后定义(芹菜任务,obj):
…打印('全部完成!')
…返回对象
…注意:
概述内部发生的事情:meth:`~pipelineconfigurator.run()`:
-任务树是使用依赖项信息生成的
-芹菜签名是创建的
-任务树被简化为一个"链"<;http://celeri.readthedocs.org/en/latest/userguide/canvas.html chains>;`
使用to逻辑排序
-使用以下方法执行任务:meth:`celeriy.app.task.apply戥async`
…注意:
当前任务树被简化为任务的线性链表,但是未来可以实现不同的"runner"。
unit testing
----
直到调用:meth:`pipelineconfigurator.scan()'。如果函数代码不依赖于"芹菜任务"的第一个参数,只需传递"none"作为值即可。
代码::python
class pipelinetestcase(unittest.testcase):
self.assertequals(bar(none,"test"),"test")
self.assertequals(foo(none),"simple task flow")
/>===
要运行测试,请安装"py.test"并运行它:
…代码::bash
$py.test tests/
>
要考虑的功能
----
-使用大量带有作为参数传递的大对象的任务可能会占用大量存储空间。如果芹菜允许的话,另一种选择是动态生成签名。自动模块::毛细管
:成员:
:排除成员:pipelineconfigurator
…AutoClass::毛细管。管道配置程序
:成员:运行、预打印、扫描
…currentmodule::毛细血管
==
:状态:alpha(欢迎API反馈,API可能破坏兼容性)
:生成日期:今天
:版本:发布日期:
:许可证:BSD 3条款
:作者:Domen Ko_ar和Aaron McMillin
。topic::introduction
:mod:`毛细血管`是一个小型集成包,用于
:mod:`celeri`分布式任务队列,目的是在声明性manne中设计
`workflows(canvas)<;http://celeri.readthedocs.org/en/latest/userguide/canvas.html>;`\br/>r<;http://stackoverflow.com/questions/1784664/>;`
使用python decorators。
1。扫描定义的python包中的所有芹菜任务
2。基于传递给:func:`@pipeline` decorators的元数据执行任务
:mod:`毛细血管`使用:
-:mod:`venusian`发现芹菜任务使用延迟的decorators
-:mod:`networkx`处理图形操作以跟踪工作流中的任务_简单示例:
dule包含管道的步骤。步骤用`@pipeline``decorator标记,decorator有可选参数
,表示此步骤必须在其他步骤之后执行,或者
该步骤有特定的标记,允许任务组一起执行。
代码::python
@pipeline()
def foo(芹菜任务):
返回"简单任务流"
@pipeline(after='foo')
def bar(芹菜任务,l):
return l.upper()
"myapp.py"模块然后创建一个:c类:`pipelineconfigurator`
将组装声明步骤的实例:
…代码::python
…代码::bash
$celeri worker-a myapp-d
,并在python shell中执行管道:
……代码::python
>;>;来自myapp import pc
>;>;asyncResult=pc.run()
>;>;asyncResult.get()
simple task flow
*此示例将作为基础在整个用户指南中使用。*
。注意:
此示例假设redis代理正在使用默认设置运行,但任何
`芹菜代理<;http://celeri.readthedocs.org/en/latest/getting started/brokers/>;` `
`都可以。
` backend``仅用于使用`.get()`,i检索结果t是
否则不需要的。
核心概念:处理输入和输出参数
-----------------------------
芹菜使用名为"partials"的概念<;http://celeri.readthedocs.org/en/latest/userguide/canvas.html"partials">;`
(有时也被称为"currying"http s://en.wikipedia.org/wiki/currying>;````创建函数'签名<;http://celeri.readthedocs.org/en/latest/userguide/canvas.html ``签名>;``执行任务。从任务"foo"返回的值将传递到任务"bar"。
如
:ref:`extra parameters`.
core concept:标记管道默认情况下:meth:`pipelineconfigurator.run`将按拓扑顺序执行所有不带标记的扫描任务。
如果将"tags=['foobar']``传递给:func:`@pipeline`,则当将"taged=['foobar']``传递给:meth:`pipelineconfigurator.run`.
有关如何减少样板文件的信息,请参见:ref:`predefined\u defaults`,并按标记对管道进行分组。
ng管道
---------
如果某个步骤需要停止当前管道(意味着管道中不再处理任何其他任务),只需升高:exc:`毛细血管。中止管道`
管道任务中的任何位置。
。_额外参数:
将额外参数传递给特定任务
----------
某些:func:`@pipeline'元素可能需要额外的参数,这些参数仅在调用:meth:`pipelineconfigurator.run`时已知。
代码::python
>;@pipeline(
…必需的_kwarg_names=['param'],
…)
…def foobar(芹菜任务,参数=无):
…打印参数
…返回"simple task flow"
调用:meth:`pipelineconfigurator.run`时,它需要在
`Required Kwargs`内部传递'param',否则:exc:`missingargument`将被抛出。
----
最典型的两个:func:`@pipeline`修饰符有用的用例是当
您希望为两个不同的管道重用一个函数,每个管道都有不同的标记。
代码::python
@pipeline(
after=['first','second',
tags=['some_pipeline',
)
@pipeline(
after=['third',
tags=['other_pipeline',
)
def foobar(芹菜任务):
return'simple task flow'
执行"configurepipeline.run(tagged_as=['some_pipeline'])`
将在完成"第一个"和"第二个"任务后作为任务运行"foobar"函数。
但是执行"configurepipeline.run(tagged_as=['other_pipeline'])`
将在"第三个"任务wa之后运行"foobar"函数完成。
…注意:
特德。_预定义的默认值:
基于预定义的默认值创建管道
——:func:`make_pipeline_from_defaults`允许您为管道创建自定义的
预定义默认值。此示例生成一个"foobar_pipeline"`
decorator,它将对每个步骤应用相同的标记:
…代码::python
>;>from毛细管导入make_pipeline_from_defaults
>;>foobar_pipeline=make_pipeline_from_defaults(
>;>tags=["foobar"]
>;)
eline`而所有的
定义都将使用'foobar'作为标记。
…注意:
/>:方法:`configurepipeline.run`
…代码::python
>;>pc.prettyprint(args=[],kwargs={})
task s.foo()tasks.bar()
代码::python
>;>来自毛细血管导入all,pipeline
>;@pipeline(
…毕竟,
…)
…最后定义(芹菜任务,obj):
…打印('全部完成!')
…返回对象
…注意:
概述内部发生的事情:meth:`~pipelineconfigurator.run()`:
-任务树是使用依赖项信息生成的
-芹菜签名是创建的
-任务树被简化为一个"链"<;http://celeri.readthedocs.org/en/latest/userguide/canvas.html chains>;`
使用to逻辑排序
-使用以下方法执行任务:meth:`celeriy.app.task.apply戥async`
…注意:
当前任务树被简化为任务的线性链表,但是未来可以实现不同的"runner"。
unit testing
----
直到调用:meth:`pipelineconfigurator.scan()'。如果函数代码不依赖于"芹菜任务"的第一个参数,只需传递"none"作为值即可。
代码::python
class pipelinetestcase(unittest.testcase):
/>===
要运行测试,请安装"py.test"并运行它:
…代码::bash
$py.test tests/
>
要考虑的功能
----
-使用大量带有作为参数传递的大对象的任务可能会占用大量存储空间。如果芹菜允许的话,另一种选择是动态生成签名。自动模块::毛细管
:成员:
:排除成员:pipelineconfigurator
…AutoClass::毛细管。管道配置程序
:成员:运行、预打印、扫描