From a7d6a84a8f0f14f3def1bd6a0a6faf5a99ef0936 Mon Sep 17 00:00:00 2001 From: Alex Dunn Date: Fri, 8 Sep 2023 13:51:04 -0700 Subject: [PATCH] fix hacky lambdas --- src/pds/registrysweepers/utils/db/__init__.py | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/pds/registrysweepers/utils/db/__init__.py b/src/pds/registrysweepers/utils/db/__init__.py index 5aa1d3a..77dedb4 100644 --- a/src/pds/registrysweepers/utils/db/__init__.py +++ b/src/pds/registrysweepers/utils/db/__init__.py @@ -51,16 +51,21 @@ def query_registry_db( scroll_id = None while more_data_exists: if scroll_id is None: - fetch_func = lambda: client.search( # noqa: E731 - index=index_name, - body=query, - scroll=scroll_keepalive, - size=page_size, - _source_includes=_source.get("includes", []), # TODO: Break out from the enclosing _source object - _source_excludes=_source.get("excludes", []), # TODO: Break out from the enclosing _source object - ) + + def fetch_func(): + return client.search( + index=index_name, + body=query, + scroll=scroll_keepalive, + size=page_size, + _source_includes=_source.get("includes", []), # TODO: Break out from the enclosing _source object + _source_excludes=_source.get("excludes", []), # TODO: Break out from the enclosing _source object + ) + else: - fetch_func = lambda: client.scroll(scroll_id=scroll_id, scroll=scroll_keepalive) # noqa: E731, B023 + + def fetch_func(_scroll_id: str = scroll_id): + return client.scroll(scroll_id=_scroll_id, scroll=scroll_keepalive) results = retry_call( fetch_func,