Пример #1
0
def test_effective_get():
    da = pytest.importorskip('dask.array')
    x = da.arange(10, chunks=(5, ))

    with pytest.warns(Warning) as record:
        assert effective_get(collection=x) is dask.threaded.get
        assert effective_get(get=dask.threaded.get) is dask.threaded.get

    assert any('dask.base.get_scheduler' in str(warning)
               for warning in record.list)
Пример #2
0
def test_effective_get():
    da = pytest.importorskip('dask.array')
    x = da.arange(10, chunks=(5,))

    with pytest.warns(Warning) as record:
        assert effective_get(collection=x) is dask.threaded.get
        assert effective_get(get=dask.threaded.get) is dask.threaded.get

    assert any('dask.base.get_scheduler' in str(warning)
               for warning in record.list)
Пример #3
0
def get_scheduler(get=None, collection=None):
    """ Determine the dask scheduler that is being used.

    None is returned if not dask scheduler is active.

    See also
    --------
    dask.utils.effective_get
    """
    try:
        from dask.utils import effective_get
        actual_get = effective_get(get, collection)
        try:
            from dask.distributed import Client
            if isinstance(actual_get.__self__, Client):
                return 'distributed'
        except (ImportError, AttributeError):
            try:
                import dask.multiprocessing
                if actual_get == dask.multiprocessing.get:
                    return 'multiprocessing'
                else:
                    return 'threaded'
            except ImportError:
                return 'threaded'
    except ImportError:
        return None
Пример #4
0
def _get_scheduler(get=None, collection=None):
    """Determine the dask scheduler that is being used.

    None is returned if no dask scheduler is active.

    See also
    --------
    dask.base.get_scheduler
    """
    try:
        # dask 0.18.1 and later
        from dask.base import get_scheduler
        actual_get = get_scheduler(get, collection)
    except ImportError:
        try:
            from dask.utils import effective_get
            actual_get = effective_get(get, collection)
        except ImportError:
            return None

    try:
        from dask.distributed import Client
        if isinstance(actual_get.__self__, Client):
            return 'distributed'
    except (ImportError, AttributeError):
        try:
            import dask.multiprocessing
            if actual_get == dask.multiprocessing.get:
                return 'multiprocessing'
            else:
                return 'threaded'
        except ImportError:
            return 'threaded'
Пример #5
0
def _get_scheduler(get=None, collection=None):
    """Determine the dask scheduler that is being used.

    None is returned if no dask scheduler is active.

    See also
    --------
    dask.base.get_scheduler
    """
    try:
        # dask 0.18.1 and later
        from dask.base import get_scheduler

        actual_get = get_scheduler(get, collection)
    except ImportError:
        try:
            from dask.utils import effective_get

            actual_get = effective_get(get, collection)
        except ImportError:
            return None

    try:
        from dask.distributed import Client

        if isinstance(actual_get.__self__, Client):
            return "distributed"
    except (ImportError, AttributeError):
        try:
            import dask.multiprocessing

            if actual_get == dask.multiprocessing.get:
                return "multiprocessing"
            else:
                return "threaded"
        except ImportError:
            return "threaded"