From 5907b3bb71cda9207c3e226b616734c18ab4d621 Mon Sep 17 00:00:00 2001 From: Edmund Yan Date: Fri, 8 Nov 2019 11:43:07 -0500 Subject: [PATCH 1/3] Skip explores with no dimensions --- spectacles/validators.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/spectacles/validators.py b/spectacles/validators.py index 263002ec..5acbb5ea 100644 --- a/spectacles/validators.py +++ b/spectacles/validators.py @@ -239,10 +239,11 @@ def _query(self, mode: str = "batch") -> List[SqlError]: for explore in model.explores: if mode == "batch" or (mode == "hybrid" and not explore.queried): logger.debug("Querying one explore at at time") - task = loop.create_task( - self._query_explore(session, model, explore) - ) - tasks.append(task) + if explore.dimensions: + task = loop.create_task( + self._query_explore(session, model, explore) + ) + tasks.append(task) elif mode == "single" or (mode == "hybrid" and explore.errored): logger.debug("Querying one dimension at at time") for dimension in explore.dimensions: From 0c71a0c7fcb413d6d0c04beb57dd79653a5759b2 Mon Sep 17 00:00:00 2001 From: Edmund Yan Date: Sat, 9 Nov 2019 12:41:27 -0500 Subject: [PATCH 2/3] Move conditional higher to skip other query modes --- spectacles/validators.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/spectacles/validators.py b/spectacles/validators.py index 5acbb5ea..2cf5df5d 100644 --- a/spectacles/validators.py +++ b/spectacles/validators.py @@ -237,20 +237,20 @@ def _query(self, mode: str = "batch") -> List[SqlError]: tasks = [] for model in self.project.models: for explore in model.explores: - if mode == "batch" or (mode == "hybrid" and not explore.queried): - logger.debug("Querying one explore at at time") - if explore.dimensions: + if explore.dimensions: + if mode == "batch" or (mode == "hybrid" and not explore.queried): + logger.debug("Querying one explore at at time") task = loop.create_task( self._query_explore(session, model, explore) ) tasks.append(task) - elif mode == "single" or (mode == "hybrid" and explore.errored): - logger.debug("Querying one dimension at at time") - for dimension in explore.dimensions: - task = loop.create_task( - self._query_dimension(session, model, explore, dimension) - ) - tasks.append(task) + elif mode == "single" or (mode == "hybrid" and explore.errored): + logger.debug("Querying one dimension at at time") + for dimension in explore.dimensions: + task = loop.create_task( + self._query_dimension(session, model, explore, dimension) + ) + tasks.append(task) query_task_ids = list(loop.run_until_complete(asyncio.gather(*tasks))) loop.run_until_complete(session.close()) From 17045bc7969573792ebb59938e52f878a32c1288 Mon Sep 17 00:00:00 2001 From: Edmund Yan Date: Mon, 11 Nov 2019 11:25:24 -0500 Subject: [PATCH 3/3] Reindent to 4 spaces --- spectacles/validators.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/spectacles/validators.py b/spectacles/validators.py index 2cf5df5d..be6cd985 100644 --- a/spectacles/validators.py +++ b/spectacles/validators.py @@ -238,19 +238,19 @@ def _query(self, mode: str = "batch") -> List[SqlError]: for model in self.project.models: for explore in model.explores: if explore.dimensions: - if mode == "batch" or (mode == "hybrid" and not explore.queried): - logger.debug("Querying one explore at at time") - task = loop.create_task( - self._query_explore(session, model, explore) - ) - tasks.append(task) - elif mode == "single" or (mode == "hybrid" and explore.errored): - logger.debug("Querying one dimension at at time") - for dimension in explore.dimensions: - task = loop.create_task( - self._query_dimension(session, model, explore, dimension) - ) - tasks.append(task) + if mode == "batch" or (mode == "hybrid" and not explore.queried): + logger.debug("Querying one explore at at time") + task = loop.create_task( + self._query_explore(session, model, explore) + ) + tasks.append(task) + elif mode == "single" or (mode == "hybrid" and explore.errored): + logger.debug("Querying one dimension at at time") + for dimension in explore.dimensions: + task = loop.create_task( + self._query_dimension(session, model, explore, dimension) + ) + tasks.append(task) query_task_ids = list(loop.run_until_complete(asyncio.gather(*tasks))) loop.run_until_complete(session.close())