Loading...
Loading...
02-reusable-code-python/pipelines/__init__.py
"""
파이프라인 오케스트레이션 패턴
4단계(Ingest → Synthesize → Create → Publish) 파이프라인 엔진,
5개 사전 정의 레시피, 생명주기 훅을 제공한다.
@source claude-world/notebooklm-skill
@extracted 2026-03-18
@version 1.0.0
의존성:
- pydantic>=2.0 (필수)
빠른 시작::
import asyncio
from pipelines import (
PipelineOrchestrator,
PipelineStage,
StageResult,
StageStatus,
SourceInput,
create_config_from_recipe,
LoggingHook,
TimingHook,
CheckpointHook,
)
async def my_ingest(config, previous):
# 소스 수집 로직 구현
return StageResult(
stage=PipelineStage.INGEST,
status=StageStatus.COMPLETED,
outputs=["data/raw.json"],
duration_seconds=1.2,
)
async def main():
source = SourceInput(type="url", content="https://example.com/news")
config = create_config_from_recipe("news-to-briefing", source)
orchestrator = PipelineOrchestrator()
orchestrator.register_handler(PipelineStage.INGEST, my_ingest)
hook = LoggingHook()
timing = TimingHook()
orchestrator.register_hook("before_stage", hook.before)
orchestrator.register_hook("after_stage", hook.after)
orchestrator.register_hook("on_error", hook.on_error)
orchestrator.register_hook("before_stage", timing.before)
orchestrator.register_hook("after_stage", timing.after)
report = await orchestrator.run(config)
print(report.summary())
print(timing.get_report())
asyncio.run(main())
"""
from .hooks import CheckpointHook, LoggingHook, TimingHook
from .models import (
PipelineConfig,
PipelineReport,
RecipeDefinition,
SourceInput,
StageResult,
)
from .orchestrator import LifecycleHook, PipelineOrchestrator, StageHandler
from .recipes import create_config_from_recipe, get_recipe, list_recipes
from .types import OutputType, PipelineStage, StageStatus
__all__ = [
# 타입 열거형
"PipelineStage",
"StageStatus",
"OutputType",
# 데이터 모델
"SourceInput",
"StageResult",
"PipelineConfig",
"PipelineReport",
"RecipeDefinition",
# 오케스트레이터 및 타입 별칭
"PipelineOrchestrator",
"StageHandler",
"LifecycleHook",
# 레시피 유틸리티
"get_recipe",
"list_recipes",
"create_config_from_recipe",
# 생명주기 훅
"LoggingHook",
"TimingHook",
"CheckpointHook",
]