aiteamutils 0.2.15__py3-none-any.whl → 0.2.16__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
aiteamutils/__init__.py CHANGED
@@ -1,5 +1,10 @@
1
1
  from .base_model import Base
2
- from .database import DatabaseService
2
+ from .database import (
3
+ DatabaseService,
4
+ get_db,
5
+ get_database_service,
6
+ get_database_session
7
+ )
3
8
  from .exceptions import (
4
9
  CustomException,
5
10
  ErrorCode,
@@ -30,6 +35,9 @@ __all__ = [
30
35
 
31
36
  # Database
32
37
  "DatabaseService",
38
+ "get_db",
39
+ "get_database_service",
40
+ "get_database_session",
33
41
 
34
42
  # Exceptions
35
43
  "CustomException",
aiteamutils/config.py CHANGED
@@ -1,26 +1,59 @@
1
1
  """설정 모듈."""
2
- from typing import Optional
3
- from pydantic_settings import BaseSettings
2
+ from typing import Union
3
+ from .database import init_database_service
4
4
 
5
- class Settings(BaseSettings):
6
- """애플리케이션 설정."""
7
-
8
- # 데이터베이스 설정
9
- DB_ECHO: bool = False
10
- DB_POOL_SIZE: int = 5
11
- DB_MAX_OVERFLOW: int = 10
12
- DB_POOL_TIMEOUT: int = 30
13
- DB_POOL_RECYCLE: int = 1800
5
+ class Settings:
6
+ """기본 설정 클래스"""
7
+ def __init__(self, jwt_secret: str, jwt_algorithm: str = "HS256"):
8
+ self.JWT_SECRET = jwt_secret
9
+ self.JWT_ALGORITHM = jwt_algorithm
10
+
11
+ _settings: Union[Settings, None] = None
12
+
13
+ def init_settings(
14
+ jwt_secret: str,
15
+ jwt_algorithm: str = "HS256",
16
+ db_url: str = None,
17
+ db_echo: bool = False,
18
+ db_pool_size: int = 5,
19
+ db_max_overflow: int = 10,
20
+ db_pool_timeout: int = 30,
21
+ db_pool_recycle: int = 1800
22
+ ):
23
+ """설정 초기화 함수
14
24
 
15
- # JWT 설정
16
- JWT_SECRET: str = "your-secret-key"
17
- JWT_ALGORITHM: str = "HS256"
18
- ACCESS_TOKEN_EXPIRE_MINUTES: int = 30
19
- TOKEN_ISSUER: str = "ai-team-platform"
20
- TOKEN_AUDIENCE: str = "ai-team-users"
25
+ Args:
26
+ jwt_secret (str): JWT 시크릿 키
27
+ jwt_algorithm (str, optional): JWT 알고리즘. Defaults to "HS256".
28
+ db_url (str, optional): 데이터베이스 URL
29
+ db_echo (bool, optional): SQL 로깅 여부
30
+ db_pool_size (int, optional): DB 커넥션 풀 크기
31
+ db_max_overflow (int, optional): 최대 초과 커넥션 수
32
+ db_pool_timeout (int, optional): 커넥션 풀 타임아웃
33
+ db_pool_recycle (int, optional): 커넥션 재활용 시간
34
+ """
35
+ global _settings
36
+ _settings = Settings(jwt_secret, jwt_algorithm)
21
37
 
22
- class Config:
23
- env_file = ".env"
24
- case_sensitive = True
38
+ if db_url:
39
+ init_database_service(
40
+ db_url=db_url,
41
+ db_echo=db_echo,
42
+ db_pool_size=db_pool_size,
43
+ db_max_overflow=db_max_overflow,
44
+ db_pool_timeout=db_pool_timeout,
45
+ db_pool_recycle=db_pool_recycle
46
+ )
25
47
 
26
- settings = Settings()
48
+ def get_settings() -> Settings:
49
+ """현재 설정을 반환하는 함수
50
+
51
+ Returns:
52
+ Settings: 설정 객체
53
+
54
+ Raises:
55
+ RuntimeError: 설정이 초기화되지 않은 경우
56
+ """
57
+ if _settings is None:
58
+ raise RuntimeError("Settings not initialized. Call init_settings first.")
59
+ return _settings
aiteamutils/database.py CHANGED
@@ -880,4 +880,36 @@ class DatabaseService:
880
880
  detail=str(e),
881
881
  source_function="DatabaseService.refresh",
882
882
  original_error=e
883
- )
883
+ )
884
+
885
+ def init_database_service(
886
+ db_url: str,
887
+ db_echo: bool = False,
888
+ db_pool_size: int = 5,
889
+ db_max_overflow: int = 10,
890
+ db_pool_timeout: int = 30,
891
+ db_pool_recycle: int = 1800
892
+ ) -> DatabaseService:
893
+ """데이터베이스 서비스를 초기화합니다.
894
+
895
+ Args:
896
+ db_url (str): 데이터베이스 URL
897
+ db_echo (bool, optional): SQL 로깅 여부
898
+ db_pool_size (int, optional): DB 커넥션 풀 크기
899
+ db_max_overflow (int, optional): 최대 초과 커넥션 수
900
+ db_pool_timeout (int, optional): 커넥션 풀 타임아웃
901
+ db_pool_recycle (int, optional): 커넥션 재활용 시간
902
+
903
+ Returns:
904
+ DatabaseService: 초기화된 데이터베이스 서비스 인스턴스
905
+ """
906
+ global _database_service
907
+ _database_service = DatabaseService(
908
+ db_url=db_url,
909
+ db_echo=db_echo,
910
+ db_pool_size=db_pool_size,
911
+ db_max_overflow=db_max_overflow,
912
+ db_pool_timeout=db_pool_timeout,
913
+ db_pool_recycle=db_pool_recycle
914
+ )
915
+ return _database_service
@@ -1,67 +1,11 @@
1
- from typing import Type, Dict, Tuple, Any, Callable, Union
1
+ from typing import Type, Dict, Tuple, Any, Callable
2
2
  from fastapi import Depends, status
3
3
  from fastapi.security import OAuth2PasswordBearer
4
4
  from jose import JWTError, jwt
5
5
 
6
6
  from .database import DatabaseService, get_database_service
7
7
  from .exceptions import CustomException, ErrorCode
8
-
9
- class Settings:
10
- """기본 설정 클래스"""
11
- def __init__(self, jwt_secret: str, jwt_algorithm: str = "HS256"):
12
- self.JWT_SECRET = jwt_secret
13
- self.JWT_ALGORITHM = jwt_algorithm
14
-
15
- _settings: Union[Settings, None] = None
16
-
17
- def init_settings(
18
- jwt_secret: str,
19
- jwt_algorithm: str = "HS256",
20
- db_url: str = None,
21
- db_echo: bool = False,
22
- db_pool_size: int = 5,
23
- db_max_overflow: int = 10,
24
- db_pool_timeout: int = 30,
25
- db_pool_recycle: int = 1800
26
- ):
27
- """설정 초기화 함수
28
-
29
- Args:
30
- jwt_secret (str): JWT 시크릿 키
31
- jwt_algorithm (str, optional): JWT 알고리즘. Defaults to "HS256".
32
- db_url (str, optional): 데이터베이스 URL
33
- db_echo (bool, optional): SQL 로깅 여부
34
- db_pool_size (int, optional): DB 커넥션 풀 크기
35
- db_max_overflow (int, optional): 최대 초과 커넥션 수
36
- db_pool_timeout (int, optional): 커넥션 풀 타임아웃
37
- db_pool_recycle (int, optional): 커넥션 재활용 시간
38
- """
39
- global _settings
40
- _settings = Settings(jwt_secret, jwt_algorithm)
41
-
42
- if db_url:
43
- from .database import _database_service
44
- _database_service = DatabaseService(
45
- db_url=db_url,
46
- db_echo=db_echo,
47
- db_pool_size=db_pool_size,
48
- db_max_overflow=db_max_overflow,
49
- db_pool_timeout=db_pool_timeout,
50
- db_pool_recycle=db_pool_recycle
51
- )
52
-
53
- def get_settings() -> Settings:
54
- """현재 설정을 반환하는 함수
55
-
56
- Returns:
57
- Settings: 설정 객체
58
-
59
- Raises:
60
- RuntimeError: 설정이 초기화되지 않은 경우
61
- """
62
- if _settings is None:
63
- raise RuntimeError("Settings not initialized. Call init_settings first.")
64
- return _settings
8
+ from .config import get_settings
65
9
 
66
10
  class ServiceRegistry:
67
11
  """서비스 레지스트리를 관리하는 클래스"""
aiteamutils/version.py CHANGED
@@ -1,2 +1,2 @@
1
1
  """버전 정보"""
2
- __version__ = "0.2.15"
2
+ __version__ = "0.2.16"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aiteamutils
3
- Version: 0.2.15
3
+ Version: 0.2.16
4
4
  Summary: AI Team Utilities
5
5
  Project-URL: Homepage, https://github.com/yourusername/aiteamutils
6
6
  Project-URL: Issues, https://github.com/yourusername/aiteamutils/issues
@@ -1,16 +1,16 @@
1
- aiteamutils/__init__.py,sha256=h7iFifWvRlaComsk4VPapRr16YhD19Kp1LuBzLHqdgQ,1170
1
+ aiteamutils/__init__.py,sha256=cpQeEVultNyHYdnz0hympv8iA-8loE_4EbTHytxlp6s,1312
2
2
  aiteamutils/base_model.py,sha256=ODEnjvUVoxQ1RPCfq8-uZTfTADIA4c7Z3E6G4EVsSX0,2708
3
3
  aiteamutils/base_repository.py,sha256=qdwQ7Sj2fUqxpDg6cWM48n_QbwPK_VUlG9zTSem8iCk,18968
4
4
  aiteamutils/base_service.py,sha256=E4dHGE0DvhmRyFplh46SwKJOSF_nUL7OAsCkf_ZJF_8,24733
5
5
  aiteamutils/cache.py,sha256=tr0Yn8VPYA9QHiKCUzciVlQ2J1RAwNo2K9lGMH4rY3s,1334
6
- aiteamutils/config.py,sha256=vC6k6E2-Y4mD0E0kw6WVgSatCl9K_BtTwrVFhLrhCzs,665
7
- aiteamutils/database.py,sha256=qD7Qr_WPMfo989MMSJZrT1myBH8FsI3295h_lVC8sG8,32153
8
- aiteamutils/dependencies.py,sha256=tniDXjF3HxTZFYYH5StIIp7i09caHKq7MS-QbSzfYTg,5717
6
+ aiteamutils/config.py,sha256=1rqsrEiYEHbZAtDwS43139jDvPQYEFMn3GKPnZFR9cs,1843
7
+ aiteamutils/database.py,sha256=09ihgJgKlCTouWPnb2dMhWqNH75n7lwB5GauEtr3oiQ,33226
8
+ aiteamutils/dependencies.py,sha256=S6OWV4d3TONKKW9tRUP9whQlVX5DFfOq7U-7VUyPktA,3928
9
9
  aiteamutils/enums.py,sha256=ipZi6k_QD5-3QV7Yzv7bnL0MjDz-vqfO9I5L77biMKs,632
10
10
  aiteamutils/exceptions.py,sha256=YV-ISya4wQlHk4twvGo16I5r8h22-tXpn9wa-b3WwDM,15231
11
11
  aiteamutils/security.py,sha256=AZszaTxVEGi1jU1sX3QXHGgshp1lVvd0xXvZejXvs_w,12643
12
12
  aiteamutils/validators.py,sha256=3N245cZFjgwtW_KzjESkizx5BBUDaJLbbxfNO4WOFZ0,7764
13
- aiteamutils/version.py,sha256=NcySKhUNLNSDWEOg8GGMsSljHPsJiM_LdJJHBQJQG8s,44
14
- aiteamutils-0.2.15.dist-info/METADATA,sha256=2h2jY-E5xlWm5n9csmSjxXV2XilC2a0qivb1p7JlCvc,1718
15
- aiteamutils-0.2.15.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
16
- aiteamutils-0.2.15.dist-info/RECORD,,
13
+ aiteamutils/version.py,sha256=rRuVYgfIJ8ippmZIeHjX4hU3YDt4kvSClCXfazS1zhw,44
14
+ aiteamutils-0.2.16.dist-info/METADATA,sha256=1oaCQf8w5iiMLfZ6Fv5C_PLUkF6hcx2SNhBy5BwApBs,1718
15
+ aiteamutils-0.2.16.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
16
+ aiteamutils-0.2.16.dist-info/RECORD,,