Specify file paths#
Functions to download sample datasets from the Ansys example data repository.
Exceptions:
Raised on an attempt to download a non-existent remote file. |
Functions:
Delete all downloaded examples from the default examples folder to free space or update the files. |
|
|
Download specified example file from the Ansys example data repository. |
|
Return path of given file name. |
- exception ansys.fluent.core.examples.downloads.RemoteFileNotFoundError(url)#
Bases:
FileNotFoundError
Raised on an attempt to download a non-existent remote file.
- __init__(url)#
- ansys.fluent.core.examples.downloads.delete_downloads()#
Delete all downloaded examples from the default examples folder to free space or update the files.
Notes
The default examples path is given by
pyfluent.EXAMPLES_PATH
.
- ansys.fluent.core.examples.downloads.download_file(file_name, directory=None, save_path=None, return_without_path=None)#
Download specified example file from the Ansys example data repository.
- Parameters:
- file_name
str
File to download.
- directory
str
,optional
Ansys example data repository directory where specified file is located. If not specified, looks for the file in the root directory of the repository.
- save_path
str
,optional
Path to download the specified file to.
- return_without_pathbool,
optional
When unspecified, defaults to False, unless the PYFLUENT_LAUNCH_CONTAINER=1 environment variable is specified, in which case defaults to True. Relevant when using Fluent Docker container images, as the full path for the imported file from the host side is not necessarily going to be the same as the one for Fluent inside the container. Assuming the Fluent inside the container has its working directory set to the path that was mounted from the host, and that the example files are being made available by the host through this same path, only the file name is required for Fluent to find and open the file.
- file_name
- Returns:
str
file path of the downloaded or already existing file, or only the file name if
return_without_path=True
.
- Raises:
RemoteFileNotFoundError
If remote file does not exist.
Examples
>>> from ansys.fluent.core import examples >>> file_path = examples.download_file("bracket.iges", "geometry") >>> file_path '/home/user/.local/share/ansys_fluent_core/examples/bracket.iges' >>> file_name = examples.download_file("bracket.iges", "geometry", return_without_path=True) >>> file_name 'bracket.iges' >>> file_path = examples.download_file("bracket.iges", "geometry", save_path='.') '/home/<current_folder_path>/bracket.iges' >>> file_name = examples.download_file("bracket.iges", "geometry", save_path='.', return_without_path=True) >>> file_name 'bracket.iges' >>> file_path = examples.download_file("bracket.iges", "geometry", save_path='<user_specified_path>') '/home/<user_specified_path>/bracket.iges' >>> file_name = examples.download_file("bracket.iges", "geometry", save_path='<user_specified_path>', ... return_without_path=True) >>> file_name 'bracket.iges'
- ansys.fluent.core.examples.downloads.path(file_name)#
Return path of given file name.
- Parameters:
- file_name
str
Name of the file.
- file_name
- Returns:
- file_path:
str
File path.
- file_path:
- Raises:
FileNotFoundError
If file does not exist.