Spaces:
Starting
on
L4
Starting
on
L4
File size: 1,666 Bytes
dc9e27a |
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 50 51 52 53 54 55 56 57 58 |
# msdl/config.py
from pathlib import Path
class FileSystemManager:
@staticmethod
def ensure_dir(dir_path):
"""Ensure the directory exists, create if it doesn't"""
path = Path(dir_path)
if not path.exists():
path.mkdir(parents=True, exist_ok=True)
return path
@staticmethod
def ensure_file(file_path, default_content=""):
"""Ensure the file exists, create if it doesn't"""
path = Path(file_path)
if not path.parent.exists():
FileSystemManager.ensure_dir(path.parent)
if not path.exists():
with open(path, "w") as f:
f.write(default_content)
return path
# Get the directory where the script is located
PACKAGE_DIR = Path(__file__).resolve().parent
# Get the root directory of the MindSearch project
PROJECT_ROOT = PACKAGE_DIR.parent.parent
# Get the temp directory path, which is actually the working directory for executing the docker compose up command
TEMP_DIR = FileSystemManager.ensure_dir(PACKAGE_DIR / "temp")
# Configuration file name list
TEMPLATE_FILES = ["docker-compose.yaml"]
# Backend Dockerfile directory
BACKEND_DOCKERFILE_DIR = "backend"
# Backend Dockerfile name
CLOUD_LLM_DOCKERFILE = "cloud_llm.dockerfile"
LOCAL_LLM_DOCKERFILE = "local_llm.dockerfile"
# Frontend Dockerfile directory
FRONTEND_DOCKERFILE_DIR = "frontend"
# Frontend Dockerfile name
REACT_DOCKERFILE = "react.dockerfile"
# i18n translations directory
TRANSLATIONS_DIR = FileSystemManager.ensure_dir(PACKAGE_DIR / "translations")
# Get the path of the .env file
ENV_FILE_PATH = FileSystemManager.ensure_file(TEMP_DIR / ".env")
|