Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ crewai = {extras = ["tools"], version = "^0.108.0"}
rich = "^13.9.4"
weave = "^0.51.39"
mlflow = "^2.21.1"
ollama = "^0.4.0"
poetry = "^2.1.1"

[tool.poetry.group.dev]
Expand Down
7 changes: 6 additions & 1 deletion src/structsense/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,7 @@ async def align_structured_information(self, extracted_result):
print(extracted_result)

logger.info("Starting alignment process")

start_time_align = time.time()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For measuring performance and duration of code execution, it's better to use time.perf_counter() instead of time.time(). time.time() is based on the system's wall-clock time, which can be adjusted (e.g., by NTP), potentially leading to inaccurate or even negative time differences. time.perf_counter() provides a high-resolution monotonic clock that is unaffected by system time changes, making it ideal for timing operations.

Suggested change
start_time_align = time.time()
start_time_align = time.perf_counter()

# Detect task type
task_type = self._detect_task_type()
logger.info(f"Detected task type for alignment: {task_type}")
Expand Down Expand Up @@ -891,6 +891,8 @@ async def align_structured_information(self, extracted_result):
# Update shared state with the correct structure
self._update_shared_state("aligned_terms", wrapped_result)
logger.info(f"Alignment complete with aligned data")
end_time_align = time.time()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

As mentioned in a previous comment, time.perf_counter() should be used here for consistency and to ensure accurate duration measurement.

Suggested change
end_time_align = time.time()
end_time_align = time.perf_counter()

logger.info(f"Alignment process completed in {end_time_align - start_time_align:.2f} seconds")
return wrapped_result
else:
logger.warning("Alignment crew returned no results")
Expand All @@ -904,6 +906,7 @@ async def judge_alignment(self, aligned_info):
return None

logger.info("Starting judgment of aligned information")
start_time_judge = time.time()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For consistency and to ensure accurate duration measurement, please use time.perf_counter() here as well. time.time() can be unreliable for measuring durations due to system clock adjustments.

Suggested change
start_time_judge = time.time()
start_time_judge = time.perf_counter()


# Detect task type
task_type = self._detect_task_type()
Expand Down Expand Up @@ -945,6 +948,8 @@ async def judge_alignment(self, aligned_info):

self._update_shared_state("judged_terms", wrapped_result)
logger.info(f"Judgment complete with judged data")
end_time_judge = time.time()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

As with the start time, please use time.perf_counter() to ensure the duration calculation is accurate and monotonic.

Suggested change
end_time_judge = time.time()
end_time_judge = time.perf_counter()

logger.info(f"Judgment process completed in {end_time_judge - start_time_judge:.2f} seconds")
return wrapped_result

@listen(judge_alignment)
Expand Down
Loading