Skip to content

Dask doc review: [3] Bags #1593

Closed
Closed

Description

@pitrou

Bag Overview

The page doesn't say whether a bag is mutable or not. I'm guessing not,
but it would be worth spelling out.

The two following sentences seem a bit contradictory: "Dask bags coordinate
many Python lists or Iterators, each of which forms a partition of a
larger linear collection." and "a bag is like a list, but it doesn’t
guarantee an ordering among elements". "Linear collection" seems like
it implies "sequence" to me -- perhaps "linear" really means "flat" here?

Also, if you say a bag is like a multiset, that seems to imply some kind
of efficient member-checking, as with a tree or hash table. Is that the
case?

"Bag operations tend to be slower than array/dataframe computations in
the same way that Python tends to be slower than NumPy/pandas": perhaps
rephrase this as "... standard Python containers tend to be slower than
NumPy arrays and Pandas dataframes".

Create Dask Bags

Small consistency note: in the Dask array API, functions are described
as e.g. dask.array.from_array (actual module path), but here
they are described as e.g. db.from_sequence (conventional aliased
path instead of dask.bag.from_sequence).

The functions here don't summarize their signatures (e.g. the
heading for db.from_sequence should be
db.from_sequence(x, partition_size=None, npartitions=None)).

db.from_sequence
''''''''''''''''

It seems the function works not only with actual sequences, but with any
iterable::

>>> x = db.from_sequence([1,2,3,45,3])
>>> x.compute()
[1, 2, 3, 45, 3]
>>> y = db.from_sequence({1,2,3,45})
>>> y.compute()
[1, 2, 3, 45]

However, passing a Counter (the stdlib version of a multiset) breaks the
multiset expectation::

>>> from collections import Counter
>>> c = Counter([3,42,3])
>>> c
Counter({3: 2, 42: 1})
>>> x = db.from_sequence(c)
>>> x.compute()
[42, 3]

db.read_text
''''''''''''

The examples seem a bit misleading. The JSON files are not automatically
decoded, right? Also, this seems to assume that a JSON object will be
encoded into a single line of text?

"For convenience there is a string namespace attached directly to bags
with .str.methodname": does it automatically apply the method also to
nested bags / lists of strings?

(which begs the question: would a nested bag contain actual bags or simply
lists?)

Bag API

I'm a bit surprised that bags don't have a cache() method as arrays do.
This would sound useful, as otherwise any materialization goes through some
multiprocessed marshalling.

"Top level user functions": those seem to be methods of Bag objects, not
top-level functions in the dask.bag module, unless I'm missing
something.

Bag.accumulate
''''''''''''''

I'm a bit surprised here. A bag is supposed to be unordered, so how
can you compute a cumulative operation?

Bag.all(), Bag.any(), Bag.max(), Bag.min()
''''''''''''''''''''''''''''''''''''''''''

The signature is wrong (those methods take no mandatory argument) and the
documentation says "iterable" instead of "bag".

dask.bag.from_castra
''''''''''''''''''''

It would be good to say what a Castra is (or hyperlink to some external
documentation perhaps).

dask.bag.from_url
'''''''''''''''''

It would be useful to explain how this is different from
dask.bag.read_text on the given URL.

dask.bag.zip
''''''''''''

Last part of the fizzbuzz example (after "When what you really wanted (...)")
isn't formatted correctly.

Activity

  1. added 2 commits that reference this issue on Oct 3, 2016
    3a0a096
    faee62d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions