in upload.py [0:0]
def upload(prod: bool,
data_date: date,
ping_ndjson: tuple[typing.IO[bytes], typing.Optional[int]],
config_ndjson: tuple[typing.IO[bytes], int]):
client = make_client(prod)
tables = list(client.list_tables(DATASET))
if not any(x.table_id == TABLE_NAME for x in tables):
create_table(client)
if not any(x.table_id == CONFIG_TABLE_NAME for x in tables):
create_config_table(client)
update_table_schema(client, TABLE_NAME, TABLE_SCHEMA)
update_table_schema(client, CONFIG_TABLE_NAME, CONFIG_TABLE_SCHEMA)
# We may fail due to concurrent updates by other tasks (if a batch of tasks is started); just keep retrying for a while.
retries = 30
while not try_upload(client, data_date, ping_ndjson, config_ndjson):
time.sleep(random.randint(1, 5) * 30)
retries -= 1
if retries == 0:
raise RuntimeError("aborted due to concurrent update; retries exhausted")