sqlsaber 0.31.0__py3-none-any.whl → 0.32.0__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 sqlsaber might be problematic. Click here for more details.

sqlsaber/cli/commands.py CHANGED
@@ -1,6 +1,7 @@
1
1
  """CLI command definitions and handlers."""
2
2
 
3
3
  import asyncio
4
+ import os
4
5
  import sys
5
6
  from typing import Annotated
6
7
 
@@ -43,6 +44,52 @@ app.command(create_threads_app(), name="threads")
43
44
  console = create_console()
44
45
  config_manager = DatabaseConfigManager()
45
46
 
47
+ _MLFLOW_CONFIGURED = False
48
+
49
+
50
+ def _maybe_configure_mlflow(log) -> bool:
51
+ """Enable mlflow autologging when environment variables are present."""
52
+ global _MLFLOW_CONFIGURED
53
+ if _MLFLOW_CONFIGURED:
54
+ return True
55
+
56
+ tracking_uri = os.getenv("MLFLOW_URI")
57
+ experiment = os.getenv("MLFLOW_EXP")
58
+ if not tracking_uri and not experiment:
59
+ return False
60
+
61
+ try:
62
+ import mlflow
63
+ except ModuleNotFoundError:
64
+ log.warning(
65
+ "mlflow.setup.skipped",
66
+ reason="mlflow package not installed",
67
+ uri=tracking_uri,
68
+ experiment=experiment,
69
+ )
70
+ return False
71
+
72
+ try:
73
+ mlflow.pydantic_ai.autolog()
74
+ except Exception:
75
+ log.warning("mlflow.autolog.failed", exc_info=True)
76
+ try:
77
+ if tracking_uri:
78
+ mlflow.set_tracking_uri(tracking_uri)
79
+ if experiment:
80
+ mlflow.set_experiment(experiment)
81
+ except Exception:
82
+ log.warning("mlflow.setup.failed", exc_info=True)
83
+ return False
84
+
85
+ _MLFLOW_CONFIGURED = True
86
+ log.info(
87
+ "mlflow.setup.enabled",
88
+ uri=tracking_uri,
89
+ experiment=experiment,
90
+ )
91
+ return True
92
+
46
93
 
47
94
  @app.meta.default
48
95
  def meta_handler(
@@ -175,6 +222,7 @@ def query(
175
222
 
176
223
  # Create pydantic-ai agent instance with database name for memory context
177
224
  sqlsaber_agent = SQLSaberAgent(db_conn, db_name, thinking_enabled=thinking)
225
+ _maybe_configure_mlflow(log)
178
226
 
179
227
  try:
180
228
  if actual_query:
@@ -188,6 +236,7 @@ def query(
188
236
  run = await streaming_handler.execute_streaming_query(
189
237
  actual_query, sqlsaber_agent
190
238
  )
239
+
191
240
  # Persist non-interactive run as a thread snapshot so it can be resumed later
192
241
  try:
193
242
  if run is not None:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sqlsaber
3
- Version: 0.31.0
3
+ Version: 0.32.0
4
4
  Summary: SQLsaber - Open-source agentic SQL assistant
5
5
  License-File: LICENSE
6
6
  Requires-Python: >=3.12
@@ -10,7 +10,7 @@ sqlsaber/application/model_selection.py,sha256=fSC06MZNKinHDR-csMFVYYJFyK8MydKf6
10
10
  sqlsaber/application/prompts.py,sha256=4rMGcWpYJbNWPMzqVWseUMx0nwvXOkWS6GaTAJ5mhfc,3473
11
11
  sqlsaber/cli/__init__.py,sha256=qVSLVJLLJYzoC6aj6y9MFrzZvAwc4_OgxU9DlkQnZ4M,86
12
12
  sqlsaber/cli/auth.py,sha256=8BsAkOYarLSpGipYi2CCUqyAv7EbOCqVXKLmdrX_g2c,6966
13
- sqlsaber/cli/commands.py,sha256=eH6jC2coaH6QhJAlOySBxEHfETWW283fBr6BQG60Bl8,9732
13
+ sqlsaber/cli/commands.py,sha256=WocWlLrxA5kM8URfvIvWFtc0ocfgKWAwoYTxVNZhmM4,10962
14
14
  sqlsaber/cli/completers.py,sha256=g-hLDq5fiBx7gg8Bte1Lq8GU-ZxCYVs4dcPsmHPIcK4,6574
15
15
  sqlsaber/cli/database.py,sha256=BBGj0eyduh5DDXNLZLDtWfY9kWpeT_ZX0J9R9INZyyU,12421
16
16
  sqlsaber/cli/display.py,sha256=WB5JCumhXadziDEX1EZHG3vN1Chol5FNAaTXHieqFK0,17892
@@ -51,8 +51,8 @@ sqlsaber/tools/base.py,sha256=NKEEooliPKTJj_Pomwte_wW0Xd9Z5kXNfVdCRfTppuw,883
51
51
  sqlsaber/tools/registry.py,sha256=XmBzERq0LJXtg3BZ-r8cEyt8J54NUekgUlTJ_EdSYMk,2204
52
52
  sqlsaber/tools/sql_guard.py,sha256=dTDwcZP-N4xPGzcr7MQtKUxKrlDzlc1irr9aH5a4wvk,6182
53
53
  sqlsaber/tools/sql_tools.py,sha256=eo-NTxiXGHMopAjujvDDjmv9hf5bQNbiy3nTpxoJ_E8,7369
54
- sqlsaber-0.31.0.dist-info/METADATA,sha256=B5_gtNMDPZ9pEIMaAHvuvx9XvyaTS3ENl3A37d1-A_o,5915
55
- sqlsaber-0.31.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
56
- sqlsaber-0.31.0.dist-info/entry_points.txt,sha256=tw1mB0fjlkXQiOsC0434X6nE-o1cFCuQwt2ZYHv_WAE,91
57
- sqlsaber-0.31.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
58
- sqlsaber-0.31.0.dist-info/RECORD,,
54
+ sqlsaber-0.32.0.dist-info/METADATA,sha256=Ai3-BNq7KNZ1oA4W-39jp6YTHIE_9ZApz_z0vCkVPyI,5915
55
+ sqlsaber-0.32.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
56
+ sqlsaber-0.32.0.dist-info/entry_points.txt,sha256=tw1mB0fjlkXQiOsC0434X6nE-o1cFCuQwt2ZYHv_WAE,91
57
+ sqlsaber-0.32.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
58
+ sqlsaber-0.32.0.dist-info/RECORD,,