flowyml 1.7.0__py3-none-any.whl → 1.7.1__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.
flowyml/storage/sql.py CHANGED
@@ -249,6 +249,9 @@ class SQLMetadataStore(MetadataStore):
249
249
  stmt = select(self.runs).where(self.runs.c.run_id == run_id)
250
250
  existing = conn.execute(stmt).fetchone()
251
251
 
252
+ # Ensure run_id is included in metadata for consistency
253
+ metadata_with_id = {**metadata, "run_id": run_id}
254
+
252
255
  values = {
253
256
  "run_id": run_id,
254
257
  "pipeline_name": metadata.get("pipeline_name"),
@@ -256,7 +259,7 @@ class SQLMetadataStore(MetadataStore):
256
259
  "start_time": metadata.get("start_time"),
257
260
  "end_time": metadata.get("end_time"),
258
261
  "duration": metadata.get("duration"),
259
- "metadata": json.dumps(metadata),
262
+ "metadata": json.dumps(metadata_with_id),
260
263
  "project": metadata.get("project"),
261
264
  }
262
265
 
@@ -299,7 +302,10 @@ class SQLMetadataStore(MetadataStore):
299
302
  stmt = select(self.runs.c.metadata).where(self.runs.c.run_id == run_id)
300
303
  row = conn.execute(stmt).fetchone()
301
304
  if row:
302
- return json.loads(row[0])
305
+ data = json.loads(row[0])
306
+ # Ensure run_id is always included in the returned dict
307
+ data["run_id"] = run_id
308
+ return data
303
309
  return None
304
310
 
305
311
  def update_run_project(self, run_id: str, project_name: str) -> None:
@@ -325,12 +331,18 @@ class SQLMetadataStore(MetadataStore):
325
331
  def list_runs(self, limit: int | None = None) -> list[dict]:
326
332
  """List all runs."""
327
333
  with self.engine.connect() as conn:
328
- stmt = select(self.runs.c.metadata).order_by(self.runs.c.created_at.desc())
334
+ stmt = select(self.runs.c.run_id, self.runs.c.metadata).order_by(self.runs.c.created_at.desc())
329
335
  if limit:
330
336
  stmt = stmt.limit(limit)
331
337
 
332
338
  rows = conn.execute(stmt).fetchall()
333
- return [json.loads(row[0]) for row in rows]
339
+ runs = []
340
+ for row in rows:
341
+ data = json.loads(row[1])
342
+ # Ensure run_id is always included in the returned dict
343
+ data["run_id"] = row[0]
344
+ runs.append(data)
345
+ return runs
334
346
 
335
347
  def list_pipelines(self, project: str = None) -> list[str]:
336
348
  """List all unique pipeline names."""
@@ -402,7 +414,7 @@ class SQLMetadataStore(MetadataStore):
402
414
  def query(self, **filters) -> list[dict]:
403
415
  """Query runs with filters."""
404
416
  with self.engine.connect() as conn:
405
- stmt = select(self.runs.c.metadata)
417
+ stmt = select(self.runs.c.run_id, self.runs.c.metadata)
406
418
 
407
419
  for key, value in filters.items():
408
420
  if hasattr(self.runs.c, key):
@@ -410,7 +422,13 @@ class SQLMetadataStore(MetadataStore):
410
422
 
411
423
  stmt = stmt.order_by(self.runs.c.created_at.desc())
412
424
  rows = conn.execute(stmt).fetchall()
413
- return [json.loads(row[0]) for row in rows]
425
+ runs = []
426
+ for row in rows:
427
+ data = json.loads(row[1])
428
+ # Ensure run_id is always included in the returned dict
429
+ data["run_id"] = row[0]
430
+ runs.append(data)
431
+ return runs
414
432
 
415
433
  def save_metric(self, run_id: str, name: str, value: float, step: int = 0) -> None:
416
434
  """Save a single metric value."""