From 654ea6eea36655bc57d1fef40315c7591e6a40d1 Mon Sep 17 00:00:00 2001 From: Johannes Laurin Hoermann Date: Mon, 11 Nov 2024 10:41:54 +0100 Subject: [PATCH] MAINT: fix dependency graph retrieval --- dtool_lookup_gui/utils/dependency_graph.py | 36 +++++++++++++++++++--- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/dtool_lookup_gui/utils/dependency_graph.py b/dtool_lookup_gui/utils/dependency_graph.py index 92e4cd0..ab1c737 100644 --- a/dtool_lookup_gui/utils/dependency_graph.py +++ b/dtool_lookup_gui/utils/dependency_graph.py @@ -26,9 +26,11 @@ import json import logging +from aiohttp.client_exceptions import ContentTypeError + from dtool_lookup_gui import is_uuid from dtool_lookup_gui.models.simple_graph import SimpleGraph - +from dtool_lookup_gui.models.search_state import SearchState logger = logging.getLogger(__name__) @@ -40,6 +42,8 @@ def _log_nested(log_func, dct): class DependencyGraph: def __init__(self): + self._search_state = SearchState() + self._reset_graph() self._reset_graph() @property @@ -63,7 +67,33 @@ async def trace_dependencies(self, lookup, root_uuid, dependency_keys=None): logger.warning("Dependency keys not valid. Ignored.") dependency_keys = None - datasets = await lookup.get_graph_by_uuid(uuid=root_uuid, dependency_keys=dependency_keys) + pagination = {} + try: + datasets = await lookup.get_graph_by_uuid(uuid=root_uuid, + dependency_keys=dependency_keys, + page_size=self._search_state.page_size, + pagination=pagination) + except ContentTypeError as exc: + logger.error("%s", exc) + return + + logger.debug("Got first batch of dependency graph datasets with pagination information '%s'.", pagination) + + self._search_state.ingest_pagination_information(pagination=pagination) + + for page in range(self._search_state.first_page+1, self._search_state.last_page+1): + try: + more_datasets = await lookup.get_graph_by_uuid(uuid=root_uuid, + dependency_keys=dependency_keys, + page_number=page, page_size=self._search_state.page_size, + pagination=pagination) + except ContentTypeError as exc: + logger.error("%s", exc) + return + logger.debug("Got batch #%s of dependency graph datasets with pagination information '%s'.", page, pagination) + if len(more_datasets) > 0: + datasets.extend(more_datasets) + logger.debug("Server response on querying dependency graph for UUID = {}.".format(root_uuid)) _log_nested(logger.debug, datasets) @@ -105,8 +135,6 @@ async def trace_dependencies(self, lookup, root_uuid, dependency_keys=None): dataset['name'])) logger.debug(f"Done building dependency graph for root '{root_uuid}'.") - - @property def missing_uuids(self): return self._missing_uuids \ No newline at end of file