From 381e95ba9fbe1d769bd4ebea2d46f6f9f47d5b11 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Sat, 28 Nov 2026 12:10:20 -0600 Subject: [PATCH] misc cleanups (#39501) --- openpilot/selfdrive/test/update_ci_routes.py | 6 +++--- openpilot/tools/lib/azure_container.py | 15 +++++++++++---- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/openpilot/selfdrive/test/update_ci_routes.py b/openpilot/selfdrive/test/update_ci_routes.py index 40f74ee93c..3d79c70283 100755 --- a/openpilot/selfdrive/test/update_ci_routes.py +++ b/openpilot/selfdrive/test/update_ci_routes.py @@ -32,18 +32,18 @@ def upload_route(path: str, exclude_patterns: Iterable[str] | None = None) -> No def sync_to_ci_public(route: str) -> bool: - dest_container, dest_key = DEST.get_client_and_key() key_prefix = route.replace('|', '/') dongle_id = key_prefix.split('/')[0] - if next(dest_container.list_blob_names(name_starts_with=key_prefix), None) is not None: + if DEST.has_prefix(key_prefix): return True + dest_key = DEST.sas() print(f"Uploading {route}") for source_container in SOURCES: # assumes az login has been run print(f"Trying {source_container.ACCOUNT}/{source_container.CONTAINER}") - _, source_key = source_container.get_client_and_key() + source_key = source_container.sas() cmd = [ "azcopy", "copy", diff --git a/openpilot/tools/lib/azure_container.py b/openpilot/tools/lib/azure_container.py index 7ba2e1515f..b279b32974 100644 --- a/openpilot/tools/lib/azure_container.py +++ b/openpilot/tools/lib/azure_container.py @@ -47,11 +47,18 @@ class AzureContainer: def BASE_URL(self) -> str: return f"{self.ACCOUNT_URL}/{self.CONTAINER}/" - def get_client_and_key(self): + def _client(self): from azure.storage.blob import ContainerClient - client = ContainerClient(self.ACCOUNT_URL, self.CONTAINER, credential=get_azure_credential()) - key = get_container_sas(self.ACCOUNT, self.CONTAINER) - return client, key + return ContainerClient(self.ACCOUNT_URL, self.CONTAINER, credential=get_azure_credential()) + + def sas(self) -> str: + return get_container_sas(self.ACCOUNT, self.CONTAINER) + + def has_prefix(self, prefix: str) -> bool: + return next(self._client().list_blob_names(name_starts_with=prefix), None) is not None + + def get_client_and_key(self): + return self._client(), self.sas() def get_url(self, route_name: str, segment_num: str, filename: str) -> str: return self.BASE_URL + f"{route_name.replace('|', '/')}/{segment_num}/{filename}"