lecrapaud 0.18.8__tar.gz → 0.18.10__tar.gz

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.

Files changed (46) hide show
  1. {lecrapaud-0.18.8 → lecrapaud-0.18.10}/PKG-INFO +1 -1
  2. {lecrapaud-0.18.8 → lecrapaud-0.18.10}/lecrapaud/db/models/base.py +11 -7
  3. {lecrapaud-0.18.8 → lecrapaud-0.18.10}/lecrapaud/db/session.py +29 -4
  4. {lecrapaud-0.18.8 → lecrapaud-0.18.10}/pyproject.toml +1 -1
  5. {lecrapaud-0.18.8 → lecrapaud-0.18.10}/LICENSE +0 -0
  6. {lecrapaud-0.18.8 → lecrapaud-0.18.10}/README.md +0 -0
  7. {lecrapaud-0.18.8 → lecrapaud-0.18.10}/lecrapaud/__init__.py +0 -0
  8. {lecrapaud-0.18.8 → lecrapaud-0.18.10}/lecrapaud/api.py +0 -0
  9. {lecrapaud-0.18.8 → lecrapaud-0.18.10}/lecrapaud/config.py +0 -0
  10. {lecrapaud-0.18.8 → lecrapaud-0.18.10}/lecrapaud/db/__init__.py +0 -0
  11. {lecrapaud-0.18.8 → lecrapaud-0.18.10}/lecrapaud/db/alembic/README +0 -0
  12. {lecrapaud-0.18.8 → lecrapaud-0.18.10}/lecrapaud/db/alembic/env.py +0 -0
  13. {lecrapaud-0.18.8 → lecrapaud-0.18.10}/lecrapaud/db/alembic/script.py.mako +0 -0
  14. {lecrapaud-0.18.8 → lecrapaud-0.18.10}/lecrapaud/db/alembic/versions/2025_06_23_1748-f089dfb7e3ba_.py +0 -0
  15. {lecrapaud-0.18.8 → lecrapaud-0.18.10}/lecrapaud/db/alembic/versions/2025_06_24_1216-c62251b129ed_.py +0 -0
  16. {lecrapaud-0.18.8 → lecrapaud-0.18.10}/lecrapaud/db/alembic/versions/2025_06_24_1711-86457e2f333f_.py +0 -0
  17. {lecrapaud-0.18.8 → lecrapaud-0.18.10}/lecrapaud/db/alembic/versions/2025_06_25_1759-72aa496ca65b_.py +0 -0
  18. {lecrapaud-0.18.8 → lecrapaud-0.18.10}/lecrapaud/db/alembic/versions/2025_08_25_1434-7ed9963e732f_add_best_score_to_model_selection.py +0 -0
  19. {lecrapaud-0.18.8 → lecrapaud-0.18.10}/lecrapaud/db/alembic.ini +0 -0
  20. {lecrapaud-0.18.8 → lecrapaud-0.18.10}/lecrapaud/db/models/__init__.py +0 -0
  21. {lecrapaud-0.18.8 → lecrapaud-0.18.10}/lecrapaud/db/models/experiment.py +0 -0
  22. {lecrapaud-0.18.8 → lecrapaud-0.18.10}/lecrapaud/db/models/feature.py +0 -0
  23. {lecrapaud-0.18.8 → lecrapaud-0.18.10}/lecrapaud/db/models/feature_selection.py +0 -0
  24. {lecrapaud-0.18.8 → lecrapaud-0.18.10}/lecrapaud/db/models/feature_selection_rank.py +0 -0
  25. {lecrapaud-0.18.8 → lecrapaud-0.18.10}/lecrapaud/db/models/model.py +0 -0
  26. {lecrapaud-0.18.8 → lecrapaud-0.18.10}/lecrapaud/db/models/model_selection.py +0 -0
  27. {lecrapaud-0.18.8 → lecrapaud-0.18.10}/lecrapaud/db/models/model_training.py +0 -0
  28. {lecrapaud-0.18.8 → lecrapaud-0.18.10}/lecrapaud/db/models/score.py +0 -0
  29. {lecrapaud-0.18.8 → lecrapaud-0.18.10}/lecrapaud/db/models/target.py +0 -0
  30. {lecrapaud-0.18.8 → lecrapaud-0.18.10}/lecrapaud/db/models/utils.py +0 -0
  31. {lecrapaud-0.18.8 → lecrapaud-0.18.10}/lecrapaud/directories.py +0 -0
  32. {lecrapaud-0.18.8 → lecrapaud-0.18.10}/lecrapaud/experiment.py +0 -0
  33. {lecrapaud-0.18.8 → lecrapaud-0.18.10}/lecrapaud/feature_engineering.py +0 -0
  34. {lecrapaud-0.18.8 → lecrapaud-0.18.10}/lecrapaud/feature_selection.py +0 -0
  35. {lecrapaud-0.18.8 → lecrapaud-0.18.10}/lecrapaud/integrations/openai_integration.py +0 -0
  36. {lecrapaud-0.18.8 → lecrapaud-0.18.10}/lecrapaud/jobs/__init__.py +0 -0
  37. {lecrapaud-0.18.8 → lecrapaud-0.18.10}/lecrapaud/jobs/config.py +0 -0
  38. {lecrapaud-0.18.8 → lecrapaud-0.18.10}/lecrapaud/jobs/scheduler.py +0 -0
  39. {lecrapaud-0.18.8 → lecrapaud-0.18.10}/lecrapaud/jobs/tasks.py +0 -0
  40. {lecrapaud-0.18.8 → lecrapaud-0.18.10}/lecrapaud/misc/tabpfn_tests.ipynb +0 -0
  41. {lecrapaud-0.18.8 → lecrapaud-0.18.10}/lecrapaud/misc/test-gpu-bilstm.ipynb +0 -0
  42. {lecrapaud-0.18.8 → lecrapaud-0.18.10}/lecrapaud/misc/test-gpu-resnet.ipynb +0 -0
  43. {lecrapaud-0.18.8 → lecrapaud-0.18.10}/lecrapaud/misc/test-gpu-transformers.ipynb +0 -0
  44. {lecrapaud-0.18.8 → lecrapaud-0.18.10}/lecrapaud/model_selection.py +0 -0
  45. {lecrapaud-0.18.8 → lecrapaud-0.18.10}/lecrapaud/search_space.py +0 -0
  46. {lecrapaud-0.18.8 → lecrapaud-0.18.10}/lecrapaud/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: lecrapaud
3
- Version: 0.18.8
3
+ Version: 0.18.10
4
4
  Summary: Framework for machine and deep learning, with regression, classification and time series analysis
5
5
  License: Apache License
6
6
  Author: Pierre H. Gallet
@@ -14,16 +14,20 @@ from lecrapaud.config import LECRAPAUD_TABLE_PREFIX
14
14
 
15
15
 
16
16
  def with_db(func):
17
- """Decorator to allow passing an optional db session"""
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 = kwargs.pop("db", None)
22
- if db:
23
- return func(*args, db=db, **kwargs)
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
- return func(*args, db=db, **kwargs)
26
-
28
+ kwargs["db"] = db
29
+ return func(*args, **kwargs)
30
+
27
31
  return wrapper
28
32
 
29
33
 
@@ -12,6 +12,7 @@ from lecrapaud.config import DB_USER, DB_PASSWORD, DB_HOST, DB_PORT, DB_NAME, DB
12
12
 
13
13
  _engine = None
14
14
  _SessionLocal = None
15
+
15
16
  if DB_URI:
16
17
  if "mysql://" in DB_URI and "pymysql://" not in DB_URI:
17
18
  DB_URI = DB_URI.replace("mysql://", "mysql+pymysql://")
@@ -53,11 +54,26 @@ def init_db(uri: str = None):
53
54
  conn.execute(text(f"CREATE DATABASE IF NOT EXISTS `{db_name}`"))
54
55
  conn.commit()
55
56
 
56
- # Step 3: Connect to the newly created database
57
- _engine = create_engine(DATABASE_URL, echo=False)
57
+ # Step 3: Configure main engine with connection pooling and reconnection settings
58
+ _engine = create_engine(
59
+ DATABASE_URL,
60
+ echo=False,
61
+ pool_pre_ping=True, # Check connection health before using
62
+ pool_recycle=3600, # Recycle connections after 1 hour
63
+ pool_timeout=30, # Wait 30 seconds for a connection from the pool
64
+ pool_size=10, # Maintain up to 10 connections
65
+ max_overflow=10, # Allow up to 10 more connections during spikes
66
+ connect_args={
67
+ "connect_timeout": 10, # 10 second connection timeout
68
+ },
69
+ )
58
70
 
59
- # Step 4: Create session factory
60
- _SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=_engine)
71
+ # Step 4: Configure session factory
72
+ _SessionLocal = sessionmaker(
73
+ autocommit=False,
74
+ autoflush=False,
75
+ bind=_engine,
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
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "lecrapaud"
3
- version = "0.18.8"
3
+ version = "0.18.10"
4
4
  description = "Framework for machine and deep learning, with regression, classification and time series analysis"
5
5
  authors = [
6
6
  {name = "Pierre H. Gallet"}
File without changes
File without changes
File without changes