Metadata Stores#
ragbits.core.metadata_stores.base.MetadataStore
#
Bases: WithConstructionConfig
, ABC
An abstract class for metadata storage. Allows to store, query and retrieve metadata in form of key value pairs.
configuration_key
class-attribute
instance-attribute
#
subclass_from_config
classmethod
#
Initializes the class with the provided configuration. May return a subclass of the class, if requested by the configuration.
PARAMETER | DESCRIPTION |
---|---|
config |
A model containing configuration details for the class.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Self
|
An instance of the class initialized with the provided configuration. |
RAISES | DESCRIPTION |
---|---|
InvalidConfigError
|
The class can't be found or is not a subclass of the current class. |
Source code in packages/ragbits-core/src/ragbits/core/utils/config_handling.py
subclass_from_factory
classmethod
#
Creates the class using the provided factory function. May return a subclass of the class, if requested by the factory.
PARAMETER | DESCRIPTION |
---|---|
factory_path |
A string representing the path to the factory function in the format of "module.submodule:factory_name".
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Self
|
An instance of the class initialized with the provided factory function. |
RAISES | DESCRIPTION |
---|---|
InvalidConfigError
|
The factory can't be found or the object returned is not a subclass of the current class. |
Source code in packages/ragbits-core/src/ragbits/core/utils/config_handling.py
preferred_subclass
classmethod
#
preferred_subclass(config: CoreConfig, factory_path_override: str | None = None, yaml_path_override: Path | None = None) -> Self
Tries to create an instance by looking at project's component prefferences, either from YAML or from the factory. Takes optional overrides for both, which takes a higher precedence.
PARAMETER | DESCRIPTION |
---|---|
config |
The CoreConfig instance containing preferred factory and configuration details.
TYPE:
|
factory_path_override |
A string representing the path to the factory function in the format of "module.submodule:factory_name".
TYPE:
|
yaml_path_override |
A string representing the path to the YAML file containing the Ragstack instance configuration.
TYPE:
|
RAISES | DESCRIPTION |
---|---|
InvalidConfigError
|
If the default factory or configuration can't be found. |
Source code in packages/ragbits-core/src/ragbits/core/utils/config_handling.py
from_config
classmethod
#
Initializes the class with the provided configuration.
PARAMETER | DESCRIPTION |
---|---|
config |
A dictionary containing configuration details for the class.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Self
|
An instance of the class initialized with the provided configuration. |
Source code in packages/ragbits-core/src/ragbits/core/utils/config_handling.py
store
abstractmethod
async
#
Store metadatas under ids in metadata store.
PARAMETER | DESCRIPTION |
---|---|
ids |
list of unique ids of the entries
TYPE:
|
metadatas |
list of dicts with metadata.
TYPE:
|
Source code in packages/ragbits-core/src/ragbits/core/metadata_stores/base.py
get
abstractmethod
async
#
Returns metadatas associated with a given ids.
PARAMETER | DESCRIPTION |
---|---|
ids |
list of ids to use.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[dict]
|
List of metadata dicts associated with a given ids. |
RAISES | DESCRIPTION |
---|---|
MetadataNotFoundError
|
If the metadata is not found. |
Source code in packages/ragbits-core/src/ragbits/core/metadata_stores/base.py
ragbits.core.metadata_stores.in_memory.InMemoryMetadataStore
#
Bases: MetadataStore
Metadata Store implemented in memory
Constructs a new InMemoryMetadataStore instance.
Source code in packages/ragbits-core/src/ragbits/core/metadata_stores/in_memory.py
configuration_key
class-attribute
instance-attribute
#
subclass_from_config
classmethod
#
Initializes the class with the provided configuration. May return a subclass of the class, if requested by the configuration.
PARAMETER | DESCRIPTION |
---|---|
config |
A model containing configuration details for the class.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Self
|
An instance of the class initialized with the provided configuration. |
RAISES | DESCRIPTION |
---|---|
InvalidConfigError
|
The class can't be found or is not a subclass of the current class. |
Source code in packages/ragbits-core/src/ragbits/core/utils/config_handling.py
subclass_from_factory
classmethod
#
Creates the class using the provided factory function. May return a subclass of the class, if requested by the factory.
PARAMETER | DESCRIPTION |
---|---|
factory_path |
A string representing the path to the factory function in the format of "module.submodule:factory_name".
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Self
|
An instance of the class initialized with the provided factory function. |
RAISES | DESCRIPTION |
---|---|
InvalidConfigError
|
The factory can't be found or the object returned is not a subclass of the current class. |
Source code in packages/ragbits-core/src/ragbits/core/utils/config_handling.py
preferred_subclass
classmethod
#
preferred_subclass(config: CoreConfig, factory_path_override: str | None = None, yaml_path_override: Path | None = None) -> Self
Tries to create an instance by looking at project's component prefferences, either from YAML or from the factory. Takes optional overrides for both, which takes a higher precedence.
PARAMETER | DESCRIPTION |
---|---|
config |
The CoreConfig instance containing preferred factory and configuration details.
TYPE:
|
factory_path_override |
A string representing the path to the factory function in the format of "module.submodule:factory_name".
TYPE:
|
yaml_path_override |
A string representing the path to the YAML file containing the Ragstack instance configuration.
TYPE:
|
RAISES | DESCRIPTION |
---|---|
InvalidConfigError
|
If the default factory or configuration can't be found. |
Source code in packages/ragbits-core/src/ragbits/core/utils/config_handling.py
from_config
classmethod
#
Initializes the class with the provided configuration.
PARAMETER | DESCRIPTION |
---|---|
config |
A dictionary containing configuration details for the class.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Self
|
An instance of the class initialized with the provided configuration. |
Source code in packages/ragbits-core/src/ragbits/core/utils/config_handling.py
store
async
#
Store metadatas under ids in metadata store.
PARAMETER | DESCRIPTION |
---|---|
ids |
list of unique ids of the entries
TYPE:
|
metadatas |
list of dicts with metadata.
TYPE:
|
Source code in packages/ragbits-core/src/ragbits/core/metadata_stores/in_memory.py
get
async
#
Returns metadatas associated with a given ids.
PARAMETER | DESCRIPTION |
---|---|
ids |
list of ids to use.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[dict]
|
List of metadata dicts associated with a given ids. |
RAISES | DESCRIPTION |
---|---|
MetadataNotFoundError
|
If the metadata is not found. |