From 1a892358a859208dcecc1a85535dbba4e6506f1d Mon Sep 17 00:00:00 2001 From: drupman Date: Tue, 31 Oct 2023 17:30:15 -0300 Subject: [PATCH] (feat) get bots data paths from hummingbot_files/bots + general or uploaded data --- utils/database_manager.py | 2 +- utils/os_utils.py | 17 +++++++---------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/utils/database_manager.py b/utils/database_manager.py index 80f8725..8234fff 100644 --- a/utils/database_manager.py +++ b/utils/database_manager.py @@ -12,7 +12,7 @@ class DatabaseManager: def __init__(self, db_name: str, executors_path: str = "data"): self.db_name = db_name # TODO: Create db path for all types of db - self.db_path = f'sqlite:///{os.path.join("data", db_name)}' + self.db_path = f'sqlite:///{os.path.join(db_name)}' self.executors_path = executors_path self.engine = create_engine(self.db_path, connect_args={'check_same_thread': False}) self.session_maker = sessionmaker(bind=self.engine) diff --git a/utils/os_utils.py b/utils/os_utils.py index e7b73cc..c5cd6e2 100644 --- a/utils/os_utils.py +++ b/utils/os_utils.py @@ -105,23 +105,20 @@ def load_controllers(path): def get_bots_data_paths(): - root_directory = os.getcwd() - bots_data_paths = {} - + root_directory = "hummingbot_files/bots" + bots_data_paths = {"General / Uploaded data": "data"} + reserved_word = "hummingbot-" # Walk through the directory tree for dirpath, dirnames, filenames in os.walk(root_directory): for dirname in dirnames: - # Check if the directory is named "data" if dirname == "data": parent_folder = os.path.basename(dirpath) - # Append the full path of the "data" directory to the list - bots_data_paths[parent_folder] = os.path.join(dirpath, dirname) + if parent_folder.startswith(reserved_word): + bots_data_paths[parent_folder] = os.path.join(dirpath, dirname) if "dashboard" in bots_data_paths: - # Create a new key "base folder" with the value of the old key - bots_data_paths["base folder"] = bots_data_paths["dashboard"] - # Delete the old key "dashboard" del bots_data_paths["dashboard"] - return {key: value for key, value in bots_data_paths.items() if value is not None} + data_sources = {key: value for key, value in bots_data_paths.items() if value is not None} + return data_sources def get_function_from_file(file_path: str, function_name: str):