@@ -23,7 +23,7 @@ def _retrieve_file(url, filename, directory):
2323 local_path = os .path .join (EXAMPLES_PATH , directory , os .path .basename (filename ))
2424 local_path_no_zip = local_path .replace ('.zip' , '' )
2525 if os .path .isfile (local_path_no_zip ) or os .path .isdir (local_path_no_zip ):
26- return local_path_no_zip , None
26+ return local_path_no_zip
2727
2828 # grab the correct url retriever
2929 urlretrieve = urllib .request .urlretrieve
@@ -44,13 +44,84 @@ def _download_file(directory, filename):
4444 if os .environ .get ('DPF_DOCKER' , False ): # pragma: no cover
4545 # override path if running on docker as path must be relative
4646 # to docker mount
47- local_path = os .path .join ('/dpf/ansys/dpf/core/examples/_cache/' , directory ,
48- filename )
47+ #
48+ # Assumes the following mapping in docker
49+ # DWN_CSH=/tmp/dpf_cache
50+ # -v $DWN_CSH:/dpf/_cache
51+ local_path = os .path .join ('/dpf/_cache' , directory , filename )
4952 return local_path
5053
5154###############################################################################
5255# front-facing downloads
5356
54- def download_transient_result ():
55- """Download an example transient result and return the download path"""
57+ def download_transient_result () -> str :
58+ """Download an example transient result file and return the download path.
59+
60+ Examples files are downloaded to a persistent cache to avoid
61+ re-downloading the same file twice.
62+
63+ Returns
64+ -------
65+ str
66+ Path to the example file.
67+
68+ Examples
69+ --------
70+ Download an example result file and return the path of the file
71+
72+ >>> from ansys.dpf.core import examples
73+ >>> path = examples.transient_result
74+ >>> path
75+ 'C:/Users/user/AppData/local/temp/transient.rst'
76+
77+ """
5678 return _download_file ('transient' , 'transient.rst' )
79+
80+
81+ def download_all_kinds_of_complexity () -> str :
82+ """Download an example static result and return the download path.
83+
84+ Examples files are downloaded to a persistent cache to avoid
85+ re-downloading the same file twice.
86+
87+ Returns
88+ -------
89+ str
90+ Path to the example file.
91+
92+ Examples
93+ --------
94+ Download an example result file and return the path of the file
95+
96+ >>> from ansys.dpf.core import examples
97+ >>> path = examples.download_all_kinds_of_complexity
98+ >>> path
99+ 'C:/Users/user/AppData/local/temp/allKindOfComplexity.rst'
100+
101+ """
102+ return _download_file ('testing' , 'allKindOfComplexity.rst' )
103+
104+
105+ def download_all_kinds_of_complexity_modal () -> str :
106+ """Download an example result file from a static modal analsys and
107+ return the download path.
108+
109+ Examples files are downloaded to a persistent cache to avoid
110+ re-downloading the same file twice.
111+
112+ Returns
113+ -------
114+ str
115+ Path to the example file.
116+
117+ Examples
118+ --------
119+ Download an example result file and return the path of the file
120+
121+ >>> from ansys.dpf.core import examples
122+ >>> path = examples.download_all_kinds_of_complexity_modal
123+ >>> path
124+ 'C:/Users/user/AppData/local/temp/modal_allKindOfComplexity.rst'
125+
126+ """
127+ return _download_file ('testing' , 'modal_allKindOfComplexity.rst' )
0 commit comments