Skip to content

Commit

Permalink
MAINT: fix dependency graph retrieval
Browse files Browse the repository at this point in the history
  • Loading branch information
jotelha committed Nov 11, 2024
1 parent 75fc51e commit 654ea6e
Showing 1 changed file with 32 additions and 4 deletions.
36 changes: 32 additions & 4 deletions dtool_lookup_gui/utils/dependency_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand All @@ -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
Expand All @@ -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)

Expand Down Expand Up @@ -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

0 comments on commit 654ea6e

Please sign in to comment.