kazu.krt.resource_manager

Classes

ResourceManager

The ResourceManager class is responsible for managing resources in the streamlit application.

class kazu.krt.resource_manager.ResourceManager[source]

Bases: object

The ResourceManager class is responsible for managing resources in the streamlit application.

It manages the global state of all OntologyStringResources. It is also responsible for saving and updates to these resources in the configured model pack.

__init__(parsers)[source]

Initializes the ResourceManager instance.

Sets up dictionaries for managing resources and parsers, and loads resources from each parser.

Parameters:

parsers (Iterable[OntologyParser])

Return type:

None

clear_invalid_caches()[source]
Return type:

None

delete_resource(resource, parser_name)[source]

Deletes a resource from the internal state.

Parameters:
  • resource (OntologyStringResource) – The resource to be deleted.

  • parser_name (str) – The name of the parser that is handling the resource.

Returns:

Return type:

None

load_cache_state_aware_pipeline()[source]
Return type:

Pipeline

parser_count()[source]

Returns the number of parsers loaded by the ResourceManager instance.

Returns:

Return type:

int

save()[source]

Saves updated resources to the model pack.

Returns:

Return type:

Iterable[str]

sync_resources(original_resource, new_resource, parser_name)[source]

Synchronizes resources within the internal state.

If an original resource is provided, it is removed from the resource dictionaries and the new resource is added. If no original resource is provided, only the new resource is added. Note that no action is taken if original_resource == new_resource

Parameters:
  • original_resource (OntologyStringResource | None) – The original resource to be replaced. If None, no resource is replaced.

  • new_resource (OntologyStringResource) – The new resource to be added.

  • parser_name (str) – The name of the parser that is handling the resource.

Returns:

Return type:

None