(feat) get bots data paths from hummingbot_files/bots + general or uploaded data

This commit is contained in:
drupman
2023-10-31 17:30:15 -03:00
parent 620cc10024
commit 1a892358a8
2 changed files with 8 additions and 11 deletions

View File

@@ -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)

View File

@@ -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):