lecrapaud 0.18.7__py3-none-any.whl → 0.18.9__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.
Potentially problematic release.
This version of lecrapaud might be problematic. Click here for more details.
- lecrapaud/db/alembic/versions/2025_08_25_1434-7ed9963e732f_add_best_score_to_model_selection.py +9 -4
- lecrapaud/db/models/base.py +11 -7
- lecrapaud/db/session.py +29 -4
- {lecrapaud-0.18.7.dist-info → lecrapaud-0.18.9.dist-info}/METADATA +1 -1
- {lecrapaud-0.18.7.dist-info → lecrapaud-0.18.9.dist-info}/RECORD +7 -7
- {lecrapaud-0.18.7.dist-info → lecrapaud-0.18.9.dist-info}/LICENSE +0 -0
- {lecrapaud-0.18.7.dist-info → lecrapaud-0.18.9.dist-info}/WHEEL +0 -0
lecrapaud/db/alembic/versions/2025_08_25_1434-7ed9963e732f_add_best_score_to_model_selection.py
CHANGED
|
@@ -5,26 +5,31 @@ Revises: 72aa496ca65b
|
|
|
5
5
|
Create Date: 2025-08-25 14:34:58.866912
|
|
6
6
|
|
|
7
7
|
"""
|
|
8
|
+
|
|
8
9
|
from typing import Sequence, Union
|
|
9
10
|
|
|
10
11
|
from alembic import op
|
|
11
12
|
import sqlalchemy as sa
|
|
13
|
+
from lecrapaud.config import LECRAPAUD_TABLE_PREFIX
|
|
12
14
|
|
|
13
15
|
|
|
14
16
|
# revision identifiers, used by Alembic.
|
|
15
|
-
revision: str =
|
|
16
|
-
down_revision: Union[str, None] =
|
|
17
|
+
revision: str = "7ed9963e732f"
|
|
18
|
+
down_revision: Union[str, None] = "72aa496ca65b"
|
|
17
19
|
branch_labels: Union[str, Sequence[str], None] = None
|
|
18
20
|
depends_on: Union[str, Sequence[str], None] = None
|
|
19
21
|
|
|
20
22
|
|
|
21
23
|
def upgrade() -> None:
|
|
22
24
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
23
|
-
op.add_column(
|
|
25
|
+
op.add_column(
|
|
26
|
+
f"{LECRAPAUD_TABLE_PREFIX}_model_selections",
|
|
27
|
+
sa.Column("best_score", sa.JSON(), nullable=True),
|
|
28
|
+
)
|
|
24
29
|
# ### end Alembic commands ###
|
|
25
30
|
|
|
26
31
|
|
|
27
32
|
def downgrade() -> None:
|
|
28
33
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
29
|
-
op.drop_column(
|
|
34
|
+
op.drop_column(f"{LECRAPAUD_TABLE_PREFIX}_model_selections", "best_score")
|
|
30
35
|
# ### end Alembic commands ###
|
lecrapaud/db/models/base.py
CHANGED
|
@@ -14,16 +14,20 @@ from lecrapaud.config import LECRAPAUD_TABLE_PREFIX
|
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
def with_db(func):
|
|
17
|
-
"""Decorator to
|
|
18
|
-
|
|
17
|
+
"""Decorator to provide a database session to the wrapped function.
|
|
18
|
+
|
|
19
|
+
If a db parameter is already provided, it will be used. Otherwise,
|
|
20
|
+
a new session will be created and automatically managed.
|
|
21
|
+
"""
|
|
19
22
|
@wraps(func)
|
|
20
23
|
def wrapper(*args, **kwargs):
|
|
21
|
-
db
|
|
22
|
-
|
|
23
|
-
|
|
24
|
+
if "db" in kwargs and kwargs["db"] is not None:
|
|
25
|
+
return func(*args, **kwargs)
|
|
26
|
+
|
|
24
27
|
with get_db() as db:
|
|
25
|
-
|
|
26
|
-
|
|
28
|
+
kwargs["db"] = db
|
|
29
|
+
return func(*args, **kwargs)
|
|
30
|
+
|
|
27
31
|
return wrapper
|
|
28
32
|
|
|
29
33
|
|
lecrapaud/db/session.py
CHANGED
|
@@ -53,11 +53,27 @@ def init_db(uri: str = None):
|
|
|
53
53
|
conn.execute(text(f"CREATE DATABASE IF NOT EXISTS `{db_name}`"))
|
|
54
54
|
conn.commit()
|
|
55
55
|
|
|
56
|
-
# Step 3:
|
|
57
|
-
_engine = create_engine(
|
|
56
|
+
# Step 3: Configure main engine with connection pooling and reconnection settings
|
|
57
|
+
_engine = create_engine(
|
|
58
|
+
DATABASE_URL,
|
|
59
|
+
echo=False,
|
|
60
|
+
pool_pre_ping=True, # Check connection health before using
|
|
61
|
+
pool_recycle=3600, # Recycle connections after 1 hour
|
|
62
|
+
pool_timeout=30, # Wait 30 seconds for a connection from the pool
|
|
63
|
+
pool_size=10, # Maintain up to 10 connections
|
|
64
|
+
max_overflow=10, # Allow up to 10 more connections during spikes
|
|
65
|
+
connect_args={
|
|
66
|
+
"connect_timeout": 10, # 10 second connection timeout
|
|
67
|
+
},
|
|
68
|
+
)
|
|
58
69
|
|
|
59
|
-
# Step 4:
|
|
60
|
-
_SessionLocal = sessionmaker(
|
|
70
|
+
# Step 4: Configure session factory
|
|
71
|
+
_SessionLocal = sessionmaker(
|
|
72
|
+
autocommit=False,
|
|
73
|
+
autoflush=False,
|
|
74
|
+
bind=_engine,
|
|
75
|
+
expire_on_commit=False, # Don't expire objects on commit
|
|
76
|
+
)
|
|
61
77
|
|
|
62
78
|
# Step 5: Apply Alembic migrations programmatically
|
|
63
79
|
current_dir = os.path.dirname(__file__) # → lecrapaud/db
|
|
@@ -76,8 +92,17 @@ def init_db(uri: str = None):
|
|
|
76
92
|
# Dependency to get a session instance
|
|
77
93
|
@contextmanager
|
|
78
94
|
def get_db():
|
|
95
|
+
"""Get a database session with automatic connection management.
|
|
96
|
+
|
|
97
|
+
Yields:
|
|
98
|
+
Session: A SQLAlchemy session instance
|
|
99
|
+
|
|
100
|
+
The session is automatically committed if no exceptions occur, and rolled back otherwise.
|
|
101
|
+
The connection is automatically returned to the pool when the session is closed.
|
|
102
|
+
"""
|
|
79
103
|
if _SessionLocal is None:
|
|
80
104
|
init_db()
|
|
105
|
+
|
|
81
106
|
db = _SessionLocal()
|
|
82
107
|
try:
|
|
83
108
|
yield db
|
|
@@ -9,10 +9,10 @@ lecrapaud/db/alembic/versions/2025_06_23_1748-f089dfb7e3ba_.py,sha256=hyPW0Mt_B4
|
|
|
9
9
|
lecrapaud/db/alembic/versions/2025_06_24_1216-c62251b129ed_.py,sha256=6Pf36HAXEVrVlnrohAe2O7gVaXpDiv3LLIP_EEgTyA0,917
|
|
10
10
|
lecrapaud/db/alembic/versions/2025_06_24_1711-86457e2f333f_.py,sha256=KjwjYvFaNqYmBLTYel8As37fyaBtNVWTqN_3M7y_2eI,1357
|
|
11
11
|
lecrapaud/db/alembic/versions/2025_06_25_1759-72aa496ca65b_.py,sha256=MiqooJuZ1etExl2he3MniaEv8G0LrmqY-0m22m9xKmc,943
|
|
12
|
-
lecrapaud/db/alembic/versions/2025_08_25_1434-7ed9963e732f_add_best_score_to_model_selection.py,sha256=
|
|
12
|
+
lecrapaud/db/alembic/versions/2025_08_25_1434-7ed9963e732f_add_best_score_to_model_selection.py,sha256=gyQDFFHp1dlILuDtXSPdUU_MsLlX-UzTP-E96Aj_Hto,966
|
|
13
13
|
lecrapaud/db/alembic.ini,sha256=Zw2rdwsKV6c7J1SPtoFIPDX08_oTP3MuUKnNxBDiY8I,3796
|
|
14
14
|
lecrapaud/db/models/__init__.py,sha256=Lhyw9fVLdom0Fc6yIP-ip8FjkU1EwVwjae5q2VM815Q,740
|
|
15
|
-
lecrapaud/db/models/base.py,sha256=
|
|
15
|
+
lecrapaud/db/models/base.py,sha256=Sc6g38LsNsjn9-qpWOMSsZlbUER0Xr56-yLIJLpTMDU,7808
|
|
16
16
|
lecrapaud/db/models/experiment.py,sha256=LjsMTY-PA9HZ27D2sz2fWy7HvwFqiS0dXKaiKF-S3k4,14868
|
|
17
17
|
lecrapaud/db/models/feature.py,sha256=5o77O2FyRObnLOCGNj8kaPSGM3pLv1Ov6mXXHYkmnYY,1136
|
|
18
18
|
lecrapaud/db/models/feature_selection.py,sha256=mk42xuw1Sm_7Pznfg7TNc5_S4hscdw79QgIe3Bt9ZRI,3245
|
|
@@ -23,7 +23,7 @@ lecrapaud/db/models/model_training.py,sha256=jAIYPdwBln2jf593soLQ730uYrTfNK8zdG8
|
|
|
23
23
|
lecrapaud/db/models/score.py,sha256=fSfXLt6Dm-8Fy9ku0urMT5Fa6zNqn4YqVnEO4o3zKVI,1669
|
|
24
24
|
lecrapaud/db/models/target.py,sha256=DKnfeaLU8eT8J_oh_vuFo5-o1CaoXR13xBbswme6Bgk,1649
|
|
25
25
|
lecrapaud/db/models/utils.py,sha256=-a-nWWmpJ2XzidIxo2COVUTrGZIPYCfBzjhcszJj_bM,1109
|
|
26
|
-
lecrapaud/db/session.py,sha256=
|
|
26
|
+
lecrapaud/db/session.py,sha256=24vbFhpC2dB3eTMRWc9XFdNOVHdXXt5U6U3_WzXsGA0,3732
|
|
27
27
|
lecrapaud/directories.py,sha256=0LrANuDgbuneSLker60c6q2hmGnQ3mKHIztTGzTx6Gw,826
|
|
28
28
|
lecrapaud/experiment.py,sha256=1xLWjOrqAxJh9CdXOx9ppQuRFRRj0GH-xYZqg-ty9hI,2463
|
|
29
29
|
lecrapaud/feature_engineering.py,sha256=ib1afBrwqePiXUaw0Cpe6hY3VNl5afg8YVntb88SCT4,39199
|
|
@@ -40,7 +40,7 @@ lecrapaud/misc/test-gpu-transformers.ipynb,sha256=k6MBSs_Um1h4PykvE-LTBcdpbWLbIF
|
|
|
40
40
|
lecrapaud/model_selection.py,sha256=gP7Jo_JyI7YVKNk7VG5DjGcheUZsir1vNnTlTCM-R40,72480
|
|
41
41
|
lecrapaud/search_space.py,sha256=-JkzuMhaomdwiWi4HvVQY5hiw3-oREemJA16tbwEIp4,34854
|
|
42
42
|
lecrapaud/utils.py,sha256=ATKu9pbXjYFRa2YzBYjqyLHJrzfnZ7SJrOD_qAnEBYE,8242
|
|
43
|
-
lecrapaud-0.18.
|
|
44
|
-
lecrapaud-0.18.
|
|
45
|
-
lecrapaud-0.18.
|
|
46
|
-
lecrapaud-0.18.
|
|
43
|
+
lecrapaud-0.18.9.dist-info/LICENSE,sha256=MImCryu0AnqhJE_uAZD-PIDKXDKb8sT7v0i1NOYeHTM,11350
|
|
44
|
+
lecrapaud-0.18.9.dist-info/METADATA,sha256=h4ahCgmQFRO_B6zF39_TTmFFIhO9VCdgH4XgEpK7T2g,11081
|
|
45
|
+
lecrapaud-0.18.9.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
|
46
|
+
lecrapaud-0.18.9.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|