-
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_context
norunbind_context
is specified, the returnedSpec
does 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=True
andopen=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
open
isTrue
anddelete_existing
isFalse
. This option takes precedence overassume_cached_metadata
if 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
open
isTrue
anddelete_existing
isFalse
. Theassume_metadata
option 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
Spec
returned bytensorstore.TensorStore.spec
the metadata necessary to re-create theTensorStore
. By default, the returnedSpec
includes the full metadata, but it is skipped ifminimal_spec
is set toTrue
.When applied to an existing
Spec
viatensorstore.open
ortensorstore.Spec.update
, onlyFalse
has any effect.- retain_context: bool | None =
None
¶ Retain all bound context resources (e.g. specific concurrency pools, specific cache pools).
The resultant
Spec
may be used to re-open theTensorStore
using the identical context resources.Specifying a value of
False
has 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
False
has 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
True
means 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
True
means that cached data is revalidated on every read. To enable in-memory data caching, you must both specify acache_pool
with a non-zerototal_bytes_limit
and also specifyFalse
,"open"
, or an explicit time bound forrecheck_cached_data
.- recheck_cached: RecheckCacheOption | None =
None
¶ Sets both
recheck_cached_data
andrecheck_cached_metadata
.
- open_mode: OpenMode | None =