question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Adding attrs arg to create_group and create_dataset

See original GitHub issue

As it stands now, when one writes a group or dataset, one must write the attributes as a separate operation. This results in creation of .zattrs once. Then if one update the attributes, it results in writing .zattrs again. With something like a ZipStore backed Zarr Group, one gets a warning on writing .zattrs the second time, which AFAICT is unavoidable unless someone sets the attributes correctly the first time. So if we include an argument for attrs to create_group and create_dataset, we should be able to avoid this warning by setting the attributes during creation of these Zarr objects.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
alimanfoocommented, Nov 24, 2017

Thinking about this some more, I actually think the current behaviour is a bit pointless: when an array or group is created, an empty dict is written to the .zattrs key, but there is no need to write .zattrs at all unless the user actually wants to store some attributes. I’m tempted to change this so that .zattrs is only written when the user actually wants to store some attributes. This would obviate the need for an ‘attrs’ argument to array or group creation, because, e.g.:

g = zarr.group()
g.attrs.update(foo='bar', baz='qux')

…would then imply only a single write to .zattrs.

0reactions
alimanfoocommented, Nov 24, 2017

I’ve gone ahead and implemented this in #200, everything works fine and should be fully backwards compatible with code and data, so seems like a good thing to me.

Read more comments on GitHub >

github_iconTop Results From Across the Web

netCDF4 API documentation
Dataset.createGroup takes a single argument, a python string containing the name of the new group. The new Group instances contained within the ...
Read more >
attrs by Example - attrs 22.2.0 documentation
If you create an attribute with init=False , the kw_only argument is ignored. Keyword-only attributes allow subclasses to add attributes without default ...
Read more >
h5fortran/Examples.md at main · geospace-code ... - GitHub
Create dataset with fill value ... By default a dataset has arbitrary data. Providing a fill value initializes the dataset to that value,...
Read more >
Create a Dataset Using a Web Service - Oracle Help Center
On the Data Model pane, select Parameters, click Create New Parameter, and define the parameters to make them available to the web service...
Read more >
hdf5r: Interface to the 'HDF5' Binary Data Format
Additionally, functionality is added so that 'HDF5' objects behave very ... createGroup Maps to object$create_group where object implements CommonFG.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found