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) 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 nor unbind_context is specified, the returned Spec does not include any context resources, equivalent to specifying tensorstore.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 and open=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 is True and delete_existing is False. This option takes precedence over assume_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 is True and delete_existing is False. The assume_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 returned Spec the metadata necessary to re-create the TensorStore. By default, the returned Spec includes the full metadata, but it is skipped if minimal_spec is set to True.

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 the TensorStore 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.