-
Couldn't load subscription status.
- Fork 87
Staging -> Main #603
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Staging -> Main #603
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
2611a23
chore: update pre-commit hooks (#598)
github-actions[bot] 0961902
feat: wrapper correctness and safety guarantees (JUD-2103, JUD-2107) β¦
abhishekg999 da994fa
JUD-2114: Organize LLM UTs (#599)
alanzhang25 bae551c
Remove Local Eval Queue (#600)
alanzhang25 7ac93d6
JUD-2154: Cache Tokens Tests (#601)
alanzhang25 34ecf06
quickfix: only return project id (#602)
justinsheu c2a55c0
Release: Merge staging to main
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -66,7 +66,6 @@ | |
| from judgeval.api import JudgmentSyncClient | ||
| from judgeval.tracer.llm import wrap_provider | ||
| from judgeval.utils.url import url_for | ||
| from judgeval.tracer.local_eval_queue import LocalEvaluationQueue | ||
| from judgeval.tracer.processors import ( | ||
| JudgmentSpanProcessor, | ||
| NoOpJudgmentSpanProcessor, | ||
|
|
@@ -99,7 +98,6 @@ class Tracer(metaclass=SingletonMeta): | |
| "enable_evaluation", | ||
| "resource_attributes", | ||
| "api_client", | ||
| "local_eval_queue", | ||
| "judgment_processor", | ||
| "tracer", | ||
| "agent_context", | ||
|
|
@@ -113,7 +111,6 @@ class Tracer(metaclass=SingletonMeta): | |
| enable_evaluation: bool | ||
| resource_attributes: Optional[Dict[str, Any]] | ||
| api_client: JudgmentSyncClient | ||
| local_eval_queue: LocalEvaluationQueue | ||
| judgment_processor: JudgmentSpanProcessor | ||
| tracer: ABCTracer | ||
| agent_context: ContextVar[Optional[AgentContext]] | ||
|
|
@@ -148,7 +145,6 @@ def __init__( | |
| api_key=self.api_key, | ||
| organization_id=self.organization_id, | ||
| ) | ||
| self.local_eval_queue = LocalEvaluationQueue() | ||
|
|
||
| if initialize: | ||
| self.initialize() | ||
|
|
@@ -159,14 +155,10 @@ def initialize(self) -> Tracer: | |
|
|
||
| self.judgment_processor = NoOpJudgmentSpanProcessor() | ||
| if self.enable_monitoring: | ||
| project_id, project_created = Tracer._resolve_project_id( | ||
| project_id = Tracer._resolve_project_id( | ||
| self.project_name, self.api_key, self.organization_id | ||
| ) or (None, False) | ||
| ) | ||
| if project_id: | ||
| if project_created: | ||
| judgeval_logger.info( | ||
| f"Project {self.project_name} was autocreated successfully." | ||
| ) | ||
| self.judgment_processor = self.get_processor( | ||
| tracer=self, | ||
| project_name=self.project_name, | ||
|
|
@@ -190,9 +182,6 @@ def initialize(self) -> Tracer: | |
| get_version(), | ||
| ) | ||
|
|
||
| if self.enable_evaluation and self.enable_monitoring: | ||
| self.local_eval_queue.start_workers() | ||
|
|
||
| self._initialized = True | ||
| atexit.register(self._atexit_flush) | ||
| return self | ||
|
|
@@ -240,14 +229,14 @@ def get_processor( | |
| @staticmethod | ||
| def _resolve_project_id( | ||
| project_name: str, api_key: str, organization_id: str | ||
| ) -> Tuple[str, bool]: | ||
| ) -> str: | ||
| """Resolve project_id from project_name using the API.""" | ||
| client = JudgmentSyncClient( | ||
| api_key=api_key, | ||
| organization_id=organization_id, | ||
| ) | ||
| response = client.projects_resolve({"project_name": project_name}) | ||
| return response["project_id"], response["project_created"] | ||
| return response["project_id"] | ||
|
|
||
| def get_current_span(self): | ||
| return get_current_span() | ||
|
|
@@ -299,6 +288,7 @@ def add_agent_attributes_to_span(self, span): | |
| ) | ||
| current_agent_context["is_agent_entry_point"] = False | ||
|
|
||
| @dont_throw | ||
| def record_instance_state(self, record_point: Literal["before", "after"], span): | ||
| current_agent_context = self.agent_context.get() | ||
|
|
||
|
|
@@ -955,45 +945,10 @@ def async_evaluate( | |
| eval_run.model_dump(warnings=False) # type: ignore | ||
| ) | ||
| else: | ||
| # Enqueue the evaluation run to the local evaluation queue | ||
| self.local_eval_queue.enqueue(eval_run) | ||
|
|
||
| def wait_for_completion(self, timeout: Optional[float] = 30.0) -> bool: | ||
| """Wait for all evaluations and span processing to complete. | ||
|
|
||
| This method blocks until all queued evaluations are processed and | ||
| all pending spans are flushed to the server. | ||
|
|
||
| Args: | ||
| timeout: Maximum time to wait in seconds. Defaults to 30 seconds. | ||
| None means wait indefinitely. | ||
|
|
||
| Returns: | ||
| True if all processing completed within the timeout, False otherwise. | ||
|
|
||
| """ | ||
| try: | ||
| judgeval_logger.debug( | ||
| "Waiting for all evaluations and spans to complete..." | ||
| judgeval_logger.warning( | ||
| "The scorer provided is not hosted, skipping evaluation." | ||
| ) | ||
|
Comment on lines
+948
to
950
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| # Wait for all queued evaluation work to complete | ||
| eval_completed = self.local_eval_queue.wait_for_completion() | ||
| if not eval_completed: | ||
| judgeval_logger.warning( | ||
| f"Local evaluation queue did not complete within {timeout} seconds" | ||
| ) | ||
| return False | ||
|
|
||
| self.force_flush() | ||
|
|
||
| judgeval_logger.debug("All evaluations and spans completed successfully") | ||
| return True | ||
|
|
||
| except Exception as e: | ||
| judgeval_logger.warning(f"Error while waiting for completion: {e}") | ||
| return False | ||
|
|
||
|
|
||
| def wrap(client: ApiClient) -> ApiClient: | ||
| try: | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Return type annotation should be
Optional[str]since@dont_throwdecorator can cause this to return None on exceptionsPrompt To Fix With AI