composer.utils.file_retriever#
Utility for retrieving files.
Functions
Get a file from a local folder, URL, or object store. |
Exceptions
Exception if |
- exception composer.utils.file_retriever.GetFileNotFoundException[source]#
Bases:
RuntimeError
Exception if
get_file()
failed due to a not found error.
- composer.utils.file_retriever.get_file(path, destination, object_store=None, chunk_size=1048576, progress_bar=True)[source]#
Get a file from a local folder, URL, or object store.
- Parameters
path (str) โ
The path to the file to retreive.
If
object_store
is specified, then thepath
should be the object name for the file to get. Do not include the the cloud provider or bucket name.If
object_store
is not specified but thepath
begins withhttp://
orhttps://
, the object at this URL will be downloaded.Otherwise,
path
is presumed to be a local filepath.
destination (str) โ
The destination filepath.
If
path
is a local filepath, then a symlink topath
atdestination
will be created. Otherwise,path
will be downloaded to a file atdestination
.object_store (ObjectStoreProvider, optional) โ
An
ObjectStoreProvider
, ifpath
is located inside an object store (i.e. AWS S3 or Google Cloud Storage). (default:None
)This
ObjectStoreProvider
instance will be used to retreive the file. Thepath
parameter should be set to the object name within the object store.Set this parameter to
None
(the default) ifpath
is a URL or a local file.chunk_size (int, optional) โ Chunk size (in bytes). Ignored if
path
is a local file. (default: 1MB)progress_bar (bool, optional) โ Whether to show a progress bar. Ignored if
path
is a local file. (default:True
)
- Raises
GetFileNotFoundException โ If the
path
does not exist, aGetFileNotFoundException
exception will be raised.