@@ -423,47 +423,34 @@ async def async_put_raw_data(
423423 r = await self ._put (from_path , to_path , ** kwargs )
424424 return r or to_path
425425
426+ # See https://github.com/fsspec/s3fs/issues/871 for more background and pending work on the fsspec side to
427+ # support effectively async open(). For now these use-cases below will revert to sync calls.
426428 # raw bytes
427429 if isinstance (lpath , bytes ):
428- fs = await self .get_async_filesystem_for_path (to_path )
429- if isinstance (fs , AsyncFileSystem ):
430- async with fs .open_async (to_path , "wb" , ** kwargs ) as s :
431- s .write (lpath )
432- else :
433- with fs .open (to_path , "wb" , ** kwargs ) as s :
434- s .write (lpath )
435-
430+ fs = self .get_filesystem_for_path (to_path )
431+ with fs .open (to_path , "wb" , ** kwargs ) as s :
432+ s .write (lpath )
436433 return to_path
437434
438435 # If lpath is a buffered reader of some kind
439436 if isinstance (lpath , io .BufferedReader ) or isinstance (lpath , io .BytesIO ):
440437 if not lpath .readable ():
441438 raise FlyteAssertion ("Buffered reader must be readable" )
442- fs = await self .get_async_filesystem_for_path (to_path )
439+ fs = self .get_filesystem_for_path (to_path )
443440 lpath .seek (0 )
444- if isinstance (fs , AsyncFileSystem ):
445- async with fs .open_async (to_path , "wb" , ** kwargs ) as s :
446- while data := lpath .read (read_chunk_size_bytes ):
447- s .write (data )
448- else :
449- with fs .open (to_path , "wb" , ** kwargs ) as s :
450- while data := lpath .read (read_chunk_size_bytes ):
451- s .write (data )
441+ with fs .open (to_path , "wb" , ** kwargs ) as s :
442+ while data := lpath .read (read_chunk_size_bytes ):
443+ s .write (data )
452444 return to_path
453445
454446 if isinstance (lpath , io .StringIO ):
455447 if not lpath .readable ():
456448 raise FlyteAssertion ("Buffered reader must be readable" )
457- fs = await self .get_async_filesystem_for_path (to_path )
449+ fs = self .get_filesystem_for_path (to_path )
458450 lpath .seek (0 )
459- if isinstance (fs , AsyncFileSystem ):
460- async with fs .open_async (to_path , "wb" , ** kwargs ) as s :
461- while data_str := lpath .read (read_chunk_size_bytes ):
462- s .write (data_str .encode (encoding ))
463- else :
464- with fs .open (to_path , "wb" , ** kwargs ) as s :
465- while data_str := lpath .read (read_chunk_size_bytes ):
466- s .write (data_str .encode (encoding ))
451+ with fs .open (to_path , "wb" , ** kwargs ) as s :
452+ while data_str := lpath .read (read_chunk_size_bytes ):
453+ s .write (data_str .encode (encoding ))
467454 return to_path
468455
469456 raise FlyteAssertion (f"Unsupported lpath type { type (lpath )} " )
0 commit comments