Giter VIP home page Giter VIP logo

dask-tutorial's Introduction

Dask Tutorial

This tutorial was last given at SciPy 2022 in Austin Texas. A video of the SciPy 2022 tutorial is available online.

Binder Build Status

Dask is a parallel and distributed computing library that scales the existing Python and PyData ecosystem. Dask can scale up to your full laptop capacity and out to a cloud cluster.

Prepare

1. You should clone this repository

git clone http://github.com/dask/dask-tutorial

and then install necessary packages. There are three different ways to achieve this, pick the one that best suits you, and only pick one option. They are, in order of preference:

2a) Create a conda environment (preferred)

In the main repo directory

conda env create -f binder/environment.yml
conda activate dask-tutorial

2b) Install into an existing environment

You will need the following core libraries

conda install -c conda-forge ipycytoscape jupyterlab python-graphviz matplotlib zarr xarray pooch pyarrow s3fs scipy dask distributed dask-labextension

Note that these options will alter your existing environment, potentially changing the versions of packages you already have installed.

2c) Use Dockerfile

You can build a docker image from the provided Dockerfile.

$ docker build . # This will build using the same env as in a)

Run a container, replacing the ID with the output of the previous command

$ docker run -it -p 8888:8888 -p 8787:8787 <container_id_or_tag>

The above command will give an URL (Like http://(container_id or 127.0.0.1):8888/?token=<sometoken>) which can be used to access the notebook from browser. You may need to replace the given hostname with "localhost" or "127.0.0.1".

You should follow only one of the options above!

Launch Jupyter

From the repo directory

jupyter lab

This was already done for method c) and does not need repeating.

You are welcome to use Jupyter notebook if you prefer, but we'll be using lab in the live tutorial.

Links

Outline

  1. Overview - dask's place in the universe.

  2. Dataframe - parallelized operations on many pandas dataframes spread across your cluster.

  3. Array - blocked numpy-like functionality with a collection of numpy arrays spread across your cluster.

  4. Delayed - the single-function way to parallelize general python code.

  5. Deployment/Distributed - Dask's scheduler for clusters, with details of how to view the UI.

  6. Distributed Futures - non-blocking results that compute asynchronously.

  7. Conclusion

dask-tutorial's People

Contributors

2sang avatar albertdefusco avatar alexandertyan avatar cpcloud avatar hendrikmakait avatar jacobtomlinson avatar jameslamb avatar jarnorfb avatar jcrist avatar jrbourbeau avatar jsignell avatar kori73 avatar koverholt avatar lazarillo avatar maddenp avatar martindurant avatar mathmagique avatar mplough-kobold avatar mrocklin avatar ncclementi avatar nhameleers avatar pabtorre avatar pavithraes avatar quasiben avatar raybellwaves avatar scharlottej13 avatar shanral avatar srcoulombe avatar tomaugspurger avatar zzhengnan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dask-tutorial's Issues

key error in bag example with account data

this block:

%%time

# Warning, this one takes a while...
js.groupby('name').map(lambda (k, v): (k, len(v))).compute()

Fails with a key error and long traceback from itertoolz:


KeyError Traceback (most recent call last)
in ()
----> 1 get_ipython().run_cell_magic('time', '', "\n# Warning, this one takes a while...\njs.groupby('name').map(lambda k, v: (k, len(v))).compute() #didn't work for me at all?")

/Users/szeitlin/anaconda/lib/python3.5/site-packages/IPython/core/interactiveshell.py in run_cell_magic(self, magic_name, line, cell)
2118 magic_arg_s = self.var_expand(line, stack_depth)
2119 with self.builtin_trap:
-> 2120 result = fn(magic_arg_s, cell)
2121 return result
2122

in time(self, line, cell, local_ns)

/Users/szeitlin/anaconda/lib/python3.5/site-packages/IPython/core/magic.py in (f, _a, *_k)
191 # but it's overkill for just that one bit of state.
192 def magic_deco(arg):
--> 193 call = lambda f, _a, *_k: f(_a, *_k)
194
195 if callable(arg):

/Users/szeitlin/anaconda/lib/python3.5/site-packages/IPython/core/magics/execution.py in time(self, line, cell, local_ns)
1171 if mode=='eval':
1172 st = clock2()
-> 1173 out = eval(code, glob, local_ns)
1174 end = clock2()
1175 else:

in ()

/Users/szeitlin/anaconda/lib/python3.5/site-packages/dask/base.py in compute(self, *_kwargs)
35
36 def compute(self, *_kwargs):
---> 37 return compute(self, **kwargs)[0]
38
39 @classmethod

/Users/szeitlin/anaconda/lib/python3.5/site-packages/dask/base.py in compute(_args, *_kwargs)
108 for opt, val in groups.items()])
109 keys = [var._keys() for var in variables]
--> 110 results = get(dsk, keys, **kwargs)
111
112 results_iter = iter(results)

/Users/szeitlin/anaconda/lib/python3.5/site-packages/dask/multiprocessing.py in get(dsk, keys, optimizations, num_workers, func_loads, func_dumps, *_kwargs)
75 # Run
76 result = get_async(apply_async, len(pool._pool), dsk3, keys,
---> 77 queue=queue, get_id=_process_get_id, *_kwargs)
78 finally:
79 if cleanup:

/Users/szeitlin/anaconda/lib/python3.5/site-packages/dask/async.py in get_async(apply_async, num_workers, dsk, result, cache, queue, get_id, raise_on_exception, rerun_exceptions_locally, callbacks, **kwargs)
479 _execute_task(task, data) # Re-execute locally
480 else:
--> 481 raise(remote_exception(res, tb))
482 state['cache'][key] = res
483 finish_task(dsk, key, state, results, keyorder.get)

KeyError: 'name'

Traceback

File "/Users/szeitlin/anaconda/lib/python3.5/site-packages/dask/async.py", line 264, in execute_task
result = _execute_task(task, data)
File "/Users/szeitlin/anaconda/lib/python3.5/site-packages/dask/async.py", line 245, in _execute_task
args2 = [_execute_task(a, cache) for a in args]
File "/Users/szeitlin/anaconda/lib/python3.5/site-packages/dask/async.py", line 245, in
args2 = [_execute_task(a, cache) for a in args]
File "/Users/szeitlin/anaconda/lib/python3.5/site-packages/dask/async.py", line 245, in _execute_task
args2 = [_execute_task(a, cache) for a in args]
File "/Users/szeitlin/anaconda/lib/python3.5/site-packages/dask/async.py", line 245, in
args2 = [_execute_task(a, cache) for a in args]
File "/Users/szeitlin/anaconda/lib/python3.5/site-packages/dask/async.py", line 246, in _execute_task
return func(*args2)
File "/Users/szeitlin/anaconda/lib/python3.5/site-packages/dask/bag/core.py", line 873, in collect
d = groupby(grouper, p.get(group, lock=False))
File "cytoolz/itertoolz.pyx", line 122, in cytoolz.itertoolz.groupby (cytoolz/itertoolz.c:3671)
File "cytoolz/itertoolz.pyx", line 165, in cytoolz.itertoolz.groupby (cytoolz/itertoolz.c:3533)

05 Array notebook fails

The 05 Array notebook examples fails for me at
In[8]: result.compute()

Stack trace:

distributed.batched - INFO - Batched Stream Closed
distributed.batched - INFO - Batched Stream Closed
distributed.batched - INFO - Batched Stream Closed
distributed.batched - INFO - Batched Stream Closed
distributed.batched - INFO - Batched Stream Closed
distributed.utils - ERROR - ('array-original-2a9a222b2f08d90710bd5f256242af17', '172.20.10.4:51739')
Traceback (most recent call last):
  File "/opt/anaconda/lib/python2.7/site-packages/distributed/utils.py", line 149, in f
    result[0] = yield gen.maybe_future(func(*args, **kwargs))
  File "/opt/anaconda/lib/python2.7/site-packages/tornado/gen.py", line 1015, in run
    value = future.result()
  File "/opt/anaconda/lib/python2.7/site-packages/tornado/concurrent.py", line 237, in result
    raise_exc_info(self._exc_info)
  File "/opt/anaconda/lib/python2.7/site-packages/tornado/gen.py", line 1021, in run
    yielded = self.gen.throw(*exc_info)
  File "/opt/anaconda/lib/python2.7/site-packages/distributed/client.py", line 896, in _gather
    st.traceback)
  File "<string>", line 2, in reraise
KilledWorker: ('array-original-2a9a222b2f08d90710bd5f256242af17', '172.20.10.4:51739')
---------------------------------------------------------------------------
KilledWorker                              Traceback (most recent call last)
<ipython-input-8-f80778adb0dc> in <module>()
----> 1 result.compute()

/opt/anaconda/lib/python2.7/site-packages/dask/base.pyc in compute(self, **kwargs)
     77             Extra keywords to forward to the scheduler ``get`` function.
     78         """
---> 79         return compute(self, **kwargs)[0]
     80 
     81     @classmethod

/opt/anaconda/lib/python2.7/site-packages/dask/base.pyc in compute(*args, **kwargs)
    177         dsk = merge(var.dask for var in variables)
    178     keys = [var._keys() for var in variables]
--> 179     results = get(dsk, keys, **kwargs)
    180 
    181     results_iter = iter(results)

/opt/anaconda/lib/python2.7/site-packages/distributed/client.pyc in get(self, dsk, keys, restrictions, loose_restrictions, resources, **kwargs)
   1467 
   1468         try:
-> 1469             results = self.gather(futures)
   1470         except (KeyboardInterrupt, Exception) as e:
   1471             for f in futures.values():

/opt/anaconda/lib/python2.7/site-packages/distributed/client.pyc in gather(self, futures, errors, maxsize)
    976             return (self.gather(f, errors=errors) for f in futures)
    977         else:
--> 978             return sync(self.loop, self._gather, futures, errors=errors)
    979 
    980     @gen.coroutine

/opt/anaconda/lib/python2.7/site-packages/distributed/utils.pyc in sync(loop, func, *args, **kwargs)
    161         e.wait(1000000)
    162     if error[0]:
--> 163         six.reraise(type(error[0]), error[0], traceback[0])
    164     else:
    165         return result[0]

/opt/anaconda/lib/python2.7/site-packages/distributed/utils.pyc in f()
    147     def f():
    148         try:
--> 149             result[0] = yield gen.maybe_future(func(*args, **kwargs))
    150         except Exception as exc:
    151             logger.exception(exc)

/opt/anaconda/lib/python2.7/site-packages/tornado/gen.pyc in run(self)
   1013 
   1014                     try:
-> 1015                         value = future.result()
   1016                     except Exception:
   1017                         self.had_exception = True

/opt/anaconda/lib/python2.7/site-packages/tornado/concurrent.pyc in result(self, timeout)
    235             return self._result
    236         if self._exc_info is not None:
--> 237             raise_exc_info(self._exc_info)
    238         self._check_done()
    239         return self._result

/opt/anaconda/lib/python2.7/site-packages/tornado/gen.pyc in run(self)
   1019 
   1020                     if exc_info is not None:
-> 1021                         yielded = self.gen.throw(*exc_info)
   1022                         exc_info = None
   1023                     else:

/opt/anaconda/lib/python2.7/site-packages/distributed/client.pyc in _gather(self, futures, errors)
    894                             six.reraise(type(st.exception),
    895                                         st.exception,
--> 896                                         st.traceback)
    897                         except (AttributeError, KeyError):
    898                             six.reraise(CancelledError,

/opt/anaconda/lib/python2.7/site-packages/six.pyc in reraise(tp, value, tb)

KilledWorker: ('array-original-2a9a222b2f08d90710bd5f256242af17', '172.20.10.4:51739')

Running on OS X
conda environment listing attached.
I may have an incompatible version of a package installed but that isn't obvious to figure out.
I am afraid anyone else would be left to assume dask doesn't work well.

env.yml.txt

Use the distributed scheduler

The distributed scheduler is now an integral part of Dask. This tutorial should talk about it. This could be in a few ways:

  1. Instantiate the distributed system from dask.distributed import Client; c = Client() and then run as normal in order to get the diagnostic visualizations, which are very helpful when trying to understand parallel computations
  2. Include a section on the concurrent futures interface (submit, map, gather, scatter) http://distributed.readthedocs.io/en/latest/quickstart.html#map-and-submit-functions
  3. Include a section on using the distributed system with dask collections (persist, compute)

matplotlib inline fix for mac

The Arrays file as written fails on imshow(). This is a known problem - matplotlib inline has to be called before importing.

This works:

%matplotlib inline
import matplotlib.pyplot as plt

plt.imshow(dsets[0][::4, ::4], cmap='RdBu_r')

Could do a pull request, but found this while executing the tutorial, so I'd have to pull in a fresh copy to insert the fix.

Scikit image warning on runprep

Just an FYI, when I run runprep, I get the following warning from scikit image:

C:\Users\rink\AppData\Local\Continuum\miniconda3\envs\dask-tutorial\lib\site-packages\skimage\transform\_warps.py:110: UserWarning: Anti-aliasing will be enabled by default in skimage 0.15 to avoid aliasing artifacts when down-sampling images. warn("Anti-aliasing will be enabled by default in skimage 0.15 to "

Thanks for such an amazing tutorial on dask. I look forward to finishing it and harassing my colleagues into using dask more often.

Graphviz not installed properly

Hey,

I just rebuilt the dockerimage and graphviz is not installed properly.
Particularly, in 02_foundations the first call to visualize is not working with the provided Dockerfile.
However, this can be simply fixed by adding
RUN conda install -y python-graphviz
to the Dockerfile. Shall I open a pull request?

environment.yml does not exist

The very beginning of the tutorial says to

conda env create -f environment.yml 
conda activate dask-tutorial

but this environment.yml does not exist anywhere in the repo.

weather data missing for example 05

This may be a problem with create_weather(), but example 05_Array in the tutorial does not work out of the box.

from prep import create_weather # Prep data if it doesn't exist
create_weather()

import h5py
from glob import glob
import os

filenames = sorted(glob(os.path.join('data', 'weather-big', '*.hdf5')))
dsets = [h5py.File(filename, mode='r')['/t2m'] for filename in filenames]
dsets[0]

returns:

....
KeyError: "Unable to open object (object 't2m' doesn't exist)"

distributed package not found but it is not a dependency of dask

While trying the 05_Array tutorial example, the first block of code failed because the distributed package could not be found. I had to install distributed separately from dask to get this to work but wouldn't it work better if distributed was a dependency of dask?

this line failed
from dask.distributed import Client

When I conda installed dask on OS X the distributed package was not installed with it.

conda install dask
Fetching package metadata ...............
Solving package specifications: .

Package plan for installation in environment /opt/anaconda:

The following packages will be UPDATED:

    cloudpickle: 0.1.1-py27_0 --> 0.2.2-py27_0
    dask:        0.8.1-py27_0 --> 0.13.0-py27_0
    partd:       0.3.2-py27_1 --> 0.3.7-py27_0

Proceed ([y]/n)?

cloudpickle-0. 100% |#########################################################################################| Time: 0:00:00 196.34 kB/s
partd-0.3.7-py 100% |#########################################################################################| Time: 0:00:00 400.17 kB/s
dask-0.13.0-py 100% |#########################################################################################| Time: 0:00:00

Array notebook - AttributeError

The 05 Array notebook fails for me at the same point as #31 but with a different error.

result.compute() gives the following stack trace:

AttributeError                            Traceback (most recent call last)
<ipython-input-8-f80778adb0dc> in <module>()
----> 1 result.compute()

~/anaconda3/envs/dask-tutorial/lib/python3.6/site-packages/dask/base.py in compute(self, **kwargs)
     97             Extra keywords to forward to the scheduler ``get`` function.
     98         """
---> 99         (result,) = compute(self, traverse=False, **kwargs)
    100         return result
    101 

~/anaconda3/envs/dask-tutorial/lib/python3.6/site-packages/dask/base.py in compute(*args, **kwargs)
    204     dsk = collections_to_dsk(variables, optimize_graph, **kwargs)
    205     keys = [var._keys() for var in variables]
--> 206     results = get(dsk, keys, **kwargs)
    207 
    208     results_iter = iter(results)

~/anaconda3/envs/dask-tutorial/lib/python3.6/site-packages/distributed/client.py in get(self, dsk, keys, restrictions, loose_restrictions, resources, sync, asynchronous, **kwargs)
   1932         if sync:
   1933             try:
-> 1934                 results = self.gather(packed, asynchronous=asynchronous)
   1935             finally:
   1936                 for f in futures.values():

~/anaconda3/envs/dask-tutorial/lib/python3.6/site-packages/distributed/client.py in gather(self, futures, errors, maxsize, direct, asynchronous)
   1374             return self.sync(self._gather, futures, errors=errors,
   1375                              direct=direct, local_worker=local_worker,
-> 1376                              asynchronous=asynchronous)
   1377 
   1378     @gen.coroutine

~/anaconda3/envs/dask-tutorial/lib/python3.6/site-packages/distributed/client.py in sync(self, func, *args, **kwargs)
    546             return future
    547         else:
--> 548             return sync(self.loop, func, *args, **kwargs)
    549 
    550     def __str__(self):

~/anaconda3/envs/dask-tutorial/lib/python3.6/site-packages/distributed/utils.py in sync(loop, func, *args, **kwargs)
    239         e.wait(1000000)
    240     if error[0]:
--> 241         six.reraise(*error[0])
    242     else:
    243         return result[0]

~/anaconda3/envs/dask-tutorial/lib/python3.6/site-packages/six.py in reraise(tp, value, tb)
    691             if value.__traceback__ is not tb:
    692                 raise value.with_traceback(tb)
--> 693             raise value
    694         finally:
    695             value = None

~/anaconda3/envs/dask-tutorial/lib/python3.6/site-packages/distributed/utils.py in f()
    227             yield gen.moment
    228             thread_state.asynchronous = True
--> 229             result[0] = yield make_coro()
    230         except Exception as exc:
    231             logger.exception(exc)

~/anaconda3/envs/dask-tutorial/lib/python3.6/site-packages/tornado/gen.py in run(self)
   1053 
   1054                     try:
-> 1055                         value = future.result()
   1056                     except Exception:
   1057                         self.had_exception = True

~/anaconda3/envs/dask-tutorial/lib/python3.6/site-packages/tornado/concurrent.py in result(self, timeout)
    236         if self._exc_info is not None:
    237             try:
--> 238                 raise_exc_info(self._exc_info)
    239             finally:
    240                 self = None

~/anaconda3/envs/dask-tutorial/lib/python3.6/site-packages/tornado/util.py in raise_exc_info(exc_info)

~/anaconda3/envs/dask-tutorial/lib/python3.6/site-packages/tornado/gen.py in wrapper(*args, **kwargs)
    305                 try:
    306                     orig_stack_contexts = stack_context._state.contexts
--> 307                     yielded = next(result)
    308                     if stack_context._state.contexts is not orig_stack_contexts:
    309                         yielded = TracebackFuture()

~/anaconda3/envs/dask-tutorial/lib/python3.6/site-packages/distributed/client.py in _gather(self, futures, errors, direct, local_worker)
   1215                 direct = False
   1216             else:
-> 1217                 if w.scheduler.address == self.scheduler.address:
   1218                     direct = True
   1219 

AttributeError: 'NoneType' object has no attribute 'address'

I get this error with all subsequent .compute() calls, and with the Meteorological Data plot exercise (and potentially more). Any thoughts on why this is happening would be great!

Thanks in advance

error in dask.delay tutorial undefined values (might be a noob thing)

Hi

Ive tried the tuturial a few time and have removed and redone all the steps a number of times but in the notebook, im getting a weird output of the following:


NameError Traceback (most recent call last)
in

NameError: name 'z' is not defined

Ive tried all the steps and removed and resinstalled files. Gone through the install a few times and still this keeps coming up. The code does define it as the following code:

%%time

This runs immediately, all it does is build a graph

x = delayed(inc)(1)
y = delayed(inc)(2)
z = delayed(add)(x, y)

then followed by:

%%time

This actually runs our computation using a local thread pool

z.compute()

But this comes up later in the same notebook for the total excercise. Which is weird.

How to create the animated graph?

The animated visualisation graph is really fabulous and would be helpful for my work. Is it an existing capability? Or if not do you have the script for it?

Thanks, Tim

merge with dask-examples

Would it make sense to include these notebooks as a directory in dask-examples, to take advantage of HTML rendering, CI tests and binder integration? Currently, the setup depends on conda env or a docker file.

The alternative would be to implement all that stuff here, which seems like a lot more work.
Thoughts, @mrocklin ?

Host turorial.dask.org like we do with examples.dask.org

It would be nice to host tutorial.dask.org similar to how we host examples.dask.org, which includes:

  1. Using nbsphinx to render the notebooks as HTML. (although this gets a bit more strange because exercises won't be filled in)
  2. Setting up a binder enviornment (which should just be done by the environment.yml file already in the tutorial).
  3. Ensuring that the exercises can be run inside that binder environment
  4. Setting up readthedocs and the subdomain

Follows on from #88

@quasiben is this something that you would be willing to do?

Feedback on SciPy tutorial

One quick bit of feedback from an attendee at the SciPy tutorial: They would have appreciated a high-level "Why Dask" introduction, before diving into examples. Filing this here in an attempt to not forget about it.

Command for new conda environment

In 'README.md', were it reads
'conda env create -f environment.yaml'
shouldn't it be
'conda env create -f environment.yml'
?
The first command didn't work on my computer.

solution for foldby exercise in 02_bag

If anyone is confident of their solution to the foldby exercise in the 02_bag notebook, computing the total amount per name, I'm curious to check mine:

from operator import add

def sum_amounts(x):
    result = 0
    for transaction in x['transactions']:
        result += transaction['amount']
    return result

def accm_amount(total, x):
    return total + sum_amounts(x)

result = js.foldby(key='name', 
                   binop=accm_amount,
                   initial=0,
                   combine=add, 
                   combine_initial=0).compute()
print(sorted(result))

Is it possible to parallelize sklearn's DBSCAN algorithm

def meth2(X):
    with parallel_backend('dask'):
        model = DBSCAN(eps = 0.5, min_samples = 30)
        model.fit(X)
    return model

thought this would work as per the documentation, but I am getting

BufferError: Existing exports of data: object cannot be re-sized

Graphviz installation issues for Windows

Looks like Windows users need to jump through a few more hoops in order to get graphviz to work, which is unfortunately needed for any .visualize commands. I'll make a pull request with some clarification in the instructions once I sort it out fully, if that's alright.

Remove discussion of custom graphs

This is internal API and probably not suitable to give to students in a tutorial, lest they shoot themselves in the foot. Or, if we keep things we should probably mark it as informational, rather than include exercises.

However, it would be nice to include dask.delayed earlier. It serves the same role, providing the ability to wrap custom code.

Variable misnamed in prep.py

Line 13 of prep.py has data_fir instead of data_dir.

This should only cause an issue if a user deletes the data directory before running prep.py. My initial thought at a solution is to rename that variable, but should I be concerned about how I deleted the data cloned from the parent repository?

03_bag change map for starmap

map is deprecated on python3.6

Then I had a warning Use the .flatten method instead warn("Deprecated. Use the .flatten method instead")
in
(js.filter(lambda record: record['name'] == 'Alice') .pluck('transactions') .concat() .pluck('amount') .take(3))

dask.bag example in 06_distributed_advanced

The following code:

import dask.bag as db
import os
import json
filename = os.path.join('data', 'accounts.*.json.gz')
lines = db.read_text(filename)
js = lines.map(json.loads)

f = c.compute(js.filter(lambda record: record['name'] == 'Alice')
.pluck('transactions')
.concat()
.pluck('amount')
.mean())

returns an error:

AttributeError: 'Bag' object has no attribute 'concat'

Remark on installing older lib version Mac obsolete?

The tutorial 03b says:

If you're on a Mac you need to install the previous versions of h5py and pytables, like so:
conda install h5py=2.4.0 pytables=3.1.1
The most recent versions of these libraries cause a segfault when writing to HDF5 storage.

It seems they are obsolete, even so I get an error later on now:

%%time
if os.path.exists('accounts.castra'):
    import shutil
    shutil.rmtree('accounts.castra')

c = df.to_castra('accounts.castra', categories=['names'])
df3 = c.to_dask()

ValueError: Expected iterable of tuples of (name, dtype), got ['id', 'names', 'amount']

Using castra 0.1.7

CSV length computation in Foundations is slower with dask

In 02_foundations.ipynb, it states that there should be "a handy speed-up factor of more than two" when using dask. But I am getting 1.11 seconds with "normal, sequential code" and 2.29 seconds with the "concise version" of the dask implementation.

I'm not sure if I've somehow done something wrong or if it depends on CPU or hard disk speed. Should the tutorial text be amended to qualify the speedup claim?

noob at dask, how to read a 3GB stata file?

Hi, I am trying to read a 3 GB stata file to analyze on python. I just completed the dask tutorials on datacamp.

This code works:

data = pd.read_stata('/Users/sherrymukim/Documents/nfhs/IAHR71DT/IAHR71FL.DTA',chunksize=100000)

But the following takes forever:

for chunk in data:
    print(chunk.shape)

My macbook has just 2GB RAM, and I will be switching to a higher RAM laptop in one month.

How do I even preview the file to know what columns are there?

Please help!!! Thank you.

I am stuck on this for one week. :-(

YoutubeVideo in JupyterLab Pane

from @mrocklin :

I wonder there is a way to get this YouTube video in a JupyterLab pane when the user starts up their session. Any suggestions @ian-r-rose?

@ian-r-rose

It should be possible -- the help panels are just iframes on the page, and those are serialized in workspace files. If you open a help panel, save the workspace, and manually replace the url in the workspace JSON with the youtube embed link, it should do the job.

Notebooks for use with a cluster

When we run this tutorial, we'll provide cloud resources for attendees. How should the material change for this environment?

  1. Changes to setup the cluster / client (let's assume KubeCluster & a worker-template.yaml like pangeo)
  2. Changes in data storage (files on S3/GCS and cloud-friendly formats)
  3. Changes in scale (we have more compute to play with)

How do we organize this? I'd favor putting the cluster-specific notebooks in the same git repository, perhaps under a different folder.

How has this been handled in past tutorials where we provided cluster resources?

Typos in 02_foundations.ipynb

  1. In Example 2:

The task is run (without 's') in a separate process, and the return-code will remain None until it completes, (...)

  1. After Example 3, in 'Dask graphs'

Any Dask object, such as total, above, has an attribute which describes the calculations necessary to produce that result. (...)

Error creating environment on Win10/x64/Anaconda: "LinkError: post-link script failed for package defaults::ipykernel-4.9.0-py37_0"

Hi there - Very excited to go through your tutorial, but had a problem getting the environment set up. Here's the trace:

(base) > conda env create environment.yml                                                                                                  
Using Anaconda API: https://api.anaconda.org                                                                                                                                                  
Solving environment: done                                                                                                                                                                     
                                                                                                                                                                                              
Downloading and Extracting Packages                                                                                                                                                           
winpty-0.4.3         | 1.1 MB    | ################################################################################################################################################## | 100%  
m2w64-gcc-libgfortra | 340 KB    | ################################################################################################################################################## | 100%  
python-3.7.0         | 21.1 MB   | ################################################################################################################################################## | 100%  
snakeviz-1.0.0       | 187 KB    | ################################################################################################################################################## | 100%  
notebook-5.6.0       | 7.3 MB    | ################################################################################################################################################## | 100%  
py-1.6.0             | 138 KB    | ################################################################################################################################################## | 100%  
cytoolz-0.9.0.1      | 325 KB    | ################################################################################################################################################## | 100%  
pyopenssl-18.0.0     | 82 KB     | ################################################################################################################################################## | 100%  
llvmlite-0.24.0      | 9.3 MB    | ################################################################################################################################################## | 100%  
pywinpty-0.5.4       | 47 KB     | ################################################################################################################################################## | 100%  
pyyaml-3.13          | 148 KB    | ################################################################################################################################################## | 100%  
win_inet_pton-1.0.1  | 6 KB      | ################################################################################################################################################## | 100%  
pyasn1-modules-0.2.2 | 85 KB     | ################################################################################################################################################## | 100%  
zict-0.1.3           | 18 KB     | ################################################################################################################################################## | 100%  
multipledispatch-0.6 | 21 KB     | ################################################################################################################################################## | 100%  
cryptography-vectors | 30.4 MB   | ################################################################################################################################################## | 100%  
psutil-5.4.7         | 323 KB    | ################################################################################################################################################## | 100%  
cloudpickle-0.5.5    | 27 KB     | ################################################################################################################################################## | 100%  
incremental-17.5.0   | 25 KB     | ################################################################################################################################################## | 100%  
cycler-0.10.0        | 13 KB     | ################################################################################################################################################## | 100%  
prompt_toolkit-1.0.1 | 334 KB    | ################################################################################################################################################## | 100%  
send2trash-1.5.0     | 16 KB     | ################################################################################################################################################## | 100%  
zope-1.0             | 4 KB      | ################################################################################################################################################## | 100%  
packaging-17.1       | 33 KB     | ################################################################################################################################################## | 100%  
traitlets-4.3.2      | 133 KB    | ################################################################################################################################################## | 100%  
chardet-3.0.4        | 184 KB    | ################################################################################################################################################## | 100%  
python-dateutil-2.7. | 260 KB    | ################################################################################################################################################## | 100%  
hdf5-1.10.2          | 18.9 MB   | ################################################################################################################################################## | 100%  
tornado-5.1          | 668 KB    | ################################################################################################################################################## | 100%  
requests-file-1.4.3  | 7 KB      | ################################################################################################################################################## | 100%  
testpath-0.3.1       | 90 KB     | ################################################################################################################################################## | 100%  
distributed-1.23.1   | 862 KB    | ################################################################################################################################################## | 100%  
asn1crypto-0.24.0    | 154 KB    | ################################################################################################################################################## | 100%  
dask-core-0.19.1     | 1.1 MB    | ################################################################################################################################################## | 100%  
wheel-0.31.1         | 80 KB     | ################################################################################################################################################## | 100%  
parso-0.3.1          | 114 KB    | ################################################################################################################################################## | 100%  
bokeh-0.13.0         | 5.1 MB    | ################################################################################################################################################## | 100%  
h5py-2.8.0           | 833 KB    | ################################################################################################################################################## | 100%  
pywin32-223          | 9.3 MB    | ################################################################################################################################################## | 100%  
pandoc-2.2.3.2       | 21.0 MB   | ################################################################################################################################################## | 100%  
sortedcontainers-2.0 | 43 KB     | ################################################################################################################################################## | 100%  
pyzmq-17.1.2         | 400 KB    | ################################################################################################################################################## | 100%  
pytz-2018.5          | 232 KB    | ################################################################################################################################################## | 100%  
partd-0.3.8          | 31 KB     | ################################################################################################################################################## | 100%  
mkl_random-1.0.1     | 267 KB    | ################################################################################################################################################## | 100%  
freetype-2.9.1       | 470 KB    | ################################################################################################################################################## | 100%  
zope.interface-4.5.0 | 202 KB    | ################################################################################################################################################## | 100%  
webencodings-0.5.1   | 19 KB     | ################################################################################################################################################## | 100%  
atomicwrites-1.2.1   | 11 KB     | ################################################################################################################################################## | 100%  
m2w64-gcc-libs-core- | 213 KB    | ################################################################################################################################################## | 100%  
mistune-0.8.3        | 198 KB    | ################################################################################################################################################## | 100%  
botocore-1.11.2      | 3.2 MB    | ################################################################################################################################################## | 100%  
appdirs-1.4.3        | 16 KB     | ################################################################################################################################################## | 100%  
markupsafe-1.0       | 27 KB     | ################################################################################################################################################## | 100%  
networkx-2.1         | 1.8 MB    | ################################################################################################################################################## | 100%  
msgpack-python-0.5.6 | 85 KB     | ################################################################################################################################################## | 100%  
zeromq-4.2.5         | 9.6 MB    | ################################################################################################################################################## | 100%  
certifi-2018.8.24    | 140 KB    | ################################################################################################################################################## | 100%  
scipy-1.1.0          | 13.5 MB   | ################################################################################################################################################## | 100%  
ca-certificates-2018 | 155 KB    | ################################################################################################################################################## | 100%  
html5lib-1.0.1       | 181 KB    | ################################################################################################################################################## | 100%  
m2w64-gcc-libs-5.3.0 | 518 KB    | ################################################################################################################################################## | 100%  
libsodium-1.0.16     | 582 KB    | ################################################################################################################################################## | 100%  
kiwisolver-1.0.1     | 61 KB     | ################################################################################################################################################## | 100%  
requests-2.19.1      | 96 KB     | ################################################################################################################################################## | 100%  
pysocks-1.6.8        | 22 KB     | ################################################################################################################################################## | 100%  
dask-glm-0.1.0       | 24 KB     | ################################################################################################################################################## | 100%  
pluggy-0.7.1         | 25 KB     | ################################################################################################################################################## | 100%  
pytest-3.8.0         | 339 KB    | ################################################################################################################################################## | 100%  
nbconvert-5.3.1      | 422 KB    | ################################################################################################################################################## | 100%  
dask-0.19.1          | 4 KB      | ################################################################################################################################################## | 100%  
mkl_fft-1.0.4        | 120 KB    | ################################################################################################################################################## | 100%  
constantly-15.1.0    | 13 KB     | ################################################################################################################################################## | 100%  
thrift-0.11.0        | 103 KB    | ################################################################################################################################################## | 100%  
toolz-0.9.0          | 91 KB     | ################################################################################################################################################## | 100%  
mkl-2019.0           | 178.1 MB  | ################################################################################################################################################## | 100%  
urllib3-1.23         | 152 KB    | ################################################################################################################################################## | 100%  
vs2015_runtime-14.0. | 2.0 MB    | ################################################################################################################################################## | 100%  
jmespath-0.9.3       | 34 KB     | ################################################################################################################################################## | 100%  
pyparsing-2.2.0      | 96 KB     | ################################################################################################################################################## | 100%  
jsonschema-2.6.0     | 104 KB    | ################################################################################################################################################## | 100%  
fastparquet-0.1.6    | 223 KB    | ################################################################################################################################################## | 100%  
backcall-0.1.0       | 19 KB     | ################################################################################################################################################## | 100%  
jedi-0.12.1          | 225 KB    | ################################################################################################################################################## | 100%  
heapdict-1.0.0       | 7 KB      | ################################################################################################################################################## | 100%  
terminado-0.8.1      | 21 KB     | ################################################################################################################################################## | 100%  
imageio-2.4.1        | 3.3 MB    | ################################################################################################################################################## | 100%  
tk-8.6.8             | 3.8 MB    | ################################################################################################################################################## | 100%  
s3fs-0.1.6           | 35 KB     | ################################################################################################################################################## | 100%  
pyasn1-0.4.4         | 101 KB    | ################################################################################################################################################## | 100%  
wrapt-1.10.11        | 44 KB     | ################################################################################################################################################## | 100%  
s3transfer-0.1.13    | 76 KB     | ################################################################################################################################################## | 100%  
numpy-1.15.1         | 37 KB     | ################################################################################################################################################## | 100%  
simplegeneric-0.8.1  | 9 KB      | ################################################################################################################################################## | 100%  
bleach-2.1.4         | 33 KB     | ################################################################################################################################################## | 100%  
docutils-0.14        | 694 KB    | ################################################################################################################################################## | 100%  
qt-5.9.6             | 92.5 MB   | ################################################################################################################################################## | 100%  
dask-ml-0.9.0        | 127 KB    | ################################################################################################################################################## | 100%  
jupyter_core-4.4.0   | 85 KB     | ################################################################################################################################################## | 100%  
libxml2-2.9.8        | 3.2 MB    | ################################################################################################################################################## | 100%  
ipython_genutils-0.2 | 39 KB     | ################################################################################################################################################## | 100%  
vc-14                | 3 KB      | ################################################################################################################################################## | 100%  
service_identity-17. | 18 KB     | ################################################################################################################################################## | 100%  
prometheus_client-0. | 52 KB     | ################################################################################################################################################## | 100%  
automat-0.7.0        | 70 KB     | ################################################################################################################################################## | 100%  
m2w64-gmp-6.1.0      | 689 KB    | ################################################################################################################################################## | 100%  
setuptools-40.2.0    | 575 KB    | ################################################################################################################################################## | 100%  
hyperlink-18.0.0     | 62 KB     | ################################################################################################################################################## | 100%  
twisted-18.7.0       | 4.9 MB    | ################################################################################################################################################## | 100%  
pyqt-5.9.2           | 4.6 MB    | ################################################################################################################################################## | 100%  
six-1.11.0           | 21 KB     | ################################################################################################################################################## | 100%  
tblib-1.3.2          | 16 KB     | ################################################################################################################################################## | 100%  
idna-2.7             | 99 KB     | ################################################################################################################################################## | 100%  
ujson-1.35           | 26 KB     | ################################################################################################################################################## | 100%  
pip-10.0.1           | 1.7 MB    | ################################################################################################################################################## | 100%  
scikit-learn-0.19.1  | 4.6 MB    | ################################################################################################################################################## | 100%  
pandas-0.23.4        | 8.6 MB    | ################################################################################################################################################## | 100%  
nbformat-4.4.0       | 160 KB    | ################################################################################################################################################## | 100%  
intel-openmp-2019.0  | 1.7 MB    | ################################################################################################################################################## | 100%  
jinja2-2.10          | 183 KB    | ################################################################################################################################################## | 100%  
jupyter_client-5.2.3 | 201 KB    | ################################################################################################################################################## | 100%  
cryptography-2.3     | 509 KB    | ################################################################################################################################################## | 100%  
attrs-18.2.0         | 51 KB     | ################################################################################################################################################## | 100%  
cffi-1.11.5          | 213 KB    | ################################################################################################################################################## | 100%  
olefile-0.46         | 49 KB     | ################################################################################################################################################## | 100%  
locket-0.2.0         | 8 KB      | ################################################################################################################################################## | 100%  
pandocfilters-1.4.2  | 13 KB     | ################################################################################################################################################## | 100%  
wincertstore-0.2     | 13 KB     | ################################################################################################################################################## | 100%  
numexpr-2.6.8        | 129 KB    | ################################################################################################################################################## | 100%  
click-6.7            | 105 KB    | ################################################################################################################################################## | 100%  
ipykernel-4.9.0      | 147 KB    | ################################################################################################################################################## | 100%  
boto3-1.8.2          | 111 KB    | ################################################################################################################################################## | 100%  
entrypoints-0.2.3    | 9 KB      | ################################################################################################################################################## | 100%  
numba-0.39.0         | 2.5 MB    | ################################################################################################################################################## | 100%  
pygments-2.2.0       | 1.3 MB    | ################################################################################################################################################## | 100%  
m2w64-libwinpthread- | 30 KB     | ################################################################################################################################################## | 100%  
ipython-6.5.0        | 1.1 MB    | ################################################################################################################################################## | 100%  
scikit-image-0.14.0  | 23.3 MB   | ################################################################################################################################################## | 100%  
decorator-4.3.0      | 15 KB     | ################################################################################################################################################## | 100%  
sip-4.19.12          | 283 KB    | ################################################################################################################################################## | 100%  
pywavelets-1.0.0     | 4.3 MB    | ################################################################################################################################################## | 100%  
pytables-3.4.4       | 2.7 MB    | ################################################################################################################################################## | 100%  
requests-ftp-0.3.1   | 14 KB     | ################################################################################################################################################## | 100%  
graphviz-2.38        | 37.7 MB   | ################################################################################################################################################## | 100%  
blosc-1.14.4         | 651 KB    | ################################################################################################################################################## | 100%  
colorama-0.3.9       | 23 KB     | ################################################################################################################################################## | 100%  
pycparser-2.18       | 167 KB    | ################################################################################################################################################## | 100%  
msys2-conda-epoch-20 | 2 KB      | ################################################################################################################################################## | 100%  
more-itertools-4.3.0 | 83 KB     | ################################################################################################################################################## | 100%  
libiconv-1.15        | 664 KB    | ################################################################################################################################################## | 100%  
matplotlib-2.2.3     | 6.5 MB    | ################################################################################################################################################## | 100%  
pillow-5.2.0         | 648 KB    | ################################################################################################################################################## | 100%  
pandas-datareader-0. | 135 KB    | ################################################################################################################################################## | 100%  
numpy-base-1.15.1    | 3.9 MB    | ################################################################################################################################################## | 100%  
wcwidth-0.1.7        | 23 KB     | ################################################################################################################################################## | 100%  
sqlite-3.24.0        | 899 KB    | ################################################################################################################################################## | 100%  
lxml-4.2.5           | 1.2 MB    | ################################################################################################################################################## | 100%  
pickleshare-0.7.4    | 12 KB     | ################################################################################################################################################## | 100%  
Preparing transaction: done                                                                                                                                                                   
Verifying transaction: done                                                                                                                                                                   
Executing transaction: failed                                                                                                                                                                 
2018-09-17 12:14:10,427 - conda.core.link - ERROR - An error occurred while installing package 'defaults::ipykernel-4.9.0-py37_0'.                                                            
LinkError: post-link script failed for package defaults::ipykernel-4.9.0-py37_0                                                                                                               
running your command again with `-v` will provide additional information                                                                                                                      
location of failed script: C:\ProgramData\Anaconda3\envs\dask-tutorial\Scripts\.ipykernel-post-link.bat                                                                                       
==> script messages <==                                                                                                                                                                       
<None>                                                                                                                                                                                        
                                                                                                                                                                                              
Attempting to roll back.                                                                                                                                                                      
                                                                                                                                                                                              
ERROR conda.core.link:_execute(502): An error occurred while installing package 'defaults::ipykernel-4.9.0-py37_0'.                                                                           
LinkError: post-link script failed for package defaults::ipykernel-4.9.0-py37_0                                                                                                               
running your command again with `-v` will provide additional information                                                                                                                      
location of failed script: C:\ProgramData\Anaconda3\envs\dask-tutorial\Scripts\.ipykernel-post-link.bat                                                                                       
==> script messages <==                                                                                                                                                                       
<None>                                                                                                                                                                                        
                                                                                                                                                                                              
Attempting to roll back.                                                                                                                                                                      
                                                                                                                                                                                              
Rolling back transaction: done                                                                                                                                                                
                                                                                                                                                                                              
LinkError: post-link script failed for package defaults::ipykernel-4.9.0-py37_0                                                                                                               
running your command again with `-v` will provide additional information                                                                                                                      
location of failed script: C:\ProgramData\Anaconda3\envs\dask-tutorial\Scripts\.ipykernel-post-link.bat                                                                                       
==> script messages <==                                                                                                                                                                       
<None>                                                                                                                                                                                        

Here's the conda info:

(base) C:\Users\me\dev\experiments\dask-tutorial>conda info                                 
                                                                                                       
     active environment : base                                                                         
    active env location : C:\ProgramData\Anaconda3                                                     
            shell level : 1                                                                            
       user config file : C:\Users\me\.condarc                                              
 populated config files : C:\Users\me\.condarc                                              
          conda version : 4.5.11                                                                       
    conda-build version : 3.12.0                                                                       
         python version : 3.6.3.final.0                                                                
       base environment : C:\ProgramData\Anaconda3  (writable)                                         
           channel URLs : https://conda.anaconda.org/conda-forge/win-64                                
                          https://conda.anaconda.org/conda-forge/noarch                                
                          https://repo.anaconda.com/pkgs/main/win-64                                   
                          https://repo.anaconda.com/pkgs/main/noarch                                   
                          https://repo.anaconda.com/pkgs/free/win-64                                   
                          https://repo.anaconda.com/pkgs/free/noarch                                   
                          https://repo.anaconda.com/pkgs/r/win-64                                      
                          https://repo.anaconda.com/pkgs/r/noarch                                      
                          https://repo.anaconda.com/pkgs/pro/win-64                                    
                          https://repo.anaconda.com/pkgs/pro/noarch                                    
                          https://repo.anaconda.com/pkgs/msys2/win-64                                  
                          https://repo.anaconda.com/pkgs/msys2/noarch                                  
          package cache : C:\ProgramData\Anaconda3\pkgs                                                
                          C:\Users\me\AppData\Local\conda\conda\pkgs                        
       envs directories : C:\ProgramData\Anaconda3\envs                                                
                          C:\Users\me\AppData\Local\conda\conda\envs                        
                          C:\Users\me\.conda\envs                                           
               platform : win-64                                                                       
             user-agent : conda/4.5.11 requests/2.18.4 CPython/3.6.3 Windows/10 Windows/10.0.14393     
          administrator : True                                                                         
             netrc file : None                                                                         
           offline mode : False                                                                        

Is this because it's trying to install an ipykernel for Python 3.7 and I'm using 3.6.3?

Thanks in advance.

solutions/Array-03.py in 05_Array produces "TypeError: can't pickle _thread._local objects"

Running through the tutorial examples I found a problem with the following array example:

%load solutions/Array-03.py

import h5py
from glob import glob
import os

filenames = sorted(glob(os.path.join('data', 'weather-big', '*.hdf5')))
dsets = [h5py.File(filename, mode='r')['/t2m'] for filename in filenames]
import dask.array as da
arrays = [da.from_array(dset, chunks=(500, 500)) for dset in dsets]
x = da.stack(arrays, axis=0)
result = x[:, ::2, ::2]
da.to_hdf5(os.path.join('data', 'myfile.hdf5'), '/output', result)

TypeError Traceback (most recent call last)
~/anaconda2/envs/dask-tutorial/lib/python3.6/site-packages/distributed/protocol/pickle.py in dumps(x)
37 try:
---> 38 result = pickle.dumps(x, protocol=pickle.HIGHEST_PROTOCOL)
39 if len(result) < 1000:

TypeError: can't pickle _thread._local objects

During handling of the above exception, another exception occurred:

TypeError Traceback (most recent call last)
in ()
14 result = x[:, ::2, ::2]
15
---> 16 da.to_hdf5(os.path.join('data', 'myfile.hdf5'), '/output', result)

~/anaconda2/envs/dask-tutorial/lib/python3.6/site-packages/dask/array/core.py in to_hdf5(filename, *args, **kwargs)
3388 if chunks is True else chunks, **kwargs)
3389 for dp, x in data.items()]
-> 3390 store(list(data.values()), dsets)
3391
3392

~/anaconda2/envs/dask-tutorial/lib/python3.6/site-packages/dask/array/core.py in store(sources, targets, lock, regions, compute, return_stored, **kwargs)
949
950 if compute:
--> 951 result.compute()
952 return None
953 else:

~/anaconda2/envs/dask-tutorial/lib/python3.6/site-packages/dask/base.py in compute(self, **kwargs)
133 dask.base.compute
134 """
--> 135 (result,) = compute(self, traverse=False, **kwargs)
136 return result
137

~/anaconda2/envs/dask-tutorial/lib/python3.6/site-packages/dask/base.py in compute(*args, **kwargs)
331 postcomputes = [a.dask_postcompute() if is_dask_collection(a)
332 else (None, a) for a in args]
--> 333 results = get(dsk, keys, **kwargs)
334 results_iter = iter(results)
335 return tuple(a if f is None else f(next(results_iter), *a)

~/anaconda2/envs/dask-tutorial/lib/python3.6/site-packages/distributed/client.py in get(self, dsk, keys, restrictions, loose_restrictions, resources, sync, asynchronous, **kwargs)
1991 futures = self._graph_to_futures(dsk, set(flatten([keys])),
1992 restrictions, loose_restrictions,
-> 1993 resources=resources)
1994 packed = pack_data(keys, futures)
1995 if sync:

~/anaconda2/envs/dask-tutorial/lib/python3.6/site-packages/distributed/client.py in _graph_to_futures(self, dsk, keys, restrictions, loose_restrictions, priority, resources, retries)
1952
1953 self._send_to_scheduler({'op': 'update-graph',
-> 1954 'tasks': valmap(dumps_task, dsk3),
1955 'dependencies': valmap(list, dependencies),
1956 'keys': list(flatkeys),

~/anaconda2/envs/dask-tutorial/lib/python3.6/site-packages/toolz/dicttoolz.py in valmap(func, d, factory)
82 """
83 rv = factory()
---> 84 rv.update(zip(iterkeys(d), map(func, itervalues(d))))
85 return rv
86

~/anaconda2/envs/dask-tutorial/lib/python3.6/site-packages/distributed/worker.py in dumps_task(task)
701 elif not any(map(_maybe_complex, task[1:])):
702 return {'function': dumps_function(task[0]),
--> 703 'args': pickle.dumps(task[1:])}
704 return to_serialize(task)
705

~/anaconda2/envs/dask-tutorial/lib/python3.6/site-packages/distributed/protocol/pickle.py in dumps(x)
49 except Exception:
50 try:
---> 51 return cloudpickle.dumps(x, protocol=pickle.HIGHEST_PROTOCOL)
52 except Exception as e:
53 logger.info("Failed to serialize %s. Exception: %s", x, e)

~/anaconda2/envs/dask-tutorial/lib/python3.6/site-packages/cloudpickle/cloudpickle.py in dumps(obj, protocol)
879 try:
880 cp = CloudPickler(file, protocol=protocol)
--> 881 cp.dump(obj)
882 return file.getvalue()
883 finally:

~/anaconda2/envs/dask-tutorial/lib/python3.6/site-packages/cloudpickle/cloudpickle.py in dump(self, obj)
266 self.inject_addons()
267 try:
--> 268 return Pickler.dump(self, obj)
269 except RuntimeError as e:
270 if 'recursion' in e.args[0]:

~/anaconda2/envs/dask-tutorial/lib/python3.6/pickle.py in dump(self, obj)
407 if self.proto >= 4:
408 self.framer.start_framing()
--> 409 self.save(obj)
410 self.write(STOP)
411 self.framer.end_framing()

~/anaconda2/envs/dask-tutorial/lib/python3.6/pickle.py in save(self, obj, save_persistent_id)
474 f = self.dispatch.get(t)
475 if f is not None:
--> 476 f(self, obj) # Call unbound method with explicit self
477 return
478

~/anaconda2/envs/dask-tutorial/lib/python3.6/pickle.py in save_tuple(self, obj)
749 write(MARK)
750 for element in obj:
--> 751 save(element)
752
753 if id(obj) in memo:

~/anaconda2/envs/dask-tutorial/lib/python3.6/pickle.py in save(self, obj, save_persistent_id)
519
520 # Save the reduce() output and finally memoize the object
--> 521 self.save_reduce(obj=obj, *rv)
522
523 def persistent_id(self, obj):

~/anaconda2/envs/dask-tutorial/lib/python3.6/pickle.py in save_reduce(self, func, args, state, listitems, dictitems, obj)
632
633 if state is not None:
--> 634 save(state)
635 write(BUILD)
636

~/anaconda2/envs/dask-tutorial/lib/python3.6/pickle.py in save(self, obj, save_persistent_id)
474 f = self.dispatch.get(t)
475 if f is not None:
--> 476 f(self, obj) # Call unbound method with explicit self
477 return
478

~/anaconda2/envs/dask-tutorial/lib/python3.6/pickle.py in save_dict(self, obj)
819
820 self.memoize(obj)
--> 821 self._batch_setitems(obj.items())
822
823 dispatch[dict] = save_dict

~/anaconda2/envs/dask-tutorial/lib/python3.6/pickle.py in _batch_setitems(self, items)
845 for k, v in tmp:
846 save(k)
--> 847 save(v)
848 write(SETITEMS)
849 elif n:

~/anaconda2/envs/dask-tutorial/lib/python3.6/pickle.py in save(self, obj, save_persistent_id)
494 reduce = getattr(obj, "reduce_ex", None)
495 if reduce is not None:
--> 496 rv = reduce(self.proto)
497 else:
498 reduce = getattr(obj, "reduce", None)

TypeError: can't pickle _thread._local objects

Error reproducing the machine learning tutorial

Hi,

I'm trying to reproduce the tutorial "08_machine_learning.ipynb". I gget the following error when I execute this line:

from dask_ml.cluster import KMeans

Error: ~/anaconda3/lib/python3.6/site-packages/dask_ml/base.py in ()
5 import numpy as np
6 import dask
----> 7 from dask.array import learn
8
9

ImportError: cannot import name 'learn'

How can I solve this error?

Best regard,

Oscar

#noob confused about accessing dask tutorial

Hi, I was just reading the instructions for accessing the dask tutorial. And I am stumped at the following...my question is how do i access the repo directory? executing this "conda env create -f environment.yml " in terminal window or in python is giving an error. Thank you very much.

b) Create a new environment
In the repo directory

conda env create -f environment.yml
and then on osx/linux

source activate dask-tutorial


The error in terminal:

mukim:~ sherrymukim$ conda env create -f environment.yml
Using Anaconda API: https://api.anaconda.org

SpecNotFound: Can't process without a name


The error in python:
conda env create -f environment.yml
source activate dask-tutorial
File "", line 1
conda env create -f environment.yml
^
SyntaxError: invalid syntax

Problem setting up conda environment for the tutorial

Hi
I don't know how specific this problem is to my situation, but the instruction for setting up an environment for the tutorial doesn't work

$ conda env create -f environment.yaml
Using Anaconda API: https://api.anaconda.org

SpecNotFound: Can't process without a name

No environment is created by the command:

$ source activate dask-tutorial

CondaEnvironmentNotFoundError: Could not find environment: dask-tutorial .
You can list all discoverable environments with `conda info --envs`.

Instead, I found by accident that the following works:

$ conda env update
Using Anaconda API: https://api.anaconda.org
Fetching package metadata ...........
...
...
Collecting cachey
Requirement already satisfied: heapdict in /Users/jack/anaconda3/envs/dask-tutorial/lib/python3.6/site-packages (from cachey)
Installing collected packages: graphviz, cachey
Successfully installed cachey-0.1.1 graphviz-0.8
#
# To activate this environment, use:
# > source activate dask-tutorial
#
# To deactivate an active environment, use:
# > source deactivate
#

Here's my setup:

$ uname -a
Darwin Jacks-MBP 16.7.0 Darwin Kernel Version 16.7.0: Thu Jun 15 17:36:27 PDT 2017; root:xnu-3789.70.16~2/RELEASE_X86_64 x86_64

$ conda info
Current conda install:

               platform : osx-64
          conda version : 4.3.23
       conda is private : False
      conda-env version : 4.3.23
    conda-build version : not installed
         python version : 3.6.1.final.0
       requests version : 2.14.2
       root environment : /Users/jack/anaconda3  (writable)
    default environment : /Users/jack/anaconda3/envs/dask-tutorial
       envs directories : /Users/jack/anaconda3/envs
                          /Users/jack/.conda/envs
          package cache : /Users/jack/anaconda3/pkgs
                          /Users/jack/.conda/pkgs
           channel URLs : https://repo.continuum.io/pkgs/free/osx-64
                          https://repo.continuum.io/pkgs/free/noarch
                          https://repo.continuum.io/pkgs/r/osx-64
                          https://repo.continuum.io/pkgs/r/noarch
                          https://repo.continuum.io/pkgs/pro/osx-64
                          https://repo.continuum.io/pkgs/pro/noarch
            config file : None
             netrc file : None
           offline mode : False
             user-agent : conda/4.3.23 requests/2.14.2 CPython/3.6.1 Darwin/16.7.0 OSX/10.12.6
                UID:GID : 501:20

Where to get the data from?

In the Array tutorial you open a file under data/x, but there is no such file in that directory. In fact there is only one subdirectory, which then contains very small weather data files.

What kind of data did you use for the tutorial and where to get that from?

Can you add instructions for that to the array tutorial?

Misunderstanding of size and len

Hey guys,

I was following dask-tutorial in the scipy-2017 branch and I got confused on the solution of question 2 in 03-dask-dataframes notebook:

len(df)

# OR

df.size.compute()

where df is a Dask Dataframe.

Do you agree that this two operations are not the same or am I missing something?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.