admin
commited on
Commit
·
9d28e90
1
Parent(s):
d24adcc
translate notes into english
Browse files- vi_backbones.py +11 -9
vi_backbones.py
CHANGED
@@ -30,25 +30,27 @@ class vi_backbones(datasets.GeneratorBasedBuilder):
|
|
30 |
homepage=_HOMEPAGE,
|
31 |
license="mit"
|
32 |
)
|
33 |
-
|
34 |
def _get_file_md5(self, url):
|
35 |
"""
|
36 |
-
|
37 |
|
38 |
-
:param url:
|
39 |
-
:return:
|
40 |
"""
|
41 |
try:
|
42 |
response = requests.get(url, stream=True)
|
43 |
if response.status_code == 200:
|
44 |
md5obj = hashlib.md5()
|
45 |
-
for chunk in response.iter_content(chunk_size=1024*1024):
|
46 |
-
md5obj.update(chunk)
|
47 |
-
return md5obj.hexdigest()
|
48 |
else:
|
49 |
-
raise ValueError(
|
|
|
50 |
except Exception as e:
|
51 |
-
raise ValueError(
|
|
|
52 |
|
53 |
def _parse_url(self, url):
|
54 |
response = requests.get(url)
|
|
|
30 |
homepage=_HOMEPAGE,
|
31 |
license="mit"
|
32 |
)
|
33 |
+
|
34 |
def _get_file_md5(self, url):
|
35 |
"""
|
36 |
+
Calculate the MD5 hash value of a file using its URL
|
37 |
|
38 |
+
:param url: the URL address of the file
|
39 |
+
:return: the MD5 hash value in string format
|
40 |
"""
|
41 |
try:
|
42 |
response = requests.get(url, stream=True)
|
43 |
if response.status_code == 200:
|
44 |
md5obj = hashlib.md5()
|
45 |
+
for chunk in response.iter_content(chunk_size=1024*1024):
|
46 |
+
md5obj.update(chunk)
|
47 |
+
return md5obj.hexdigest()
|
48 |
else:
|
49 |
+
raise ValueError(
|
50 |
+
f"Error downloading file from {url}. Status code: {response.status_code}")
|
51 |
except Exception as e:
|
52 |
+
raise ValueError(
|
53 |
+
f"Error calculating MD5 of file at {url}: {str(e)}")
|
54 |
|
55 |
def _parse_url(self, url):
|
56 |
response = requests.get(url)
|