tiledbsoma.SOMATileDBContext

class tiledbsoma.SOMATileDBContext(tiledb_ctx: Optional[tiledb.ctx.Ctx] = None, tiledb_config: Optional[Dict[str, Union[str, float]]] = None, timestamp: Optional[Union[int, datetime.datetime]] = None)

Maintains TileDB-specific context for TileDB-SOMA objects. This context can be shared across multiple objects, including having a child object inherit it from its parent.

Treat this as immutable. Only code internal to the _soma_tiledb_context module should be modifying this. Use the replace method to construct a new SOMATileDBContext with new values.

Lifecycle

Experimental.

__init__(tiledb_ctx: Optional[tiledb.ctx.Ctx] = None, tiledb_config: Optional[Dict[str, Union[str, float]]] = None, timestamp: Optional[Union[int, datetime.datetime]] = None) None

Initializes a new SOMATileDBContext.

Either tiledb_ctx or tiledb_config may be provided, or both may be left at their default. If neither are provided, this will use a single shared tiledb.Ctx instantiated upon first use. If tiledb_ctx is provided, that exact tiledb.Ctx is used. If a tiledb_config is provided (in the form of a dict), it is used to construct a new Ctx.

Parameters
  • tiledb_ctx – An existing TileDB Context for use as the TileDB Context in this configuration.

  • tiledb_config – A set of TileDB configuration options to use, overriding the default configuration.

  • timestamp

    The default timestamp for operations on SOMA objects, provided either as a datetime.datetime or a number of milliseconds since the Unix epoch.

    WARNING: This should not be set unless you are absolutely sure you want to use the same timestamp across multiple operations. If multiple writes to the same object are performed at the same timestamp, they have no defined order. In almost all cases, it is better to pass a timestamp to a single open call, or to simply use the default behavior.

    This is used when a timestamp is not provided to an open operation.

    None, the default, sets the timestamp on each root open operation. That is, if you open a collection, and access individual members of the collection through indexing or add_new, the timestamp of all of those operations will be that of the time you called open.

    If a value is passed, that timestamp is used as the timestamp to record all operations.

    Set to 0xFFFFFFFFFFFFFFFF (UINT64_MAX) to get the absolute latest revision (i.e., including changes that occur “after” the current wall time) as of when each object is opened.

Methods

__init__([tiledb_ctx, tiledb_config, timestamp])

Initializes a new SOMATileDBContext.

replace(*[, tiledb_config, tiledb_ctx, ...])

Create a copy of the context, merging changes.

Attributes

tiledb_config

The TileDB configuration dictionary for this SOMA context.

tiledb_ctx

The TileDB Context for this SOMA context.

timestamp

The default timestamp for SOMA operations, or None if not provided.

timestamp_ms

The default timestamp for SOMA operations, as milliseconds since the Unix epoch, or None if not provided.