File tree Expand file tree Collapse file tree 2 files changed +11
-11
lines changed
Expand file tree Collapse file tree 2 files changed +11
-11
lines changed Original file line number Diff line number Diff line change 2323
2424
2525@asyncify
26- def upload_file (file : Path | str , key : str ):
26+ def upload_file (file : Path | str , key : str ) -> str :
2727 client .upload_file (
2828 Bucket = BUCKET ,
29- File = str (file ),
29+ Filename = str (file ),
3030 Key = key ,
3131 )
3232 return client .generate_presigned_url (
@@ -50,10 +50,10 @@ def upload_json(data: t.Any, key: str) -> str:
5050 )
5151
5252
53- async def upload_files (
54- dir : str ,
55- files : list [ Path | str ],
56- ) -> dict [ str , str ]:
57- keys = [ f" { dir } / { Path ( f ). name } " for f in files ]
58- urls = await asyncio . gather ( * [ upload_file ( f , k ) for f , k in zip ( files , keys )] )
59- return dict (zip (keys , urls ))
53+ async def upload_files (dir : str , files : list [ Path | str ]) -> dict [ str , str ]:
54+ filenames = [ Path ( f ). name for f in files ]
55+ object_keys = [ f" { dir } / { n } " for n in filenames ]
56+ presigned_urls = await asyncio . gather (
57+ * [ upload_file ( f , k ) for f , k in zip ( files , object_keys ) ]
58+ )
59+ return dict (zip (filenames , presigned_urls ))
Original file line number Diff line number Diff line change @@ -48,14 +48,14 @@ async def perform(ctx: KernelContext, params: dict):
4848
4949 trajectory = await agent .run (max_steps = request .max_steps )
5050
51- ( downloads ,) = await asyncio .gather (
51+ uploads = await asyncio .gather (
5252 upload_files (dir = session , files = downloaded_files (agent )),
5353 upload_json (trajectory .model_dump (), key = f"{ session } /trajectory.json" ),
5454 )
5555
5656 response = BrowserAgentResponse .from_run (
5757 trajectory ,
5858 session = session ,
59- downloads = downloads ,
59+ downloads = uploads [ 0 ] ,
6060 )
6161 return response .model_dump ()
You can’t perform that action at this time.
0 commit comments