The downloads.py module#

Summary#

download_file

Download a file from PyAnsys examples Github repo.

delete_downloads

Delete all downloaded examples to free space or update the files.

Description#

Functions to download sample datasets from the PyAnsys data repository.

Module detail#

downloads.download_file(filename: str, *directory: str, destination: str | None = None, force: bool = False)#

Download a file from PyAnsys examples Github repo.

Parameters:
filename: str

Name of the file to download

directory: tuple[str]

Path under the PyAnsys Github examples repo

destination: Optional[str]

Optional destination to download the directory to

force: bool

Flag to force download even if the file exists in cache

Returns:
str

Filepath to the downloaded file

Examples

Download a file from the server

>>> from ansys.mechanical.core import examples
>>> filename = examples.download_file("example_01_geometry.agdb", "pymechanical", "00_basic")
>>> filename
'C:/Users/user/AppData/Local/ansys_mechanical_core/ansys_mechanical_core/examples/example_01_geometry.agdb'

Download using the download manager

>>> filename = examples.download_file("11_blades_mode_1_ND_0.csv", "pymapdl", "cfx_mapping")
>>> filename
'C:/Users/user/AppData/Local/ansys_mechanical_core/ansys_mechanical_core/examples/11_blades_mode_1_ND_0.csv'
downloads.delete_downloads() bool#

Delete all downloaded examples to free space or update the files.

Returns:
bool

True if delete_downlaods succeeds, False otherwise.

Examples

Delete all downloaded examples

>>> from ansys.mechanical.core import examples
>>> return_value = examples.delete_downloads()
>>> return_value
'True'