ADLDownloader Class
Download remote file(s) using chunks and threads
Launches multiple threads for efficient downloading, with chunksize assigned to each. The remote path can be a single file, a directory of files or a glob pattern.
- Inheritance
-
builtins.objectADLDownloader
Constructor
ADLDownloader(adlfs, rpath, lpath, nthreads=None, chunksize=268435456, buffersize=4194304, blocksize=4194304, client=None, run=True, overwrite=False, verbose=False, progress_callback=None, timeout=0)
Parameters
- adlfs
- <xref:<xref:ADL filesystem instance>>
- rpath
- str
remote path/globstring to use to find remote files. Recursive glob patterns using **** are not supported.
- lpath
- str
local path. If downloading a single file, will write to this specific file, unless it is an existing directory, in which case a file is created within it. If downloading multiple files, this is the root directory to write within. Will create directories as required.
- chunksize
- int[<xref:228>]
Number of bytes for a chunk. Large files are split into chunks. Files smaller than this number will always be transferred in a single thread.
- buffersize
- int[<xref:222>]
Ignored in curret implementation. Number of bytes for internal buffer. This block cannot be bigger than a chunk and cannot be smaller than a block.
- blocksize
- int[<xref:222>]
Number of bytes for a block. Within each chunk, we write a smaller block for each API call. This block cannot be bigger than a chunk.
- client
- ADLTransferClient[None]
Set an instance of ADLTransferClient when finer-grained control over transfer parameters is needed. Ignores nthreads and chunksize set by constructor.
Whether to forcibly overwrite existing files/directories. If False and local path is a directory, will quit regardless if any files would be overwritten or not. If True, only matching filenames are actually overwritten.
Callback for progress with signature function(current, total) where current is the number of bytes transfered so far, and total is the size of the blob, or None if the total size is unknown.
- timeout
- int(<xref:0>)
Default value 0 means infinite timeout. Otherwise time in seconds before the process will stop and raise an exception if transfer is still in progress
- timeout
Methods
| active |
Return whether the downloader is active |
| clear_saved |
Remove references to all persisted downloads. |
| load |
Load list of persisted transfers from disk, for possible resumption. |
| run |
Populate transfer queue and execute downloads |
| save |
Persist this download Saves a copy of this transfer process in its current state to disk. This is done automatically for a running transfer, so that as a chunk is completed, this is reflected. Thus, if a transfer is interrupted, e.g., by user action, the transfer can be restarted at another time. All chunks that were not already completed will be restarted at that time. See methods |
| successful |
Return whether the downloader completed successfully. It will raise AssertionError if the downloader is active. |
active
Return whether the downloader is active
active()
clear_saved
Remove references to all persisted downloads.
static clear_saved()
load
Load list of persisted transfers from disk, for possible resumption.
static load()
Returns
A dictionary of download instances. The hashes are auto-
generated unique. The state of the chunks completed, errored, etc.,
can be seen in the status attribute. Instances can be resumed with
run().
run
Populate transfer queue and execute downloads
run(nthreads=None, monitor=True)
Parameters
save
Persist this download
Saves a copy of this transfer process in its current state to disk. This is done automatically for a running transfer, so that as a chunk is completed, this is reflected. Thus, if a transfer is interrupted, e.g., by user action, the transfer can be restarted at another time. All chunks that were not already completed will be restarted at that time.
See methods load to retrieved saved transfers and run to
resume a stopped transfer.
save(keep=True)
Parameters
successful
Return whether the downloader completed successfully.
It will raise AssertionError if the downloader is active.
successful()
Attributes
hash
Feedback
Submit and view feedback for