-
tensorstore.Spec.update(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
, unbind_context: bool | None =None
, strip_context: bool | None =None
, context: Context | None =None
, kvstore: KvStore.Spec | None =None
, minimal_spec: bool | None =None
, recheck_cached_metadata: RecheckCacheOption | None =None
, recheck_cached_data: RecheckCacheOption | None =None
, recheck_cached: RecheckCacheOption | None =None
, rank: int | None =None
, dtype: dtype | None =None
, domain: IndexDomain | None =None
, shape: Sequence[int] | None =None
, chunk_layout: ChunkLayout | None =None
, codec: CodecSpec | None =None
, fill_value: ArrayLike | None =None
, dimension_units: Sequence[Unit | str | Real | tuple[Real, str] | None] | None =None
, schema: Schema | None =None
) None Adds additional constraints or changes the open mode.
Example
>>> spec = ts.Spec({'driver': 'n5', 'kvstore': {'driver': 'memory'}}) >>> spec.update(shape=[100, 200, 300]) >>> spec Spec({ 'driver': 'n5', 'kvstore': {'driver': 'memory'}, 'schema': { 'domain': {'exclusive_max': [100, 200, 300], 'inclusive_min': [0, 0, 0]}, }, 'transform': { 'input_exclusive_max': [[100], [200], [300]], 'input_inclusive_min': [0, 0, 0], }, })
- 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.
- 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.- strip_context: bool | None =
None
¶ Replace any bound context resources and unbound context resource specs by default context resource specs.
If the resultant
Spec
is re-opened with, or re-bound to, a new context, it will use the default context resources specified by that context.Specifying a value of
False
has no effect.- context: Context | None =
None
¶ Bind any context resource specs using the specified shared resource context.
Any already-bound context resources remain unchanged. Additionally, any context resources specified by a nested
TensorStore.context
spec will be created as specified, but won’t be overridden bycontext
.- kvstore: KvStore.Spec | None =
None
¶ Sets the associated key-value store used as the underlying storage.
If the
kvstore
has already been set, it is overridden.It is an error to specify this if the TensorStore driver does not use a key-value store.
- 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.- 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
.- rank: int | None =
None
¶ Constrains the rank of the TensorStore. If there is an index transform, the rank constraint must match the rank of the input space.
- dtype: dtype | None =
None
¶ Constrains the data type of the TensorStore. If a data type has already been set, it is an error to specify a different data type.
- domain: IndexDomain | None =
None
¶ Constrains the domain of the TensorStore. If there is an existing domain, the specified domain is merged with it as follows:
The rank must match the existing rank.
All bounds must match, except that a finite or explicit bound is permitted to match an infinite and implicit bound, and takes precedence.
If both the new and existing domain specify non-empty labels for a dimension, the labels must be equal. If only one of the domains specifies a non-empty label for a dimension, the non-empty label takes precedence.
Note that if there is an index transform, the domain must match the input space, not the output space.
- shape: Sequence[int] | None =
None
¶ Constrains the shape and origin of the TensorStore. Equivalent to specifying a
domain
ofts.IndexDomain(shape=shape)
.Note
This option also constrains the origin of all dimensions to be zero.
- chunk_layout: ChunkLayout | None =
None
¶ Constrains the chunk layout. If there is an existing chunk layout constraint, the constraints are merged. If the constraints are incompatible, an error is raised.
- codec: CodecSpec | None =
None
¶ Constrains the codec. If there is an existing codec constraint, the constraints are merged. If the constraints are incompatible, an error is raised.
- fill_value: ArrayLike | None =
None
¶ Specifies the fill value for positions that have not been written.
The fill value data type must be convertible to the actual data type, and the shape must be broadcast-compatible with the domain.
If an existing fill value has already been set as a constraint, it is an error to specify a different fill value (where the comparison is done after normalization by broadcasting).
- dimension_units: Sequence[Unit | str | Real | tuple[Real, str] | None] | None =
None
¶ Specifies the physical units of each dimension of the domain.
The physical unit for a dimension is the physical quantity corresponding to a single index increment along each dimension.
A value of
None
indicates that the unit is unknown. A dimension-less quantity can be indicated by a unit of""
.- schema: Schema | None =
None
¶ Additional schema constraints to merge with existing constraints.
- open_mode: OpenMode | None =