Skip to content

Add name kwarg to from_zarr#1

Merged
mpeaton merged 4 commits intomasterfrom
zarr_name
Apr 2, 2019
Merged

Add name kwarg to from_zarr#1
mpeaton merged 4 commits intomasterfrom
zarr_name

Conversation

@mpeaton
Copy link

@mpeaton mpeaton commented Apr 1, 2019

  • Tests added / passed
  • [x ] Passes flake8 dask

@mpeaton mpeaton requested review from dcharbon and jrbourbeau April 1, 2019 20:07
Copy link

@jrbourbeau jrbourbeau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @mpeaton, this generally looks good to me! I've attached a few comments. Also, it's my understanding that we want to make the PR for this fix from the Quansight-Labs Dask fork

  • Could you please add a regression test to dask/array/tests/test_array_core.py which fails on master and demonstrates this PR fixes the from_zarr name issue
  • There are a couple of minor flake8 linting issues
  • There was a recent update to the main Dask master branch which fixed a failing zarr-related test. Merging the current Dask master branch into this PR will prevent that failing test from showing up here

z = zarr.Array(mapper, read_only=True, path=component, **kwargs)
chunks = chunks if chunks is not None else z.chunks
return from_array(z, chunks, name='zarr-%s' % url)
return from_array(z, chunks, name = name)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be useful for the default name of the output array to indicate it was created with from_zarr. For example, something like

if name is None:
    name = 'from-zarr-' + tokenize(z, component, storage_options, chunks, **kwargs)

Copy link
Author

@mpeaton mpeaton Apr 1, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I agree. The only reason I can think of for dissent however, is that establishing protocol for identifying source in a name string seems undesirable, as opposed to say, creating a higher level object to accumulate such information.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

creating a higher level object to accumulate such information

The name information here is stored in the dask graph representation of the dask array. Using more descriptive graph key names like 'from-zarr-...', while not required, can be useful when inspecting the underlying dask graph (especially when debugging) and is generally used throughout the codebase. For example:

https://github.com/dask/dask/blob/a3cba093ea041a999258e518ab5d5f5c93f611b1/dask/dataframe/io/io.py#L181

https://github.com/dask/dask/blob/a3cba093ea041a999258e518ab5d5f5c93f611b1/dask/array/core.py#L2342

https://github.com/dask/dask/blob/a3cba093ea041a999258e518ab5d5f5c93f611b1/dask/dataframe/io/io.py#L253

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I follow. Ok thanks. Change pushed.

@mpeaton mpeaton merged commit b865857 into master Apr 2, 2019
mpeaton added a commit that referenced this pull request Apr 5, 2019
* Add name kwarg to from_zarr

* added default from_zarr naming convention per jrbourbeau

* flake8 fix
mpeaton added a commit that referenced this pull request Apr 9, 2019
* Add name kwarg to from_zarr

* added default from_zarr naming convention per jrbourbeau

* flake8 fix
mpeaton added a commit that referenced this pull request Apr 10, 2019
* Add name kwarg to from_zarr

* added default from_zarr naming convention per jrbourbeau

* flake8 fix
mpeaton added a commit that referenced this pull request Apr 15, 2019
* Add name kwarg to from_zarr

* added default from_zarr naming convention per jrbourbeau

* flake8 fix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants