From f0d273fc0c88b233b5a1ca277122ee9011a2000e Mon Sep 17 00:00:00 2001 From: Max Halford Date: Wed, 9 Oct 2024 13:03:29 +0200 Subject: [PATCH] Fix test logic --- lea/clients/bigquery.py | 5 +---- lea/runner.py | 20 ++++++++++++-------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/lea/clients/bigquery.py b/lea/clients/bigquery.py index e2d9460..442fb23 100644 --- a/lea/clients/bigquery.py +++ b/lea/clients/bigquery.py @@ -150,10 +150,7 @@ def read_sql(self, query: str) -> pd.DataFrame: return pandas_gbq.read_gbq( query, credentials=self.client._credentials, - project_id=self.compute_project_id, - # project_id: the project to execute the job in - # NB: there is no option to specify the write project, so we need to correctly specify - # the project in the query. + project_id=self.write_project_id, location=self.location, progress_bar_type=None, ) diff --git a/lea/runner.py b/lea/runner.py index b475f12..6cd325e 100644 --- a/lea/runner.py +++ b/lea/runner.py @@ -425,7 +425,7 @@ def run( if job.error: at_least_one_error = True self.print(str(job.view), style="bold red") - self.print(job.error) + self.print(job.error, style="red") if at_least_one_error: return sys.exit(1) @@ -500,19 +500,23 @@ def test(self, select_views: list[str], freeze_unselected: bool, threads: int, f try: conflicts = job.result() except Exception as e: - print(f"Error in {test}") - print(e) - raise RuntimeError(f"Test {test} failed") + self.print(f"Error in {test}", style="bold red") + self.print(e, style="red") + at_least_one_error = True + if fail_fast and at_least_one_error: + for job in jobs: + job.cancel() + break if conflicts.empty: self.log(f"SUCCESS {test}", style="bold green") else: self.log(f"FAILURE {test}", style="bold red") self.log(conflicts.head()) at_least_one_error = True - if fail_fast: - for job in jobs: - job.cancel() - break + if fail_fast and at_least_one_error: + for job in jobs: + job.cancel() + break if at_least_one_error: return sys.exit(1)