From f2ceb9f88d21ad13ffdb4b5ecc640e2fa894cb12 Mon Sep 17 00:00:00 2001 From: Shuchang Zheng Date: Tue, 25 Jun 2024 10:21:28 -0700 Subject: [PATCH] make log_exception optional for s3 file download - there are expected cases when the file is not there and the function returns None (#511) --- skyvern/forge/sdk/api/aws.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/skyvern/forge/sdk/api/aws.py b/skyvern/forge/sdk/api/aws.py index dae777c9..9a9c8061 100644 --- a/skyvern/forge/sdk/api/aws.py +++ b/skyvern/forge/sdk/api/aws.py @@ -65,13 +65,14 @@ class AsyncAWSClient: LOG.exception("S3 upload failed.", uri=uri) @execute_with_async_client(client_type=AWSClientType.S3) - async def download_file(self, uri: str, client: AioBaseClient = None) -> bytes | None: + async def download_file(self, uri: str, client: AioBaseClient = None, log_exception: bool = True) -> bytes | None: try: parsed_uri = S3Uri(uri) response = await client.get_object(Bucket=parsed_uri.bucket, Key=parsed_uri.key) return await response["Body"].read() except Exception: - LOG.exception("S3 download failed", uri=uri) + if log_exception: + LOG.exception("S3 download failed", uri=uri) return None @execute_with_async_client(client_type=AWSClientType.S3)