Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add progress bar on evaluate#1871

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

davide-andreoli
Copy link
Contributor

Added progress bar on evaluate

Hi, following#1657 I've added a progress bar on the evaluate process.
Sincetqdm is already a dependency no dependency needs to be added.

I went for manual updates inside the_handle_case function for better compatibility with the rest of the code.

No styling has been applied to the default tqdm bar, let me know if you'd prefer it to be styled in any way.

@@ -291,11 +307,16 @@ async def _handle_case(case: Case[InputsT, OutputT, MetadataT], report_case_name
eval_span.set_attribute('cases', report.cases)
# TODO(DavidM): Remove this 'averages' attribute once we compute it in the details panel
eval_span.set_attribute('averages', report.averages())

if progress: # pragma: no branch
progress_bar.close() # pyright: ignore[reportPossiblyUnboundVariable]
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we remove the need for these pyright ignores by checking forprogress_bar instead? You'll want to set it toNone aboveif progress: up top, so it always has a value.


limiter = anyio.Semaphore(max_concurrency) if max_concurrency is not None else AsyncExitStack()
if progress: # pragma: no branch
progress_bar = tqdm(total=total_cases, desc=f'Evaluating {name}')
lock = asyncio.Lock()
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's call thisprogress_lock

return await _run_task_and_evaluators(task, case, report_case_name, self.evaluators)
result = await _run_task_and_evaluators(task, case, report_case_name, self.evaluators)
if progress: # pragma: no branch
async with lock: # pyright: ignore[reportPossiblyUnboundVariable, reportGeneralTypeIssues]
Copy link
Contributor

Choose a reason for hiding this comment

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

I want to see if we can get rid of these pyright ignores.

What do you think about creating a newupdate_progress_bar variable up above, and setting it to a function that does this lock and update whenprogress is enabled, orNone if it's not, and only calling it when it's set?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Sure, this could work!
To keep it simpler I followed your other suggestion: I setprogress_bar andprogress_lock only ifprogress is true, and None otherwise.
This way I can check directly if they're set withif progress_bar and progress_lock: removing the need for the ignores.
Let me know if you'd still prefer to have a function perform the update.

@KludexKludex changed the titleAdded progress bar on evaluateAdd progress bar on evaluateJun 6, 2025
@@ -28,6 +29,7 @@
from pydantic._internal import _typing_extra
from pydantic_core import to_json
from pydantic_core.core_schema import SerializationInfo, SerializerFunctionWrapHandler
from tqdm import tqdm
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you update this to use the Rich progress bar fromhttps://rich.readthedocs.io/en/stable/progress.html instead? That should already be a dependency as well.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Sure I'll work on this!

@Kludex
Copy link
Member

@davide-andreoli Are you still interested in helping here?

@davide-andreoli
Copy link
ContributorAuthor

Hi@Kludex, yes I'm still interested.
Sorry for the delay but I'm on vacation, I'll take a look at everything next week!

Kludex reacted with thumbs up emoji

@DouweMDouweM assignedKludex and unassignedDouweMJun 16, 2025
@davide-andreoli
Copy link
ContributorAuthor

Hi@Kludex, everything should have been resolved in the latest commit! Let me know if there's anything else that could be improved.

@davide-andreoli
Copy link
ContributorAuthor

Hi@Kludex,@DouweM
Just making sure that you've not missed this, let me know if there's anything else I should address.

@Kludex
Copy link
Member

There's already a lock inside the update, so in terms of PydanticAI those operations are atomic.

@KludexKludex merged commit00ffe0c intopydantic:mainJun 26, 2025
18 checks passed
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@DouweMDouweMDouweM requested changes

@KludexKludexKludex approved these changes

Assignees

@KludexKludex

Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@davide-andreoli@Kludex@DouweM

[8]ページ先頭

©2009-2025 Movatter.jp