Skip to content

Commit 3a1e1ef

Browse files
committed
update LMDB info.json. not need anymore.
1 parent 1861c4e commit 3a1e1ef

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

dptb/data/build.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
from dptb.utils import instantiate, get_w_prefix
1515
from dptb.utils.tools import j_loader
1616
from dptb.utils.argcheck import normalize_setinfo, normalize_lmdbsetinfo
17+
import logging
1718

19+
log = logging.getLogger(__name__)
1820

1921
def dataset_from_config(config, prefix: str = "dataset") -> AtomicDataset:
2022
"""initialize database based on a config instance
@@ -198,31 +200,32 @@ def build_dataset(
198200
if os.path.exists(f"{root}/info.json"):
199201
public_info = j_loader(os.path.join(root, "info.json"))
200202
if dataset_type == "LMDBDataset":
201-
public_info = normalize_lmdbsetinfo(public_info)
203+
public_info = {}
204+
log.info("A public `info.json` file is provided, but will not be used anymore for LMDBDataset.")
202205
else:
203206
public_info = normalize_setinfo(public_info)
204-
print("A public `info.json` file is provided, and will be used by the subfolders who do not have their own `info.json` file.")
207+
log.info("A public `info.json` file is provided, and will be used by the subfolders who do not have their own `info.json` file.")
205208
else:
206209
public_info = None
207210

208211
# Load info in each trajectory folders seperately.
209212
for file in include_folders:
210213
#if "info.json" in os.listdir(os.path.join(root, file)):
211-
if os.path.exists(f"{root}/{file}/info.json"):
214+
215+
if dataset_type == "LMDBDataset":
216+
info_files[file] = {}
217+
elif os.path.exists(f"{root}/{file}/info.json"):
212218
# use info provided in this trajectory.
213219
info = j_loader(f"{root}/{file}/info.json")
214-
if dataset_type == "LMDBDataset":
215-
info = normalize_lmdbsetinfo(info)
216-
else:
217-
info = normalize_setinfo(info)
220+
info = normalize_setinfo(info)
218221
info_files[file] = info
219-
elif public_info is not None:
222+
elif public_info is not None: # not lmbd and no info in subfolder, then must use public info.
220223
# use public info instead
221224
# yaml will not dump correctly if this is not a deepcopy.
222225
info_files[file] = deepcopy(public_info)
223-
else:
224-
# no info for this file
225-
raise Exception(f"info.json is not properly provided for `{file}`.")
226+
else: # not lmdb no info in subfolder and no public info. then raise error.
227+
log.error(f"for {dataset_type} type, the info.json is not properly provided for `{file}`")
228+
raise ValueError(f"for {dataset_type} type, the info.json is not properly provided for `{file}`")
226229

227230
# We will sort the info_files here.
228231
# The order itself is not important, but must be consistant for the same list.

0 commit comments

Comments
 (0)