-
tensorstore.TensorStore.spec(self, *, open_mode: OpenMode | None =
None, open: bool | None =None, create: bool | None =None, delete_existing: bool | None =None, assume_metadata: bool | None =None, assume_cached_metadata: bool | None =None, minimal_spec: bool | None =None, retain_context: bool | None =None, unbind_context: bool | None =None, recheck_cached_metadata: RecheckCacheOption | None =None, recheck_cached_data: RecheckCacheOption | None =None, recheck_cached: RecheckCacheOption | None =None) Spec Spec that may be used to re-open or re-create the TensorStore.
Example
>>> dataset = await ts.open( ... { ... 'driver': 'zarr', ... 'kvstore': { ... 'driver': 'memory' ... } ... }, ... dtype=ts.uint32, ... shape=[70, 80], ... create=True) >>> dataset.spec() Spec({ 'driver': 'zarr', 'dtype': 'uint32', 'kvstore': {'driver': 'memory'}, 'metadata': { 'chunks': [70, 80], 'compressor': { 'blocksize': 0, 'clevel': 5, 'cname': 'lz4', 'id': 'blosc', 'shuffle': -1, }, 'dimension_separator': '.', 'dtype': '<u4', 'fill_value': None, 'filters': None, 'order': 'C', 'shape': [70, 80], 'zarr_format': 2, }, 'transform': { 'input_exclusive_max': [[70], [80]], 'input_inclusive_min': [0, 0], }, }) >>> dataset.spec(minimal_spec=True) Spec({ 'driver': 'zarr', 'dtype': 'uint32', 'kvstore': {'driver': 'memory'}, 'transform': { 'input_exclusive_max': [[70], [80]], 'input_inclusive_min': [0, 0], }, }) >>> dataset.spec(minimal_spec=True, unbind_context=True) Spec({ 'context': { 'cache_pool': {}, 'data_copy_concurrency': {}, 'memory_key_value_store': {}, }, 'driver': 'zarr', 'dtype': 'uint32', 'kvstore': {'driver': 'memory'}, 'transform': { 'input_exclusive_max': [[70], [80]], 'input_inclusive_min': [0, 0], }, })If neither
retain_contextnorunbind_contextis specified, the returnedSpecdoes not include any context resources, equivalent to specifyingtensorstore.Spec.update.strip_context.- Parameters:¶
- open_mode: OpenMode | None =
None¶ Overrides the existing open mode.
- open: bool | None =
None¶ Allow opening an existing TensorStore. Overrides the existing open mode.
- create: bool | None =
None¶ Allow creating a new TensorStore. Overrides the existing open mode. To open or create, specify
create=Trueandopen=True.- delete_existing: bool | None =
None¶ Delete any existing data before creating a new array. Overrides the existing open mode. Must be specified in conjunction with
create=True.- assume_metadata: bool | None =
None¶ Neither read nor write stored metadata. Instead, just assume any necessary metadata based on constraints in the spec, using the same defaults for any unspecified metadata as when creating a new TensorStore. The stored metadata need not even exist. Operations such as resizing that modify the stored metadata are not supported. Overrides the existing open mode. Requires that
openisTrueanddelete_existingisFalse. This option takes precedence overassume_cached_metadataif that option is also specified.Warning
This option can lead to data corruption if the assumed metadata does not match the stored metadata, or multiple concurrent writers use different assumed metadata.
- assume_cached_metadata: bool | None =
None¶ Skip reading the metadata when opening. Instead, just assume any necessary metadata based on constraints in the spec, using the same defaults for any unspecified metadata as when creating a new TensorStore. The stored metadata may still be accessed by subsequent operations that need to re-validate or modify the metadata. Requires that
openisTrueanddelete_existingisFalse. Theassume_metadataoption takes precedence if also specified.Warning
This option can lead to data corruption if the assumed metadata does not match the stored metadata, or multiple concurrent writers use different assumed metadata.
- minimal_spec: bool | None =
None¶ Indicates whether to include in the
Specreturned bytensorstore.TensorStore.specthe metadata necessary to re-create theTensorStore. By default, the returnedSpecincludes the full metadata, but it is skipped ifminimal_specis set toTrue.When applied to an existing
Specviatensorstore.openortensorstore.Spec.update, onlyFalsehas any effect.- retain_context: bool | None =
None¶ Retain all bound context resources (e.g. specific concurrency pools, specific cache pools).
The resultant
Specmay be used to re-open theTensorStoreusing the identical context resources.Specifying a value of
Falsehas no effect.- unbind_context: bool | None =
None¶ Convert any bound context resources to context resource specs that fully capture the graph of shared context resources and interdependencies.
Re-binding/re-opening the resultant spec will result in a new graph of new context resources that is isomorphic to the original graph of context resources. The resultant spec will not refer to any external context resources; consequently, binding it to any specific context will have the same effect as binding it to a default context.
Specifying a value of
Falsehas no effect.- recheck_cached_metadata: RecheckCacheOption | None =
None¶ Time after which cached metadata is assumed to be fresh. Cached metadata older than the specified time is revalidated prior to use. The metadata is used to check the bounds of every read or write operation.
Specifying
Truemeans that the metadata will be revalidated prior to every read or write operation. With the default value of"open", any cached metadata is revalidated when the TensorStore is opened but is not rechecked for each read or write operation.- recheck_cached_data: RecheckCacheOption | None =
None¶ Time after which cached data is assumed to be fresh. Cached data older than the specified time is revalidated prior to being returned from a read operation. Partial chunk writes are always consistent regardless of the value of this option.
The default value of
Truemeans that cached data is revalidated on every read. To enable in-memory data caching, you must both specify acache_poolwith a non-zerototal_bytes_limitand also specifyFalse,"open", or an explicit time bound forrecheck_cached_data.- recheck_cached: RecheckCacheOption | None =
None¶ Sets both
recheck_cached_dataandrecheck_cached_metadata.
- open_mode: OpenMode | None =