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