forked from Lifelong-Robot-Learning/LIBERO
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshasum_files.py
49 lines (39 loc) · 1.25 KB
/
shasum_files.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import os
import hashlib
from pathlib import Path
def shasum_file(file_path):
if os.path.exists(file_path):
with open(file_path, "rb") as f:
data = f.read()
sha_hash = hashlib.sha1(data).hexdigest()
file_name = file_path.split("/")[-1]
return {file_name: sha_hash}
else:
return None
def shasum_datasets(download_dir="datasets"):
dataset_shasum = {}
for dataset_name in [
"libero_object",
"libero_goal",
"libero_spatial",
"libero_10",
"libero_90",
]:
dataset_dir = os.path.join(download_dir, dataset_name)
if os.path.exists(dataset_dir):
count = 0
for path in Path(dataset_dir).glob("*.hdf5"):
count += 1
if not (
(count == 10 and dataset_name != "libero_90")
or (count == 90 and dataset_name == "libero_90")
):
print("file count doesn't match")
else:
print("dataset not found")
for path in Path(dataset_dir).glob("*.hdf5"):
dataset_shasum.update(shasum_file(str(path)))
print(dataset_shasum)
# def shalsum_pretrained_models():
# def shalsum_pretrained_policies():
shasum_datasets()