kazu.krt.resource_manager¶
Classes
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
OntologyStringResource
s. 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
- 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
- parser_count()[source]¶
Returns the number of parsers loaded by the ResourceManager instance.
- Returns:
- Return type:
- 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