Command-line interface¶
Zarr-Python provides a command-line interface that enables:
- migration of Zarr v2 metadata to v3
- removal of v2 or v3 metadata
To see available commands run the following in a terminal:
or to get help on individual commands:
Migrate metadata from v2 to v3¶
Migrate to a separate location¶
To migrate a Zarr array/group's metadata from v2 to v3 run:
This will write new zarr.json
files to output.zarr
, leaving input.zarr
un-touched.
Note - this will migrate the entire Zarr hierarchy, so if input.zarr
contains multiple groups/arrays,
new zarr.json
will be made for all of them.
Migrate in-place¶
If you'd prefer to migrate the metadata in-place run:
This will write new zarr.json
files to input.zarr
, leaving the existing v2 metadata un-touched.
To open the array/group using the new metadata use:
Once you are happy with the conversion, you can run the following to remove the old v2 metadata:
Note there is also a shortcut to migrate and remove v2 metadata in one step:
Remove metadata¶
Remove v2 metadata using:
or v3 with:
By default, this will only allow removal of metadata if a valid alternative exists. For example, you can't remove v2 metadata unless v3 metadata exists at that location.
To override this behaviour use --force
:
Dry run¶
All commands provide a --dry-run
option that will log changes that would be made on a real run, without creating
or modifying any files.
zarr migrate v3 path/to/input.zarr --dry-run
Dry run enabled - no new files will be created or changed. Log of files that would be created on a real run:
Saving metadata to path/to/input.zarr/zarr.json
Verbose¶
You can also add --verbose
before any command, to see a full log of its actions:
Equivalent functions¶
All features of the command-line interface are also available via functions under
zarr.metadata
.