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.
- {loom_core-0.1.8 → loom_core-0.2.0}/PKG-INFO +1 -1
- {loom_core-0.1.8 → loom_core-0.2.0}/loom/core/engine.py +1 -2
- {loom_core-0.1.8 → loom_core-0.2.0}/loom/database/db.py +56 -1
- {loom_core-0.1.8 → loom_core-0.2.0}/loom_core.egg-info/PKG-INFO +1 -1
- {loom_core-0.1.8 → loom_core-0.2.0}/pyproject.toml +1 -1
- {loom_core-0.1.8 → loom_core-0.2.0}/LICENSE +0 -0
- {loom_core-0.1.8 → loom_core-0.2.0}/MANIFEST.in +0 -0
- {loom_core-0.1.8 → loom_core-0.2.0}/QUICKSTART.md +0 -0
- {loom_core-0.1.8 → loom_core-0.2.0}/README.md +0 -0
- {loom_core-0.1.8 → loom_core-0.2.0}/loom/__init__.py +0 -0
- {loom_core-0.1.8 → loom_core-0.2.0}/loom/cli/__init__.py +0 -0
- {loom_core-0.1.8 → loom_core-0.2.0}/loom/cli/cli.py +0 -0
- {loom_core-0.1.8 → loom_core-0.2.0}/loom/common/activity.py +0 -0
- {loom_core-0.1.8 → loom_core-0.2.0}/loom/common/config.py +0 -0
- {loom_core-0.1.8 → loom_core-0.2.0}/loom/common/errors.py +0 -0
- {loom_core-0.1.8 → loom_core-0.2.0}/loom/common/workflow.py +0 -0
- {loom_core-0.1.8 → loom_core-0.2.0}/loom/core/__init__.py +0 -0
- {loom_core-0.1.8 → loom_core-0.2.0}/loom/core/compiled.py +0 -0
- {loom_core-0.1.8 → loom_core-0.2.0}/loom/core/context.py +0 -0
- {loom_core-0.1.8 → loom_core-0.2.0}/loom/core/handle.py +0 -0
- {loom_core-0.1.8 → loom_core-0.2.0}/loom/core/logger.py +0 -0
- {loom_core-0.1.8 → loom_core-0.2.0}/loom/core/runner.py +0 -0
- {loom_core-0.1.8 → loom_core-0.2.0}/loom/core/state.py +0 -0
- {loom_core-0.1.8 → loom_core-0.2.0}/loom/core/worker.py +0 -0
- {loom_core-0.1.8 → loom_core-0.2.0}/loom/core/workflow.py +0 -0
- {loom_core-0.1.8 → loom_core-0.2.0}/loom/database/__init__.py +0 -0
- {loom_core-0.1.8 → loom_core-0.2.0}/loom/decorators/__init__.py +0 -0
- {loom_core-0.1.8 → loom_core-0.2.0}/loom/decorators/activity.py +0 -0
- {loom_core-0.1.8 → loom_core-0.2.0}/loom/decorators/workflow.py +0 -0
- {loom_core-0.1.8 → loom_core-0.2.0}/loom/lib/progress.py +0 -0
- {loom_core-0.1.8 → loom_core-0.2.0}/loom/lib/utils.py +0 -0
- {loom_core-0.1.8 → loom_core-0.2.0}/loom/migrations/down/001_setup_pragma.sql +0 -0
- {loom_core-0.1.8 → loom_core-0.2.0}/loom/migrations/down/002_create_workflows.sql +0 -0
- {loom_core-0.1.8 → loom_core-0.2.0}/loom/migrations/down/003.create_events.sql +0 -0
- {loom_core-0.1.8 → loom_core-0.2.0}/loom/migrations/down/004.create_tasks.sql +0 -0
- {loom_core-0.1.8 → loom_core-0.2.0}/loom/migrations/down/005.create_indexes.sql +0 -0
- {loom_core-0.1.8 → loom_core-0.2.0}/loom/migrations/down/006_auto_update_triggers.sql +0 -0
- {loom_core-0.1.8 → loom_core-0.2.0}/loom/migrations/down/007_create_logs.sql +0 -0
- {loom_core-0.1.8 → loom_core-0.2.0}/loom/migrations/up/001_setup_pragma.sql +0 -0
- {loom_core-0.1.8 → loom_core-0.2.0}/loom/migrations/up/002_create_workflows.sql +0 -0
- {loom_core-0.1.8 → loom_core-0.2.0}/loom/migrations/up/003_create_events.sql +0 -0
- {loom_core-0.1.8 → loom_core-0.2.0}/loom/migrations/up/004_create_tasks.sql +0 -0
- {loom_core-0.1.8 → loom_core-0.2.0}/loom/migrations/up/005_create_indexes.sql +0 -0
- {loom_core-0.1.8 → loom_core-0.2.0}/loom/migrations/up/006_auto_update_triggers.sql +0 -0
- {loom_core-0.1.8 → loom_core-0.2.0}/loom/migrations/up/007_create_logs.sql +0 -0
- {loom_core-0.1.8 → loom_core-0.2.0}/loom/schemas/__init__.py +0 -0
- {loom_core-0.1.8 → loom_core-0.2.0}/loom/schemas/activity.py +0 -0
- {loom_core-0.1.8 → loom_core-0.2.0}/loom/schemas/database.py +0 -0
- {loom_core-0.1.8 → loom_core-0.2.0}/loom/schemas/events.py +0 -0
- {loom_core-0.1.8 → loom_core-0.2.0}/loom/schemas/tasks.py +0 -0
- {loom_core-0.1.8 → loom_core-0.2.0}/loom/schemas/workflow.py +0 -0
- {loom_core-0.1.8 → loom_core-0.2.0}/loom_core.egg-info/SOURCES.txt +0 -0
- {loom_core-0.1.8 → loom_core-0.2.0}/loom_core.egg-info/dependency_links.txt +0 -0
- {loom_core-0.1.8 → loom_core-0.2.0}/loom_core.egg-info/entry_points.txt +0 -0
- {loom_core-0.1.8 → loom_core-0.2.0}/loom_core.egg-info/requires.txt +0 -0
- {loom_core-0.1.8 → loom_core-0.2.0}/loom_core.egg-info/top_level.txt +0 -0
- {loom_core-0.1.8 → loom_core-0.2.0}/setup.cfg +0 -0
- {loom_core-0.1.8 → loom_core-0.2.0}/setup.py +0 -0
|
@@ -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:
|
|
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
|
|
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
|
|
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
|
|
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
|