Skip to content

Commit 7ccee81

Browse files
committed
Refactor to allow for targeting examples from other pyansys libraries
1 parent 1c727d7 commit 7ccee81

File tree

1 file changed

+79
-35
lines changed

1 file changed

+79
-35
lines changed

src/ansys/dpf/core/examples/downloads.py

Lines changed: 79 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import warnings
88
from ansys.dpf.core.examples.examples import find_files
99

10-
EXAMPLE_REPO = "https://github.com/ansys/example-data/raw/master/result_files/"
10+
EXAMPLE_REPO = "https://github.com/ansys/example-data/raw/master/"
1111

1212

1313
def delete_downloads():
@@ -121,7 +121,9 @@ def download_transient_result(
121121
'C:/Users/user/AppData/local/temp/transient.rst'
122122
123123
"""
124-
return _download_file("transient", "transient.rst", should_upload, server, return_local_path)
124+
return _download_file(
125+
"result_files/transient", "transient.rst", should_upload, server, return_local_path
126+
)
125127

126128

127129
def download_all_kinds_of_complexity(
@@ -162,7 +164,7 @@ def download_all_kinds_of_complexity(
162164
163165
"""
164166
return _download_file(
165-
"testing", "allKindOfComplexity.rst", should_upload, server, return_local_path
167+
"result_files/testing", "allKindOfComplexity.rst", should_upload, server, return_local_path
166168
)
167169

168170

@@ -204,7 +206,7 @@ def download_all_kinds_of_complexity_modal(
204206
205207
"""
206208
return _download_file(
207-
"testing",
209+
"result_files/testing",
208210
"modal_allKindOfComplexity.rst",
209211
should_upload,
210212
server,
@@ -247,7 +249,9 @@ def download_pontoon(should_upload: bool = True, server=None, return_local_path=
247249
'C:/Users/user/AppData/local/temp/pontoon.rst'
248250
249251
"""
250-
return _download_file("docs", "pontoon.rst", should_upload, server, return_local_path)
252+
return _download_file(
253+
"result_files/docs", "pontoon.rst", should_upload, server, return_local_path
254+
)
251255

252256

253257
def download_multi_harmonic_result(
@@ -287,7 +291,7 @@ def download_multi_harmonic_result(
287291
'C:/Users/user/AppData/local/temp/file_harmonic_5rpms.rst'
288292
"""
289293
return _download_file(
290-
"harmonic", "file_harmonic_5rpms.rst", should_upload, server, return_local_path
294+
"result_files/harmonic", "file_harmonic_5rpms.rst", should_upload, server, return_local_path
291295
)
292296

293297

@@ -328,7 +332,9 @@ def download_multi_stage_cyclic_result(
328332
'C:/Users/user/AppData/local/temp/multistage.rst'
329333
330334
"""
331-
return _download_file("multistage", "multistage.rst", should_upload, server, return_local_path)
335+
return _download_file(
336+
"result_files/multistage", "multistage.rst", should_upload, server, return_local_path
337+
)
332338

333339

334340
def download_sub_file(should_upload: bool = True, server=None, return_local_path=False) -> str:
@@ -366,7 +372,7 @@ def download_sub_file(should_upload: bool = True, server=None, return_local_path
366372
'C:\\Users\\user\\AppData\\Local\\ansys-dpf-core\\ansys-dpf-core\\examples\\sub\\cp56.sub'
367373
368374
"""
369-
return _download_file("sub", "cp56.sub", should_upload, server, return_local_path)
375+
return _download_file("result_files/sub", "cp56.sub", should_upload, server, return_local_path)
370376

371377

372378
def download_msup_files_to_dict(
@@ -409,9 +415,15 @@ def download_msup_files_to_dict(
409415
410416
"""
411417
return {
412-
"rfrq": _download_file("msup", "file.rfrq", should_upload, server, return_local_path),
413-
"mode": _download_file("msup", "file.mode", should_upload, server, return_local_path),
414-
"rst": _download_file("msup", "file.rst", should_upload, server, return_local_path),
418+
"rfrq": _download_file(
419+
"result_files/msup", "file.rfrq", should_upload, server, return_local_path
420+
),
421+
"mode": _download_file(
422+
"result_files/msup", "file.mode", should_upload, server, return_local_path
423+
),
424+
"rst": _download_file(
425+
"result_files/msup", "file.rst", should_upload, server, return_local_path
426+
),
415427
}
416428

417429

@@ -454,16 +466,20 @@ def download_distributed_files(
454466
455467
"""
456468
return {
457-
0: _download_file("distributed", "file0.rst", should_upload, server, return_local_path),
458-
1: _download_file("distributed", "file1.rst", should_upload, server, return_local_path),
469+
0: _download_file(
470+
"result_files/distributed", "file0.rst", should_upload, server, return_local_path
471+
),
472+
1: _download_file(
473+
"result_files/distributed", "file1.rst", should_upload, server, return_local_path
474+
),
459475
}
460476

461477

462478
def download_fluent_multi_species_files(
463479
should_upload: bool = True, server=None, return_local_path=False
464480
) -> dict:
465-
"""Download the cas and dat file of a fluent analysis and return the
466-
download paths into a dictionary extension->path.
481+
"""Download the cas and dat file of a fluent analysis with multiple species
482+
and return the download paths into a dictionary extension->path.
467483
If the server is remote (or doesn't share memory), the file is uploaded or made available
468484
on the server side.
469485
@@ -498,8 +514,12 @@ def download_fluent_multi_species_files(
498514
499515
"""
500516
return {
501-
"cas": _download_file("fluent", "FFF.cas.h5", should_upload, server, return_local_path),
502-
"dat": _download_file("fluent", "FFF.dat.h5", should_upload, server, return_local_path),
517+
"cas": _download_file(
518+
"result_files/fluent", "FFF.cas.h5", should_upload, server, return_local_path
519+
),
520+
"dat": _download_file(
521+
"result_files/fluent", "FFF.dat.h5", should_upload, server, return_local_path
522+
),
503523
}
504524

505525

@@ -546,10 +566,10 @@ def download_extrapolation_3d_result(
546566
"""
547567
path_dict = {
548568
"file_ref": _download_file(
549-
"extrapolate", "file_ref.rst", should_upload, server, return_local_path
569+
"result_files/extrapolate", "file_ref.rst", should_upload, server, return_local_path
550570
),
551571
"file_integrated": _download_file(
552-
"extrapolate", "file.rst", should_upload, server, return_local_path
572+
"result_files/extrapolate", "file.rst", should_upload, server, return_local_path
553573
),
554574
}
555575

@@ -599,14 +619,14 @@ def download_extrapolation_2d_result(
599619
"""
600620
path_dict = {
601621
"file_ref": _download_file(
602-
"extrapolate",
622+
"result_files/extrapolate",
603623
"extrapolate_2d_ref.rst",
604624
should_upload,
605625
server,
606626
return_local_path,
607627
),
608628
"file_integrated": _download_file(
609-
"extrapolate",
629+
"result_files/extrapolate",
610630
"extrapolate_2d.rst",
611631
should_upload,
612632
server,
@@ -652,7 +672,9 @@ def download_hemisphere(should_upload: bool = True, server=None, return_local_pa
652672
'C:/Users/user/AppData/local/temp/hemisphere.rst'
653673
654674
"""
655-
return _download_file("hemisphere", "hemisphere.rst", should_upload, server, return_local_path)
675+
return _download_file(
676+
"result_files/hemisphere", "hemisphere.rst", should_upload, server, return_local_path
677+
)
656678

657679

658680
def download_example_asme_result(
@@ -691,7 +713,7 @@ def download_example_asme_result(
691713
'C:/Users/user/AppData/local/temp/asme_example.rst'
692714
"""
693715
return _download_file(
694-
"postprocessing", "asme_example.rst", should_upload, server, return_local_path
716+
"result_files/postprocessing", "asme_example.rst", should_upload, server, return_local_path
695717
)
696718

697719

@@ -730,7 +752,9 @@ def download_crankshaft(should_upload: bool = True, server=None, return_local_pa
730752
'C:/Users/user/AppData/local/temp/crankshaft.rst'
731753
732754
"""
733-
return _download_file("crankshaft", "crankshaft.rst", should_upload, server, return_local_path)
755+
return _download_file(
756+
"result_files/crankshaft", "crankshaft.rst", should_upload, server, return_local_path
757+
)
734758

735759

736760
def download_piston_rod(should_upload: bool = True, server=None, return_local_path=False) -> str:
@@ -768,7 +792,9 @@ def download_piston_rod(should_upload: bool = True, server=None, return_local_pa
768792
'C:/Users/user/AppData/local/temp/piston_rod.rst'
769793
770794
"""
771-
return _download_file("piston_rod", "piston_rod.rst", should_upload, server, return_local_path)
795+
return _download_file(
796+
"result_files/piston_rod", "piston_rod.rst", should_upload, server, return_local_path
797+
)
772798

773799

774800
def download_d3plot_beam(should_upload: bool = True, server=None, return_local_path=False) -> list:
@@ -810,10 +836,18 @@ def download_d3plot_beam(should_upload: bool = True, server=None, return_local_p
810836
811837
"""
812838
return [
813-
_download_file("d3plot_beam", "d3plot", should_upload, server, return_local_path),
814-
_download_file("d3plot_beam", "d3plot01", should_upload, server, return_local_path),
815-
_download_file("d3plot_beam", "d3plot02", should_upload, server, return_local_path),
816-
_download_file("d3plot_beam", "file.actunits", should_upload, server, return_local_path),
839+
_download_file(
840+
"result_files/d3plot_beam", "d3plot", should_upload, server, return_local_path
841+
),
842+
_download_file(
843+
"result_files/d3plot_beam", "d3plot01", should_upload, server, return_local_path
844+
),
845+
_download_file(
846+
"result_files/d3plot_beam", "d3plot02", should_upload, server, return_local_path
847+
),
848+
_download_file(
849+
"result_files/d3plot_beam", "file.actunits", should_upload, server, return_local_path
850+
),
817851
]
818852

819853

@@ -852,7 +886,9 @@ def download_binout_matsum(should_upload: bool = True, server=None, return_local
852886
'C:/Users/user/AppData/local/temp/binout_matsum'
853887
854888
"""
855-
return _download_file("binout", "binout_matsum", should_upload, server, return_local_path)
889+
return _download_file(
890+
"result_files/binout", "binout_matsum", should_upload, server, return_local_path
891+
)
856892

857893

858894
def download_binout_glstat(should_upload: bool = True, server=None, return_local_path=False) -> str:
@@ -890,7 +926,9 @@ def download_binout_glstat(should_upload: bool = True, server=None, return_local
890926
'C:/Users/user/AppData/local/temp/binout_glstat'
891927
892928
"""
893-
return _download_file("binout", "binout_glstat", should_upload, server, return_local_path)
929+
return _download_file(
930+
"result_files/binout", "binout_glstat", should_upload, server, return_local_path
931+
)
894932

895933

896934
def download_cycles_to_failure(
@@ -931,7 +969,7 @@ def download_cycles_to_failure(
931969
932970
"""
933971
return _download_file(
934-
"cyclic", "cyclic_to_failure.rst", should_upload, server, return_local_path
972+
"result_files/cyclic", "cyclic_to_failure.rst", should_upload, server, return_local_path
935973
)
936974

937975

@@ -968,7 +1006,9 @@ def download_modal_frame(should_upload: bool = True, server=None, return_local_p
9681006
>>> path = examples.download_modal_frame()
9691007
9701008
"""
971-
return _download_file("modal", "frame.rst", should_upload, server, return_local_path)
1009+
return _download_file(
1010+
"result_files/modal", "frame.rst", should_upload, server, return_local_path
1011+
)
9721012

9731013

9741014
def download_harmonic_clamped_pipe(
@@ -1006,7 +1046,9 @@ def download_harmonic_clamped_pipe(
10061046
>>> path = examples.download_modal_frame()
10071047
10081048
"""
1009-
return _download_file("harmonic", "clamped_pipe.rst", should_upload, server, return_local_path)
1049+
return _download_file(
1050+
"result_files/harmonic", "clamped_pipe.rst", should_upload, server, return_local_path
1051+
)
10101052

10111053

10121054
def download_modal_cyclic(should_upload: bool = True, server=None, return_local_path=False) -> str:
@@ -1042,4 +1084,6 @@ def download_modal_cyclic(should_upload: bool = True, server=None, return_local_
10421084
>>> path = examples.download_modal_cyclic()
10431085
10441086
"""
1045-
return _download_file("cyclic", "modal_cyclic.rst", should_upload, server, return_local_path)
1087+
return _download_file(
1088+
"result_files/cyclic", "modal_cyclic.rst", should_upload, server, return_local_path
1089+
)

0 commit comments

Comments
 (0)