loom-core 0.1.8__tar.gz → 0.2.0__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.
Files changed (58) hide show
  1. {loom_core-0.1.8 → loom_core-0.2.0}/PKG-INFO +1 -1
  2. {loom_core-0.1.8 → loom_core-0.2.0}/loom/core/engine.py +1 -2
  3. {loom_core-0.1.8 → loom_core-0.2.0}/loom/database/db.py +56 -1
  4. {loom_core-0.1.8 → loom_core-0.2.0}/loom_core.egg-info/PKG-INFO +1 -1
  5. {loom_core-0.1.8 → loom_core-0.2.0}/pyproject.toml +1 -1
  6. {loom_core-0.1.8 → loom_core-0.2.0}/LICENSE +0 -0
  7. {loom_core-0.1.8 → loom_core-0.2.0}/MANIFEST.in +0 -0
  8. {loom_core-0.1.8 → loom_core-0.2.0}/QUICKSTART.md +0 -0
  9. {loom_core-0.1.8 → loom_core-0.2.0}/README.md +0 -0
  10. {loom_core-0.1.8 → loom_core-0.2.0}/loom/__init__.py +0 -0
  11. {loom_core-0.1.8 → loom_core-0.2.0}/loom/cli/__init__.py +0 -0
  12. {loom_core-0.1.8 → loom_core-0.2.0}/loom/cli/cli.py +0 -0
  13. {loom_core-0.1.8 → loom_core-0.2.0}/loom/common/activity.py +0 -0
  14. {loom_core-0.1.8 → loom_core-0.2.0}/loom/common/config.py +0 -0
  15. {loom_core-0.1.8 → loom_core-0.2.0}/loom/common/errors.py +0 -0
  16. {loom_core-0.1.8 → loom_core-0.2.0}/loom/common/workflow.py +0 -0
  17. {loom_core-0.1.8 → loom_core-0.2.0}/loom/core/__init__.py +0 -0
  18. {loom_core-0.1.8 → loom_core-0.2.0}/loom/core/compiled.py +0 -0
  19. {loom_core-0.1.8 → loom_core-0.2.0}/loom/core/context.py +0 -0
  20. {loom_core-0.1.8 → loom_core-0.2.0}/loom/core/handle.py +0 -0
  21. {loom_core-0.1.8 → loom_core-0.2.0}/loom/core/logger.py +0 -0
  22. {loom_core-0.1.8 → loom_core-0.2.0}/loom/core/runner.py +0 -0
  23. {loom_core-0.1.8 → loom_core-0.2.0}/loom/core/state.py +0 -0
  24. {loom_core-0.1.8 → loom_core-0.2.0}/loom/core/worker.py +0 -0
  25. {loom_core-0.1.8 → loom_core-0.2.0}/loom/core/workflow.py +0 -0
  26. {loom_core-0.1.8 → loom_core-0.2.0}/loom/database/__init__.py +0 -0
  27. {loom_core-0.1.8 → loom_core-0.2.0}/loom/decorators/__init__.py +0 -0
  28. {loom_core-0.1.8 → loom_core-0.2.0}/loom/decorators/activity.py +0 -0
  29. {loom_core-0.1.8 → loom_core-0.2.0}/loom/decorators/workflow.py +0 -0
  30. {loom_core-0.1.8 → loom_core-0.2.0}/loom/lib/progress.py +0 -0
  31. {loom_core-0.1.8 → loom_core-0.2.0}/loom/lib/utils.py +0 -0
  32. {loom_core-0.1.8 → loom_core-0.2.0}/loom/migrations/down/001_setup_pragma.sql +0 -0
  33. {loom_core-0.1.8 → loom_core-0.2.0}/loom/migrations/down/002_create_workflows.sql +0 -0
  34. {loom_core-0.1.8 → loom_core-0.2.0}/loom/migrations/down/003.create_events.sql +0 -0
  35. {loom_core-0.1.8 → loom_core-0.2.0}/loom/migrations/down/004.create_tasks.sql +0 -0
  36. {loom_core-0.1.8 → loom_core-0.2.0}/loom/migrations/down/005.create_indexes.sql +0 -0
  37. {loom_core-0.1.8 → loom_core-0.2.0}/loom/migrations/down/006_auto_update_triggers.sql +0 -0
  38. {loom_core-0.1.8 → loom_core-0.2.0}/loom/migrations/down/007_create_logs.sql +0 -0
  39. {loom_core-0.1.8 → loom_core-0.2.0}/loom/migrations/up/001_setup_pragma.sql +0 -0
  40. {loom_core-0.1.8 → loom_core-0.2.0}/loom/migrations/up/002_create_workflows.sql +0 -0
  41. {loom_core-0.1.8 → loom_core-0.2.0}/loom/migrations/up/003_create_events.sql +0 -0
  42. {loom_core-0.1.8 → loom_core-0.2.0}/loom/migrations/up/004_create_tasks.sql +0 -0
  43. {loom_core-0.1.8 → loom_core-0.2.0}/loom/migrations/up/005_create_indexes.sql +0 -0
  44. {loom_core-0.1.8 → loom_core-0.2.0}/loom/migrations/up/006_auto_update_triggers.sql +0 -0
  45. {loom_core-0.1.8 → loom_core-0.2.0}/loom/migrations/up/007_create_logs.sql +0 -0
  46. {loom_core-0.1.8 → loom_core-0.2.0}/loom/schemas/__init__.py +0 -0
  47. {loom_core-0.1.8 → loom_core-0.2.0}/loom/schemas/activity.py +0 -0
  48. {loom_core-0.1.8 → loom_core-0.2.0}/loom/schemas/database.py +0 -0
  49. {loom_core-0.1.8 → loom_core-0.2.0}/loom/schemas/events.py +0 -0
  50. {loom_core-0.1.8 → loom_core-0.2.0}/loom/schemas/tasks.py +0 -0
  51. {loom_core-0.1.8 → loom_core-0.2.0}/loom/schemas/workflow.py +0 -0
  52. {loom_core-0.1.8 → loom_core-0.2.0}/loom_core.egg-info/SOURCES.txt +0 -0
  53. {loom_core-0.1.8 → loom_core-0.2.0}/loom_core.egg-info/dependency_links.txt +0 -0
  54. {loom_core-0.1.8 → loom_core-0.2.0}/loom_core.egg-info/entry_points.txt +0 -0
  55. {loom_core-0.1.8 → loom_core-0.2.0}/loom_core.egg-info/requires.txt +0 -0
  56. {loom_core-0.1.8 → loom_core-0.2.0}/loom_core.egg-info/top_level.txt +0 -0
  57. {loom_core-0.1.8 → loom_core-0.2.0}/setup.cfg +0 -0
  58. {loom_core-0.1.8 → loom_core-0.2.0}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: loom-core
3
- Version: 0.1.8
3
+ Version: 0.2.0
4
4
  Summary: Durable workflow orchestration engine for Python
5
5
  Home-page: https://github.com/satadeep3927/loom
6
6
  Author: Satadeep Dasgupta
@@ -137,5 +137,4 @@ class Engine(Generic[InputT, StateT]):
137
137
  return
138
138
 
139
139
  async with Database[InputT, StateT]() as db:
140
- await db.create_event(workflow_id, "WORKFLOW_COMPLETED", {})
141
- await db.complete_running_step(workflow_id)
140
+ await db.complete_workflow(workflow_id)
@@ -154,6 +154,7 @@ class Database(Generic[InputT, StateT]):
154
154
  "id": row["id"],
155
155
  "name": row["name"],
156
156
  "status": row["status"],
157
+ "version": row["version"],
157
158
  "module": row["module"],
158
159
  "input": row["input"],
159
160
  "created_at": row["created_at"],
@@ -345,7 +346,7 @@ class Database(Generic[InputT, StateT]):
345
346
  )
346
347
 
347
348
  async def workflow_failed(
348
- self, workflow_id: str, error: str, task_id: str = None, task_kind: str = None
349
+ self, workflow_id: str, error: str, task_id: str|None = None, task_kind: str|None = None
349
350
  ) -> None:
350
351
  """Mark a workflow as failed due to an unhandled exception.
351
352
 
@@ -410,6 +411,60 @@ class Database(Generic[InputT, StateT]):
410
411
  (workflow_id,),
411
412
  )
412
413
 
414
+ async def complete_workflow(self, workflow_id: str) -> None:
415
+ """Mark a workflow as successfully completed.
416
+
417
+ Creates a WORKFLOW_COMPLETED event and updates the workflow status.
418
+ Also completes any running step tasks for the workflow.
419
+
420
+ Args:
421
+ workflow_id: Workflow identifier to mark as completed
422
+
423
+ Raises:
424
+ WorkflowNotFoundError: If the workflow doesn't exist
425
+ """
426
+ # Get workflow info (this will raise WorkflowNotFoundError if not found)
427
+ workflow = await self.get_workflow_info(workflow_id)
428
+
429
+ # Skip if already in terminal state
430
+ if workflow["status"] in ("COMPLETED", "FAILED", "CANCELED"):
431
+ return
432
+
433
+ # Create completion event
434
+ await self.execute(
435
+ """
436
+ INSERT INTO events (workflow_id, type, payload)
437
+ VALUES (?, 'WORKFLOW_COMPLETED', ?)
438
+ """,
439
+ (workflow_id, json.dumps({
440
+ "completed_at": datetime.now(timezone.utc).isoformat()
441
+ })),
442
+ )
443
+
444
+ # Update workflow status
445
+ await self.execute(
446
+ """
447
+ UPDATE workflows
448
+ SET status = 'COMPLETED',
449
+ updated_at = CURRENT_TIMESTAMP
450
+ WHERE id = ?
451
+ """,
452
+ (workflow_id,),
453
+ )
454
+
455
+ # Complete any running step tasks
456
+ await self.execute(
457
+ """
458
+ UPDATE tasks
459
+ SET status = 'COMPLETED',
460
+ updated_at = CURRENT_TIMESTAMP
461
+ WHERE workflow_id = ?
462
+ AND kind = 'STEP'
463
+ AND status = 'RUNNING'
464
+ """,
465
+ (workflow_id,),
466
+ )
467
+
413
468
  async def cancel_workflow(
414
469
  self, workflow_id: str, reason: str | None = None
415
470
  ) -> None:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: loom-core
3
- Version: 0.1.8
3
+ Version: 0.2.0
4
4
  Summary: Durable workflow orchestration engine for Python
5
5
  Home-page: https://github.com/satadeep3927/loom
6
6
  Author: Satadeep Dasgupta
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "loom-core"
7
- version = "0.1.8"
7
+ version = "0.2.0"
8
8
  description = "Durable workflow orchestration engine for Python"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.12"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes