fiftyone.operators.store¶
Module contents¶
Execution store.
Classes:
|
Service for managing execution store operations. |
|
Execution store. |
|
Model representing a Store. |
|
Model representing a key in the store. |
-
class
fiftyone.operators.store.
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
dataset_id (None) – a dataset ID to scope operations to
Methods:
create_store
(store_name[, metadata])Creates a new store with the specified name.
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])Sets the value of a 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) → 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
-
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) → fiftyone.operators.store.models.KeyDocument¶ Sets the value of a 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
- Returns
a
fiftyone.store.models.KeyDocument
-
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
-
class
fiftyone.operators.store.
ExecutionStore
(store_name: str, store_service: fiftyone.operators.store.service.ExecutionStoreService)¶ Bases:
object
Execution store.
- Parameters
store_name – the name of the store
store_service – an
fiftyone.operators.store.service.ExecutionStoreService
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])Sets a value in the store with an optional TTL.
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.
update_ttl
(key, new_ttl)Updates the TTL 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: Optional[bson.objectid.ObjectId] = None) → fiftyone.operators.store.store.ExecutionStore¶
-
list_stores
() → list¶ Lists all stores in the execution store.
- Returns
a list of store names
- Return type
list
-
get
(key: str) → Optional[Any]¶ 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: Optional[int] = None) → None¶ Sets a value in the store with an optional TTL.
- 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.
-
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
-
get_metadata
(key: str) → Optional[dict]¶ Retrieves the metadata for the given key.
- Parameters
key – the key to check
- Returns
a dict of metadata about the key
-
list_keys
() → list¶ Lists all keys in the store.
- Returns
a list of keys in the store
-
class
fiftyone.operators.store.
StoreDocument
(store_name: str, key: str = '__store__', value: Optional[dict] = None, _id: Optional[Any] = None, dataset_id: Optional[bson.objectid.ObjectId] = None, created_at: datetime.datetime = <factory>, updated_at: Optional[datetime.datetime] = None, expires_at: Optional[datetime.datetime] = None)¶ Bases:
fiftyone.operators.store.models.KeyDocument
Model representing a Store.
Attributes:
The metadata associated with the store.
Methods:
get_expiration
(ttl)Gets the expiration date for a key with the given TTL.
to_mongo_dict
([exclude_id])Serializes the document to a MongoDB dictionary.
-
key
: str = '__store__'¶
-
value
: Optional[dict] = None¶
-
property
metadata
¶ The metadata associated with the store.
-
dataset_id
: Optional[bson.objectid.ObjectId] = None¶
-
expires_at
: Optional[datetime.datetime] = None¶
-
static
get_expiration
(ttl: Optional[int]) → Optional[datetime.datetime]¶ Gets the expiration date for a key with the given TTL.
-
to_mongo_dict
(exclude_id: bool = True) → dict¶ Serializes the document to a MongoDB dictionary.
-
updated_at
: Optional[datetime.datetime] = None¶
-
store_name
: str¶
-
created_at
: datetime.datetime¶
-
-
class
fiftyone.operators.store.
KeyDocument
(store_name: str, key: str, value: Any, _id: Optional[Any] = None, dataset_id: Optional[bson.objectid.ObjectId] = None, created_at: datetime.datetime = <factory>, updated_at: Optional[datetime.datetime] = None, expires_at: Optional[datetime.datetime] = None)¶ Bases:
object
Model representing a key in the store.
Attributes:
Methods:
get_expiration
(ttl)Gets the expiration date for a key with the given TTL.
to_mongo_dict
([exclude_id])Serializes the document to a MongoDB dictionary.
-
store_name
: str¶
-
key
: str¶
-
value
: Any¶
-
dataset_id
: Optional[bson.objectid.ObjectId] = None¶
-
created_at
: datetime.datetime¶
-
updated_at
: Optional[datetime.datetime] = None¶
-
expires_at
: Optional[datetime.datetime] = None¶
-
static
get_expiration
(ttl: Optional[int]) → Optional[datetime.datetime]¶ Gets the expiration date for a key with the given TTL.
-
to_mongo_dict
(exclude_id: bool = True) → dict¶ Serializes the document to a MongoDB dictionary.
-