From cd4cd6505989cf6139078d0d958b4ded2b95fa3c Mon Sep 17 00:00:00 2001 From: Ee Durbin Date: Sat, 18 Jan 2025 11:34:14 -0500 Subject: [PATCH] optimization: only fetch bigquery schemas once per run in sync_bigquery_release_files (#17451) --- warehouse/packaging/tasks.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/warehouse/packaging/tasks.py b/warehouse/packaging/tasks.py index a1b794dd0edd..c05618b8bcb0 100644 --- a/warehouse/packaging/tasks.py +++ b/warehouse/packaging/tasks.py @@ -375,13 +375,17 @@ def sync_bigquery_release_files(request): request.tm.commit() request.tm.begin() + table_schemas = { + table_name: bq.get_table(table_name).schema for table_name in table_names + } + for missing_file in missing_files: # Add the objects back into the new session request.db.add(missing_file) release_file = missing_file.file for table_name in table_names: - table_schema = bq.get_table(table_name).schema + table_schema = table_schemas[table_name] # Using the schema to populate the data allows us to automatically # set the values to their respective fields rather than assigning