ai-pipeline-core 0.4.1__py3-none-any.whl → 0.4.3__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.
@@ -64,7 +64,7 @@ from .prompt_manager import PromptManager
64
64
  from .settings import Settings
65
65
  from .testing import disable_run_logger, prefect_test_harness
66
66
 
67
- __version__ = "0.4.1"
67
+ __version__ = "0.4.3"
68
68
 
69
69
  __all__ = [
70
70
  "AIMessageType",
@@ -51,6 +51,7 @@ from .helpers import (
51
51
  send_webhook,
52
52
  upload_documents,
53
53
  )
54
+ from .progress import flow_context, webhook_worker
54
55
 
55
56
  logger = get_pipeline_logger(__name__)
56
57
 
@@ -132,7 +133,7 @@ class FlowCallable(Protocol):
132
133
  output_document_types: list[type[Document]]
133
134
  estimated_minutes: int
134
135
 
135
- def __call__(self, project_name: str, documents: list[Document], flow_options: FlowOptions) -> Any: # type: ignore[type-arg]
136
+ def __call__(self, project_name: str, documents: list[Document], flow_options: FlowOptions | dict[str, Any]) -> Any: # type: ignore[type-arg]
136
137
  """Execute the flow with standard pipeline signature."""
137
138
  ...
138
139
 
@@ -518,16 +519,39 @@ class PipelineDeployment(Generic[TOptions, TResult]):
518
519
  else:
519
520
  current_docs = input_docs
520
521
 
521
- try:
522
- await active_flow(project_name, current_docs, options)
523
- except Exception as e:
524
- # Upload partial results on failure
525
- if context.output_documents_urls and store:
526
- all_docs = await store.load(run_scope, self._all_document_types())
527
- await upload_documents(all_docs, context.output_documents_urls)
528
- await self._send_completion(context, flow_run_id, project_name, result=None, error=str(e))
529
- completion_sent = True
530
- raise
522
+ # Set up intra-flow progress context so progress_update() works inside flows
523
+ flow_minutes = tuple(getattr(f, "estimated_minutes", 1) for f in self.flows)
524
+ completed_mins = sum(flow_minutes[: max(step - 1, 0)])
525
+ progress_queue: asyncio.Queue[ProgressRun | None] = asyncio.Queue()
526
+ wh_url = context.progress_webhook_url or ""
527
+ worker = asyncio.create_task(webhook_worker(progress_queue, wh_url)) if wh_url else None
528
+
529
+ with flow_context(
530
+ webhook_url=wh_url,
531
+ project_name=project_name,
532
+ run_id=flow_run_id,
533
+ flow_run_id=flow_run_id,
534
+ flow_name=flow_name,
535
+ step=step,
536
+ total_steps=total_steps,
537
+ flow_minutes=flow_minutes,
538
+ completed_minutes=completed_mins,
539
+ queue=progress_queue,
540
+ ):
541
+ try:
542
+ await active_flow(project_name, current_docs, options.model_dump())
543
+ except Exception as e:
544
+ # Upload partial results on failure
545
+ if context.output_documents_urls and store:
546
+ all_docs = await store.load(run_scope, self._all_document_types())
547
+ await upload_documents(all_docs, context.output_documents_urls)
548
+ await self._send_completion(context, flow_run_id, project_name, result=None, error=str(e))
549
+ completion_sent = True
550
+ raise
551
+ finally:
552
+ progress_queue.put_nowait(None)
553
+ if worker:
554
+ await worker
531
555
 
532
556
  # Per-flow upload (load from store since @pipeline_flow saves there)
533
557
  if context.output_documents_urls and store and output_types:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ai-pipeline-core
3
- Version: 0.4.1
3
+ Version: 0.4.3
4
4
  Summary: Core utilities for AI-powered processing pipelines using prefect
5
5
  Project-URL: Homepage, https://github.com/bbarwik/ai-pipeline-core
6
6
  Project-URL: Repository, https://github.com/bbarwik/ai-pipeline-core
@@ -1,11 +1,11 @@
1
- ai_pipeline_core/__init__.py,sha256=REZQInD3-LSShbonlXFpbe-IfjEtr90kkEx3JFxgfMA,3270
1
+ ai_pipeline_core/__init__.py,sha256=YxuYpXNT3kliHsZSnbbwCZxtDAdTgT5TkKp-ONSl-q4,3270
2
2
  ai_pipeline_core/exceptions.py,sha256=csAl7vq6xjSFBF8-UM9WZODCbhsOdOG5zH6IbA8iteM,1280
3
3
  ai_pipeline_core/prompt_manager.py,sha256=3wFkL5rrjtUT1cLInkgyhS8hKnO4MeD1cdXAEuLhgoE,9459
4
4
  ai_pipeline_core/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  ai_pipeline_core/settings.py,sha256=BUz8JEFfJQrdE4rNOhQWwxnTrfekLjWkoy-3wDZQ7PY,5142
6
6
  ai_pipeline_core/testing.py,sha256=jIRrLxNvTwdamucfJoHET2qMeRhhMZV9uEJXO5vAfis,279
7
7
  ai_pipeline_core/deployment/__init__.py,sha256=wTkVK6gcEQvqBajFMTAuodRONpN25yHbR1jtcumf0WQ,900
8
- ai_pipeline_core/deployment/base.py,sha256=ros0VzvkNCwbPgG9D49ceKSjTq857iRHzvW-uhiaNUE,34750
8
+ ai_pipeline_core/deployment/base.py,sha256=4fY9JXLW5PMtn7QFSt8OVRlpKSFTRQ2YnmvB_cZr8H0,36025
9
9
  ai_pipeline_core/deployment/contract.py,sha256=a1qbHhneTGB27oSOUy79CUIhOIzOoq37M63XoIMzA4Y,1952
10
10
  ai_pipeline_core/deployment/deploy.py,sha256=TCF4fH5f-K1ADODZHEyf-x7PJzDbv4qtWxlpoCe_mTs,22909
11
11
  ai_pipeline_core/deployment/helpers.py,sha256=yVtGFUs4AFXkpLkiQ_ale0nXXt5btfWSb5PAbikQHNs,3312
@@ -70,7 +70,7 @@ ai_pipeline_core/observability/_tracking/_writer.py,sha256=xZjwYyIxDzzzPxqkKjYAY
70
70
  ai_pipeline_core/pipeline/__init__.py,sha256=uMv1jwSyq8Ym8Hbn5097twBJLdwN1iMeqnVM4EWyrhA,282
71
71
  ai_pipeline_core/pipeline/decorators.py,sha256=CDJAeOjGLt5Ewc0Jc9zEuwLZwKyutOv89LSRS9dcXmI,37456
72
72
  ai_pipeline_core/pipeline/options.py,sha256=KF4FcT085-IwX8r649v0a9ua5xnApM0qG2wJHWbq39A,438
73
- ai_pipeline_core-0.4.1.dist-info/METADATA,sha256=s6YKwEgTfky-_y2CqKaYnU5yHcxOf_r7MxpdxfRL0OE,29947
74
- ai_pipeline_core-0.4.1.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
75
- ai_pipeline_core-0.4.1.dist-info/licenses/LICENSE,sha256=kKj8mfbdWwkyG3U6n7ztB3bAZlEwShTkAsvaY657i3I,1074
76
- ai_pipeline_core-0.4.1.dist-info/RECORD,,
73
+ ai_pipeline_core-0.4.3.dist-info/METADATA,sha256=j3lgsgzMN1D_4twQ3WqCzzaY1yfQThSKOxwMfZILk50,29947
74
+ ai_pipeline_core-0.4.3.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
75
+ ai_pipeline_core-0.4.3.dist-info/licenses/LICENSE,sha256=kKj8mfbdWwkyG3U6n7ztB3bAZlEwShTkAsvaY657i3I,1074
76
+ ai_pipeline_core-0.4.3.dist-info/RECORD,,