Skip to content

Commit 54105f0

Browse files
committed
chore: update dependencies and improve project structure
1 parent d0a5711 commit 54105f0

File tree

5 files changed

+327
-13
lines changed

5 files changed

+327
-13
lines changed

core/services/core/settings_service.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from pydantic_settings import BaseSettings
66

77
from core.dtos.settings import SettingsDto
8+
from shared.utils.funcs import get_project_name
89

910

1011
class SettingsService(BaseSettings, SettingsDto):
@@ -26,10 +27,11 @@ def settings_customise_sources(
2627

2728
@classmethod
2829
def yaml_config_source(cls):
30+
project_name = get_project_name()
2931
settings_type: str = os.environ.get("ENVIRONMENT", "dev")
30-
current_file_path = os.path.abspath(__file__).split("src")
32+
current_file_path = os.path.abspath(__file__).split(project_name)
3133
current_file_path = current_file_path[:-1][0]
32-
settings_dir = os.path.join(current_file_path, "src", "core", "configs")
34+
settings_dir = os.path.join(current_file_path, project_name, "core", "configs")
3335
settings_path = os.path.join(settings_dir, f"{settings_type}.yaml")
3436
config_path = Path(settings_path)
3537
if config_path.exists():

core/services/database/database_service.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from core.services.core import settings
1212
from core.services.database.abstract_database_service import AbstractDatabaseService
1313
from shared.utils import logger
14-
from shared.utils.funcs import get_root_path, get_project_name
14+
from shared.utils.funcs import get_root_path
1515

1616

1717
class DatabaseService(AbstractDatabaseService):
@@ -60,7 +60,6 @@ async def _create_database(self, engine: AsyncEngine) -> None:
6060
logger.info(f"Creating database schema for {settings.database.schema_package}")
6161
try:
6262
schema_package = settings.database.schema_package
63-
schema_package = schema_package.replace(f"{get_project_name()}.", "")
6463
schema_package_split = os.sep.join(schema_package.split("."))
6564
schema_package_path = os.path.join(get_root_path(), schema_package_split)
6665
if not os.path.exists(schema_package_path):

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ authors = [
1010
]
1111

1212
dependencies = [
13+
"asyncpg>=0.30.0",
1314
"crewai>=0.108.0",
1415
"fastapi>=0.115.9",
16+
"greenlet>=3.1.1",
1517
"gunicorn>=23.0.0",
1618
"pydantic-settings>=2.8.1",
1719
"sqlmodel>=0.0.24",

shared/utils/funcs.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,24 @@
44

55
def get_root_path() -> str:
66
"""
7-
Get the root path of the project.
7+
Get the root path of the project based on the given module name.
88
99
Returns:
1010
str: The root path of the project.
1111
"""
12-
current_file_path = os.path.abspath(__file__).split("src")
12+
current_file_path = os.path.abspath(__file__).split(get_project_name())
1313
current_file_path = current_file_path[:-1][0]
14-
return current_file_path
14+
return os.path.join(current_file_path, get_project_name())
1515

1616

1717
def get_project_name() -> str:
1818
"""
19-
Get the project name.
19+
Get the project name based on the root path of the given module.
2020
2121
Returns:
22-
str: The project name.
22+
str: The name of the project.
2323
"""
24-
root_path = get_root_path()
25-
project_name = root_path.split("/")[-2]
26-
return project_name
24+
return "canvas"
2725

2826

2927
def make_snake_case(string: str) -> str:

0 commit comments

Comments
 (0)