download#

Mechanical.download(files, target_dir=None, chunk_size=262144, progress_bar=None, recursive=False)#

Download files from the working directory of the Mechanical instance.

It downloads them from the working directory to the target directory. It returns the list of local file paths for the downloaded files.

Parameters:
filesstr, list[str], tuple(str)

One or more files on the Mechanical server to download. The files must be in the same directory as the Mechanical instance. You can use the Mechanical.list_files function to list current files. Alternatively, you can specify glob expressions to match file names. For example, you could use file* to match every file whose name starts with file.

target_dir: str

Default directory to copy the downloaded files to. The default is None and current working directory will be used as target directory.

chunk_sizeint, optional

Chunk size in bytes. The default is 262144. The value must be less than 4 MB.

progress_barbool, optional

Whether to show a progress bar using tqdm. The default is None, in which case a progress bar is shown. A progress bar is helpful for viewing download progress.

recursivebool, optional

Whether to use recursion when using a glob pattern search. The default is False.

Returns:
List[str]

List of local file paths.

Notes

There are some considerations to keep in mind when using the download() method:

  • The glob pattern search does not search recursively in remote instances.

  • In a remote instance, it is not possible to list or download files in a location other than the Mechanical working directory.

  • If you are connected to a local instance and provide a file path, downloading files from a different folder is allowed but is not recommended.

Examples

Download a single file.

>>> local_file_path_list = mechanical.download('file.out')

Download all files starting with file.

>>> local_file_path_list = mechanical.download('file*')

Download every file in the Mechanical working directory.

>>> local_file_path_list = mechanical.download('*.*')

Alternatively, the recommended method is to use the download_project() method to download all files.

>>> local_file_path_list = mechanical.download_project()