Skip to content

Commit

Permalink
Added a timer to the KG creation pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
alexthomas93 committed Aug 15, 2024
1 parent 2b78391 commit 4762cde
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/neo4j_genai/experimental/pipeline/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import enum
import logging
from datetime import datetime
from timeit import default_timer
from typing import Any, AsyncGenerator, Awaitable, Callable, Optional

from pydantic import BaseModel, Field
Expand Down Expand Up @@ -118,7 +119,9 @@ async def execute(self, **kwargs: Any) -> RunResult | None:
if the task run successfully, None if the status update
was unsuccessful.
"""
logger.debug(f"Running component {self.name} with {kwargs}")
logger.info(f"Running component {self.name}")
logger.debug(f"Component {self.name} arguments: {kwargs}")
start_time = default_timer()
try:
await self.set_status(RunStatus.RUNNING)
except PipelineStatusUpdateError:
Expand All @@ -130,6 +133,8 @@ async def execute(self, **kwargs: Any) -> RunResult | None:
status=self.status,
result=component_result,
)
end_time = default_timer()
logger.info(f"Component {self.name} finished in {end_time - start_time}s")
return run_result

def validate_inputs_config(self, input_data: dict[str, Any]) -> None:
Expand Down Expand Up @@ -467,8 +472,12 @@ def validate_inputs_config(self, data: dict[str, Any]) -> None:
task.validate_inputs_config(data)

async def run(self, data: dict[str, Any]) -> dict[str, Any]:
logging.info("Starting pipeline")
start_time = default_timer()
self.validate_inputs_config(data)
self.reinitialize()
orchestrator = Orchestrator(self)
await orchestrator.run(data)
end_time = default_timer()
logging.info(f"Pipeline finished in {end_time - start_time}s")
return self._final_results.all()

0 comments on commit 4762cde

Please sign in to comment.