AsyncFileSystem
and SyncFileSystem
. Both classes enable you to download files uploaded by the user and to upload files created during flow execution. Files and folders uploaded by the user are located in a root folder /in
(input files). Files and folders created during flow execution which will be delivered back to the user are located in a root folder /out
(output files).
Feature | AsyncFileSystem | SyncFileSystem |
---|---|---|
Usage | Asynchronous functions (async def ) | Synchronous functions |
Performance | Non-blocking, better I/O performance | Blocking, easier to use |
Ray Remote Functions | Not compatible | Compatible |
Context Manager | async with | with |
Tracer
object:
SyncFileSystem
if you pass the tracer
object to a Ray remote function. This constraint is due to the fact that Ray remote functions do not support async execution.
AsyncFileSystem
and SyncFileSystem
support context managers for automatic resource cleanup:
ls()
method to list files and subfolders in the input or output directories:
download()
method allows you to download files uploaded by the user to a local temporary directory:
upload()
method allows you to upload files created during service execution to the output directory:
open()
method to create file streams for reading files. The streams support both read_all()
and read()
methods:
remove()
method to delete files and folders:
FileNotFoundError
: When trying to access a file or folder that doesn’t existRuntimeError
: When trying to use a closed stream or re-enter a stream context