1- from pathlib import Path
21from typing import TYPE_CHECKING , Any , TypeVar
32
43from aiobotocore .session import get_session
@@ -35,7 +34,7 @@ def __init__(
3534 """
3635 Constructs a new S3 result backend.
3736
38- :param bucket_name: name of the bucket on S3 .
37+ :param bucket: S3 bucket configuration .
3938 :param base_path: base path for results.
4039 :param endpoint_url: endpoint URL for S3.
4140 :param aws_region_name: AWS region, default is 'us-east-1'.
@@ -112,7 +111,7 @@ async def set_result(
112111 :param result: result of execution.
113112 """
114113 if self ._base_path :
115- task_id = str ( Path ( self ._base_path ) / task_id )
114+ task_id = f" { self ._base_path . rstrip ( '/' ) } / { task_id } "
116115
117116 await self ._s3_client .put_object (
118117 Bucket = self ._bucket .name ,
@@ -137,7 +136,7 @@ async def get_result(
137136 """
138137 result = None
139138 if self ._base_path :
140- task_id = str ( Path ( self ._base_path ) / task_id )
139+ task_id = f" { self ._base_path . rstrip ( '/' ) } / { task_id } "
141140 try :
142141 if response := await self ._s3_client .get_object (
143142 Bucket = self ._bucket .name ,
@@ -171,7 +170,7 @@ async def is_result_ready(self, task_id: str) -> bool:
171170 :return: True if result is ready.
172171 """
173172 if self ._base_path :
174- task_id = str ( Path ( self ._base_path ) / task_id )
173+ task_id = f" { self ._base_path . rstrip ( '/' ) } / { task_id } "
175174 try :
176175 if await self ._s3_client .head_object (Bucket = self ._bucket .name , Key = task_id ):
177176 return True
0 commit comments