|
5 | 5 | from typing import List, Optional, Union |
6 | 6 | from urllib.parse import urlparse |
7 | 7 | from urllib.request import urlopen |
8 | | - |
| 8 | +from urllib.error import HTTPError |
9 | 9 | import pandas as pd |
| 10 | +from retry import retry |
10 | 11 |
|
11 | 12 | from openmc_data_downloader import ( |
12 | 13 | ISOTOPE_OPTIONS, |
@@ -48,7 +49,7 @@ def expand_materials_to_isotopes(materials: list): |
48 | 49 | msg = ( |
49 | 50 | "import openmc failed. openmc python package could not be found " |
50 | 51 | "and was not imported, the expand_materials_to_isotopes " |
51 | | - "opperation can not be performed ithout openmc" |
| 52 | + "opperation can not be performed without openmc" |
52 | 53 | ) |
53 | 54 | raise ImportError(msg) |
54 | 55 |
|
@@ -95,7 +96,7 @@ def expand_materials_to_sabs(materials: list): |
95 | 96 | msg = ( |
96 | 97 | "import openmc failed. openmc python package could not be found " |
97 | 98 | "and was not imported, the expand_materials_to_sabs " |
98 | | - "opperation can not be performed ithout openmc" |
| 99 | + "opperation can not be performed without openmc" |
99 | 100 | ) |
100 | 101 | raise ImportError(msg) |
101 | 102 |
|
@@ -231,6 +232,13 @@ def download_single_file( |
231 | 232 | print("Skipping {}, already downloaded".format(local_path)) |
232 | 233 | return local_path |
233 | 234 |
|
| 235 | + local_path = download_url_in_chuncks(url, local_path) |
| 236 | + |
| 237 | + return local_path |
| 238 | + |
| 239 | + |
| 240 | +@retry(HTTPError, tries=3) |
| 241 | +def download_url_in_chuncks(url, local_path): |
234 | 242 | with urlopen(url) as response: |
235 | 243 |
|
236 | 244 | # Copy file to disk in chunks |
@@ -336,7 +344,7 @@ def identify_sab_to_download( |
336 | 344 | print("Searching libraries with the following priority", priority_dict) |
337 | 345 |
|
338 | 346 | # Tried to removed this dict to dataframe conversion out of the function |
339 | | - # and into the initilisation of the package but this resultied in |
| 347 | + # and into the initialization of the package but this resultied in |
340 | 348 | # a SettingwithCopyWarning which can be fixed and understood here |
341 | 349 | # https://www.dataquest.io/blog/settingwithcopywarning/ |
342 | 350 | sab_info_df = pd.DataFrame.from_dict(sab_info) |
@@ -410,7 +418,7 @@ def identify_isotopes_to_download( |
410 | 418 | print("Searching libraries with the following priority", priority_dict) |
411 | 419 |
|
412 | 420 | # Tried to removed this dict to dataframe conversion out of the function |
413 | | - # and into the initilisation of the package but this resultied in |
| 421 | + # and into the initialization of the package but this resultied in |
414 | 422 | # a SettingwithCopyWarning which can be fixed and understood here |
415 | 423 | # https://www.dataquest.io/blog/settingwithcopywarning/ |
416 | 424 | xs_info_df = pd.DataFrame.from_dict(xs_info) |
|
0 commit comments