import sys
import os
path = os.path.abspath(__file__)
for i in range(2):
    path = os.path.dirname(path)
PROJECT_ROOT = path
sys.path.append(PROJECT_ROOT)

from datasets.dataset import AdvancedDataset
from datasets.nbv_1.nbv_1_dataset import NextOneBestViewDataset


class DatasetFactory:
    @staticmethod
    def create(config) -> AdvancedDataset:
        source = config["source"]
        if source == "nbv1":
            return NextOneBestViewDataset(config)


''' ------------ Debug ------------ '''
if __name__ == "__main__":
 
    from configs.config import ConfigManager

    ConfigManager.load_config_with('/home/data/hofee/project/ActivePerception/ActivePerception/configs/server_train_config.yaml')
    ConfigManager.print_config()
    dataset = DatasetFactory.create(ConfigManager.get("settings", "test", "dataset_list")[1])
    print(len(dataset))
    data_test = dataset.__getitem__(107000)
    print(data_test['src_path'])
    import pickle
    # with open("data_sample_new.pkl", "wb") as f:
    #     pickle.dump(data_test, f)
