急切执行#

注意

版本 0.2.0a2 中的新功能

Mars 支持急切模式,使其在开发时更加友好,便于调试。

用户可以通过在程序或控制台会话开始时设置选项来启用积极模式。

>>> from mars.config import options
>>> options.eager_mode = True

或者使用上下文。

>>> from mars.config import option_context

>>> with option_context() as options:
>>>     options.eager_mode = True
>>>     # the eager mode is on only for the with statement
>>>     ...

如果开启了急切模式,一旦创建,Mars对象如张量和数据框将由默认会话立即执行。

>>> import mars.tensor as mt
>>> import mars.dataframe as md
>>> from mars.config import options
>>> options.eager_mode = True
>>> t = mt.arange(6).reshape(2, 3)
>>> t
array([[0, 1, 2],
       [3, 4, 5]])
>>> df = md.DataFrame(t)
>>> df.sum()
0    3
1    5
2    7
dtype: int64