fiftyone.operators.store.service¶
Execution store service.
Classes:
|
Service for managing execution store operations. |
-
class
fiftyone.operators.store.service.
ExecutionStoreService
(repo: Optional[ExecutionStoreRepo] = None, dataset_id: Optional[bson.objectid.ObjectId] = 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 arepo
associated with one), this instance operates on stores associated with that datasetIf no
dataset_id
is provided (or arepo
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
repo (None) – a
fiftyone.factory.repos.execution_store.ExecutionStoreRepo
If not provided, a newfiftyone.factory.repos.execution_store.MongoExecutionStoreRepo
will be createddataset_id (None) – a dataset ID to scope operations to
collection_name (None) – a collection name to use for the execution store. If repo is provided, this argument is ignored
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.
Lists all stores for the current context.
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.
Lists the stores across all datasets and the global context.
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: Optional[dict] = None, policy: str = 'persist') → fiftyone.operators.store.models.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) → fiftyone.operators.store.models.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¶ 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) → fiftyone.operators.store.models.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: Optional[int] = None, policy: str = 'persist') → fiftyone.operators.store.models.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 usingclear_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
-
set_cache_key
(store_name: str, key: str, value: Any, ttl: Optional[int] = None) → fiftyone.operators.store.models.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) → fiftyone.operators.store.models.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) → fiftyone.operators.store.models.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¶ 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¶ 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