From 8c1f6d1f988e03bbf8b4039107935e4a500c894b Mon Sep 17 00:00:00 2001 From: Patrick Huck Date: Fri, 6 Dec 2024 16:48:02 -0800 Subject: [PATCH] auto-fallback on db if s3 not avail --- mp_api/client/core/client.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/mp_api/client/core/client.py b/mp_api/client/core/client.py index b37ba04e..5a98e101 100644 --- a/mp_api/client/core/client.py +++ b/mp_api/client/core/client.py @@ -468,8 +468,6 @@ def _query_resource( } ) and num_chunks is None - and "substrates" not in self.suffix - and "phonon" not in self.suffix ) if fields: @@ -506,11 +504,22 @@ def _query_resource( keys = [] for page in pages: - for obj in page["Contents"]: + for obj in page.get("Contents", []): key = obj.get("Key") if key: keys.append(key) + if len(keys) < 1: + self._submit_requests( + url=url, + criteria=criteria, + use_document_model=use_document_model, + parallel_param=parallel_param, + num_chunks=num_chunks, + chunk_size=chunk_size, + timeout=timeout, + ) + decoder = ( MontyDecoder().decode if self.monty_decode else json_util.loads )