download_if_needed#
- download_if_needed(uri: str, download_dir: str | None = None, fs: rastervision.pipeline.file_system.file_system.FileSystem | None = None, use_cache: bool = True) str [source]#
Download a file into a directory if it’s remote.
If uri is local, there is no need to download the file.
- Parameters:
uri (str) – URI of file to download.
download_dir (str | None) – Local directory to download file into. If None, the file will be downloaded to cache dir as defined by RVConfig. Defaults to None.
fs (FileSystem | None) – If provided, use fs instead of the automatically chosen FileSystem for uri. Defaults to None.
use_cache (bool) – If False and the file is remote, download it regardless of whether it exists in cache. Defaults to True.
- Returns:
Path to local file.
- Return type:
- Raises:
NotReadableError if URI cannot be read from –