fiftyone.operators.store.service#

Execution store service.

Copyright 2017-2025, Voxel51, Inc.

Classes:

ExecutionStoreService([repo, dataset_id, ...])

Service for managing execution store operations.

class fiftyone.operators.store.service.ExecutionStoreService(repo: ExecutionStoreRepo | None = None, dataset_id: ObjectId | None = None, collection_name: str = None)#

Bases: object

Service for managing execution store operations.

Note that each instance of this service has a context:

  • If a dataset_id is provided (or a repo associated with one), this instance operates on stores associated with that dataset

  • If no dataset_id is provided (or a repo is provided that is not associated with one), this instance operates on stores that are not associated with a dataset

To operate on all stores across all contexts, use the XXX_global() methods that this class provides.

Parameters:

Methods:

create_store(store_name[, metadata, policy])

Creates a new store with the specified name.

clear_cache([store_name])

Clears all cache entries in the execution stores.

get_store(store_name)

Gets the specified store for the current context.

list_stores()

Lists all stores for the current context.

count_stores()

Counts the stores for the current context.

has_store(store_name)

Determines whether the specified store exists in the current context.

delete_store(store_name)

Deletes the specified store.

set_key(store_name, key, value[, ttl, policy])

Sets the value of a key in the specified store.

set_cache_key(store_name, key, value[, ttl])

Sets the value of a cache key in the specified store.

has_key(store_name, key)

Determines whether the specified key exists in the specified store.

get_key(store_name, key)

Retrieves the value of a key from the specified store.

delete_key(store_name, key)

Deletes the specified key from the store.

update_ttl(store_name, key, new_ttl)

Updates the TTL of the specified key in the store.

list_keys(store_name)

Lists all keys in the specified store.

count_keys(store_name)

Counts the keys in the specified store.

cleanup()

Deletes all stores associated with the current context.

has_store_global(store_name)

Determines whether a store with the given name exists across all datasets and the global context.

list_stores_global()

Lists the stores across all datasets and the global context.

count_stores_global()

Counts the stores across all datasets and the global context.

delete_store_global(store_name)

Deletes the specified store across all datasets and the global context.

create_store(store_name: str, metadata: dict[str, Any] | None = None, policy: str = 'persist') StoreDocument#

Creates a new store with the specified name.

Parameters:

store_name – the name of the store

Returns:

a fiftyone.store.models.StoreDocument

clear_cache(store_name=None) None#

Clears all cache entries in the execution stores.

get_store(store_name: str) StoreDocument#

Gets the specified store for the current context.

Parameters:

store_name – the name of the store

Returns:

a fiftyone.store.models.StoreDocument

list_stores() list[str]#

Lists all stores for the current context.

Returns:

a list of store names

count_stores() int#

Counts the stores for the current context.

Returns:

the number of stores

has_store(store_name) bool#

Determines whether the specified store exists in the current context.

Parameters:

store_name – the name of the store

Returns:

True/False

delete_store(store_name: str) StoreDocument#

Deletes the specified store.

Parameters:

store_name – the name of the store

Returns:

a fiftyone.store.models.StoreDocument

set_key(store_name: str, key: str, value: Any, ttl: int | None = None, policy: str = 'persist') KeyDocument#

Sets the value of a key in the specified store.

Keys can be either persistent or cacheable, depending on the provided policy or whether a TTL (time-to-live) is set.

  • If policy="persist" (default), the key will remain in the store until explicitly deleted.

  • If policy="evict", the key may be evicted by the system or manually removed using clear_cache().

  • If a TTL is provided, the key is always treated as policy="evict".

Parameters:
  • store_name – the name of the store

  • key – the key to set

  • value – the value to set

  • ttl (None) – an optional TTL in seconds

  • policy (persist) – the eviction policy for the key. Can be “persist” or “evict”. If “persist”, the key will never be automatically removed. If “evict”, the key may be removed automatically if a TTL is set, or manually via clear_cache().

Returns:

The created or updated key document.

Return type:

KeyDocument

set_cache_key(store_name: str, key: str, value: Any, ttl: int | None = None) KeyDocument#

Sets the value of a cache key in the specified store.

Parameters:
  • store_name – the name of the store

  • key – the key to set

  • value – the value to set

  • ttl (None) – an optional TTL in seconds

has_key(store_name: str, key: str) bool#

Determines whether the specified key exists in the specified store.

Parameters:
  • store_name – the name of the store

  • key – the key to check

get_key(store_name: str, key: str) KeyDocument#

Retrieves the value of a key from the specified store.

Parameters:
  • store_name – the name of the store

  • key – the key to retrieve

Returns:

a fiftyone.store.models.KeyDocument

delete_key(store_name: str, key: str) bool#

Deletes the specified key from the store.

Parameters:
  • store_name – the name of the store

  • key – the key to delete

Returns:

True if the key was deleted, False otherwise

update_ttl(store_name: str, key: str, new_ttl: int) KeyDocument#

Updates the TTL of the specified key in the store.

Parameters:
  • store_name – the name of the store

  • key – the key to update the TTL for

  • new_ttl – the new TTL in seconds

Returns:

a fiftyone.store.models.KeyDocument

list_keys(store_name: str) list[str]#

Lists all keys in the specified store.

Parameters:

store_name – the name of the store

Returns:

a list of keys in the store

count_keys(store_name: str) int#

Counts the keys in the specified store.

Parameters:

store_name – the name of the store

Returns:

the number of keys in the store

cleanup() None#

Deletes all stores associated with the current context.

has_store_global(store_name) bool#

Determines whether a store with the given name exists across all datasets and the global context.

Parameters:

store_name – the name of the store

Returns:

True/False

list_stores_global() list[StoreDocument]#

Lists the stores across all datasets and the global context.

Returns:

a list of fiftyone.store.models.StoreDocument

count_stores_global() int#

Counts the stores across all datasets and the global context.

Returns:

the number of stores

delete_store_global(store_name) int#

Deletes the specified store across all datasets and the global context.

Parameters:

store_name – the name of the store

Returns:

the number of stores deleted