hoops_ai.storage.datastorage.data_storage_handler_base

Classes

DataStorage()

class hoops_ai.storage.datastorage.data_storage_handler_base.DataStorage

Bases: ABC

abstract close()

Handles any necessary cleanup or resource deallocation.

Return type:

None

compress_store()
Return type:

int

abstract format()

a string spcifying the concrete format for this storage.

Return type:

str

abstract get_file_path(data_key)

Retrieves the file path for a given data key.

Parameters:

data_key (str) – The data key.

Returns:

The file path corresponding to the data key.

Return type:

str

get_group_for_array(array_name)

Determines which group an array belongs to based on the schema.

Parameters:

array_name (str) – Name of the array

Returns:

Group name for the array, or None if not found in schema

Return type:

str

abstract get_keys()

Retrieves a list of all keys in the storage. :returns: A list of all keys in the storage. :rtype: list

Return type:

list

get_schema()

Retrieves the schema definition for this storage instance.

Returns:

The schema definition, or empty dict if no schema is set

Return type:

dict

abstract load_data(data_key)

Loads data associated with a specific key.

Parameters:

data_key (str) – The key of the data to load.

Returns:

The loaded data.

Return type:

Any

abstract load_metadata(key)

Loads metadata associated with a specific key.

Parameters:

key (str) – The metadata key.

Returns:

The loaded metadata value.

Return type:

Any

abstract save_data(data_key, data)

Saves data associated with a specific key.

Parameters:
  • data_key (str) – The key under which to store the data.

  • data (Any) – The data to store.

Return type:

None

abstract save_metadata(key, value)

Saves metadata as a key-value pair into the metadata JSON file. If the file doesn’t exist, it will be created.

Parameters:
  • key (str) – The metadata key.

  • value (Any) – The metadata value (bool, int, float, string, list, or array).

Return type:

None

set_schema(schema)

Sets a schema definition for this storage instance. The schema defines how arrays should be organized into groups for merging.

Parameters:

schema (dict) – Schema definition containing group and array specifications

Return type:

None

validate_data_against_schema(data_key, data)

Validates data against the stored schema if present.

Parameters:
  • data_key (str) – The key under which the data will be stored

  • data (Any) – The data to validate

Returns:

True if valid or no schema present, False if validation fails

Return type:

bool