fiftyone.operators.store.store#
Execution store class.
Classes:
|
Execution store. |
- class fiftyone.operators.store.store.ExecutionStore(store_name: str, store_service: ExecutionStoreService, default_policy: str = 'persist')#
Bases:
object
Execution store.
- Parameters:
store_name – the name of the store
store_service – an
fiftyone.operators.store.service.ExecutionStoreService
default_policy ("persist") – the default eviction policy for the store.
Methods:
create
(store_name[, dataset_id, ...])Lists all stores in the execution store.
get
(key)Retrieves a value from the store by its key.
set
(key, value[, ttl, policy])Sets the value of a key in the specified store.
set_cache
(key, value[, ttl])Sets a value in the store with the eviction policy set to "evict".
delete
(key)Deletes a key from the store.
has
(key)Checks if the store has a specific key.
clear
()Clears all the data in the store.
Clears the cache for the store.
update_ttl
(key, new_ttl)Updates the TTL for a specific key.
update_policy
(key, policy)Updates the eviction policy for a specific key.
get_metadata
(key)Retrieves the metadata for the given key.
Lists all keys in the store.
- static create(store_name: str, dataset_id: ObjectId | None = None, default_policy: str = 'persist', collection_name: str | None = None) ExecutionStore #
- list_stores() list[str] #
Lists all stores in the execution store.
- Returns:
a list of store names
- Return type:
list
- get(key: str) Any | None #
Retrieves a value from the store by its key.
- Parameters:
key – the key to retrieve the value for
- Returns:
the value stored under the given key, or None if not found
- set(key: str, value: Any, ttl: int | None = None, policy=None) None #
Sets the value of a key in the specified store.
- Parameters:
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:
a
fiftyone.store.models.KeyDocument
- set_cache(key: str, value: Any, ttl: int | None = None) None #
Sets a value in the store with the eviction policy set to “evict”.
- Parameters:
key – the key to store the value under
value – the value to store
ttl (None) – the time-to-live in seconds
- delete(key: str) bool #
Deletes a key from the store.
- Parameters:
key – the key to delete.
- Returns:
True/False whether the key was deleted
- has(key: str) bool #
Checks if the store has a specific key.
- Parameters:
key – the key to check
- Returns:
True/False whether the key exists
- clear() None #
Clears all the data in the store.
- clear_cache() None #
Clears the cache for the store.
This will remove all keys that are eligible for eviction.
- update_ttl(key: str, new_ttl: int) None #
Updates the TTL for a specific key.
- Parameters:
key – the key to update the TTL for
new_ttl – the new TTL in seconds
- update_policy(key: str, policy: str) None #
Updates the eviction policy for a specific key.
- Parameters:
key – the key to update the policy for
policy – the new policy, either “persist” or “evict”
- get_metadata(key: str) dict | None #
Retrieves the metadata for the given key.
- Parameters:
key – the key to check
- Returns:
a dict of metadata about the key
- list_keys() list[str] #
Lists all keys in the store.
- Returns:
a list of keys in the store