本文整理汇总了Python中dask.get方法的典型用法代码示例。如果您正苦于以下问题:Python dask.get方法的具体用法?Python dask.get怎么用?Python dask.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dask
的用法示例。
在下文中一共展示了dask.get方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_ephemeral_persisting
# 需要导入模块: import dask [as 别名]
# 或者: from dask import get [as 别名]
def test_ephemeral_persisting(zk, dsk2):
with Persist(zk, name="dsk2", ns="/test/dags", ephemeral=True):
with Ran() as r:
assert get(dsk2, 'e') == 10
assert r.steps == ['e']
with Ran() as r:
assert get(dsk2, 's') == 0.4
assert r.steps == ['f', 's']
with Ran() as r:
assert get(dsk2, 's') == 0.4
assert r.steps == []
assert loads(zk.get("/test/dags/dsk2/e")[0]) == 10
with pytest.raises(NoNodeError):
zk.get("/test/dags/dsk2/e")
示例2: enable
# 需要导入模块: import dask [as 别名]
# 或者: from dask import get [as 别名]
def enable(func):
"""
Decorator to attach the current MPI communicator to the input
keyword arguments of ``func``, via the ``comm`` keyword.
"""
import functools
@functools.wraps(func)
def wrapped(*args, **kwargs):
kwargs.setdefault('comm', None)
if kwargs['comm'] is None:
kwargs['comm'] = CurrentMPIComm.get()
return func(*args, **kwargs)
return wrapped
示例3: get
# 需要导入模块: import dask [as 别名]
# 或者: from dask import get [as 别名]
def get(cls):
"""
Get the default current MPI communicator. The initial value is ``MPI.COMM_WORLD``.
"""
return cls._stack[-1]
示例4: __init__
# 需要导入模块: import dask [as 别名]
# 或者: from dask import get [as 别名]
def __init__(self, **kwargs):
self.old = _global_options.copy()
for key in sorted(kwargs):
if key not in _global_options:
raise KeyError("Option `%s` is not supported" % key)
_global_options.update(kwargs)
# resize the global Cache!
# FIXME: after https://github.com/dask/cachey/pull/12
if 'global_cache_size' in kwargs:
cache = GlobalCache.get().cache
cache.available_bytes = _global_options['global_cache_size']
cache.shrink()
示例5: __exit__
# 需要导入模块: import dask [as 别名]
# 或者: from dask import get [as 别名]
def __exit__(self, type, value, traceback):
_global_options.clear()
_global_options.update(self.old)
# resize Cache to original size
# FIXME: after https://github.com/dask/cachey/pull/12
cache = GlobalCache.get().cache
cache.available_bytes = _global_options['global_cache_size']
cache.shrink()
示例6: test_persisting
# 需要导入模块: import dask [as 别名]
# 或者: from dask import get [as 别名]
def test_persisting(zk, dsk1):
with Persist(zk, name="dsk1"):
with Ran() as r:
assert get(dsk1, 'w') == 6
assert r.steps == ['z', 'w']
with Ran() as r:
assert get(dsk1, 'w') == 6
assert r.steps == []
assert loads(zk.get("/epos/dsk1/z")[0]) == 3
assert loads(zk.get("/epos/dsk1/w")[0]) == 6
# tests ephemeral=False, znode still exists after context handler
assert loads(zk.get("/epos/dsk1/w")[0]) == 6
示例7: test_locking
# 需要导入模块: import dask [as 别名]
# 或者: from dask import get [as 别名]
def test_locking(zk, dsk1):
with pytest.raises(LockTimeout):
# two identical locks; the second cannot acquire
with Lock(zk, name="dsk1", timeout=1), \
Lock(zk, name="dsk1", timeout=1):
get(dsk1, 'w')
# test lock release
with Lock(zk, name="dsk1"):
get(dsk1, 'w')
get(dsk1, 'w')
示例8: test_ephemeral_locking
# 需要导入模块: import dask [as 别名]
# 或者: from dask import get [as 别名]
def test_ephemeral_locking(zk, dsk2):
with pytest.raises(LockTimeout):
with Lock(zk, name="dsk2", timeout=1, ephemeral=True), \
Lock(zk, name="dsk2", timeout=1, ephemeral=True):
get(dsk2, 'f')
with pytest.raises(NoNodeError):
zk.get("/epos/dsk2")
示例9: __call__
# 需要导入模块: import dask [as 别名]
# 或者: from dask import get [as 别名]
def __call__(self, dsk, keys, **kwargs):
"""Compute dask task and keep track of number of times we do so."""
import dask
self.total_computes += 1
if self.total_computes > self.max_computes:
raise RuntimeError("Too many dask computations were scheduled: "
"{}".format(self.total_computes))
return dask.get(dsk, keys, **kwargs)