0
# Configuration and Utilities
1
2
Configuration system and utility functions for zarr settings, metadata management, and debugging operations.
3
4
## Capabilities
5
6
### Configuration System
7
8
```python { .api }
9
config: Config
10
```
11
12
Global configuration object for zarr settings.
13
14
**Key configuration areas:**
15
- `array.*`: Array creation defaults
16
- `codecs.*`: Codec configurations
17
- `storage.*`: Storage backend settings
18
19
**Methods:**
20
- `config.get(key)`: Get configuration value
21
- `config.set(settings_dict)`: Update configuration
22
- `config.update(settings_dict)`: Merge configuration updates
23
24
### Metadata Operations
25
26
```python { .api }
27
def consolidate_metadata(
28
store: StoreLike,
29
path: str = None,
30
zarr_format: int = None
31
) -> Group
32
```
33
34
Consolidate metadata of all nodes in a hierarchy for improved performance.
35
36
### Data Management Utilities
37
38
```python { .api }
39
def copy(
40
source: Union[Array, Group, StoreLike],
41
dest: Union[Array, Group, StoreLike],
42
name: str = None,
43
chunk_store: StoreLike = None,
44
if_exists: str = 'raise',
45
**kwargs
46
) -> tuple[int, int, int]
47
```
48
49
Copy arrays or groups between storage locations.
50
51
```python { .api }
52
def copy_all(
53
source: StoreLike,
54
dest: StoreLike,
55
**kwargs
56
) -> tuple[int, int, int]
57
```
58
59
Copy all arrays and groups from source to destination.
60
61
```python { .api }
62
def copy_store(
63
source: StoreLike,
64
dest: StoreLike,
65
**kwargs
66
) -> tuple[int, int, int]
67
```
68
69
Copy entire store contents.
70
71
### Version Information
72
73
```python { .api }
74
__version__: str
75
```
76
77
The zarr package version string.
78
79
### Visualization and Debugging
80
81
```python { .api }
82
def tree(
83
grp: Group,
84
expand: bool = None,
85
level: int = None
86
) -> Any
87
```
88
89
Display tree representation of group hierarchy.
90
91
```python { .api }
92
def print_debug_info() -> None
93
```
94
95
Print version and dependency information for debugging.
96
97
## Usage Examples
98
99
### Version Information
100
101
```python
102
import zarr
103
104
# Check zarr version
105
print(f"zarr version: {zarr.__version__}")
106
107
# Use in version checks
108
if zarr.__version__ >= '3.0.0':
109
print("Using zarr v3 features")
110
```
111
112
### Configuration Management
113
114
```python
115
import zarr
116
from zarr.codecs import BloscCodec
117
118
# View current configuration
119
print(zarr.config.get('array.v2_default_compressor'))
120
121
# Update global settings
122
zarr.config.set({
123
'array.v2_default_compressor.numeric': 'zstd',
124
'array.order': 'F'
125
})
126
127
# Configure default codecs
128
zarr.config.set({
129
'codecs.blosc': 'zarr.codecs.BloscCodec',
130
'codecs.blosc.cname': 'zstd',
131
'codecs.blosc.clevel': 3
132
})
133
```
134
135
### Metadata Consolidation
136
137
```python
138
# Create group with many arrays
139
grp = zarr.group('large_dataset.zarr')
140
for i in range(100):
141
grp.create_array(f'array_{i}', shape=(100, 100))
142
143
# Consolidate metadata for faster access
144
consolidated = zarr.consolidate_metadata('large_dataset.zarr')
145
146
# Opening consolidated group is much faster
147
fast_grp = zarr.open_consolidated('large_dataset.zarr')
148
```
149
150
### Data Operations
151
152
```python
153
# Copy data between stores
154
source = zarr.open('source_data.zarr')
155
dest_store = zarr.storage.LocalStore('backup/')
156
zarr.copy(source, dest_store)
157
158
# Tree visualization
159
grp = zarr.open_group('complex_dataset.zarr')
160
print(zarr.tree(grp, expand=True))
161
```