Skip to content

Limit number of metrics shown in gather_trajectory_groups #145

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

Merged
merged 3 commits into from
May 28, 2025
Merged
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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "openpipe-art"
version = "0.3.9"
version = "0.3.10"
description = "The OpenPipe Agent Reinforcement Training (ART) library"
readme = "README.md"
requires-python = ">=3.10"
Expand Down
8 changes: 7 additions & 1 deletion src/art/gather.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ async def gather_trajectory_groups(
pbar_desc: str | None = "gather",
pbar_total_completion_tokens: bool = True,
max_exceptions: int | float = 0,
max_metrics: int | None = None,
) -> list[TrajectoryGroup]:
groups = list(groups)
context = GatherContext(
pbar=None,
pbar_total_completion_tokens=pbar_total_completion_tokens,
max_exceptions=max_exceptions,
max_metrics=max_metrics,
)
with set_gather_context(context):
future = asyncio.gather(*[wrap_group_awaitable(g) for g in groups])
Expand Down Expand Up @@ -167,14 +169,18 @@ class GatherContext:
pbar: tqdm.tqdm | None = None
metric_sums: Counter[str] = field(default_factory=Counter)
metric_divisors: Counter[str] = field(default_factory=Counter)
max_metrics: int | None = None
pbar_total_completion_tokens: bool = False
max_exceptions: int | float = 0

def update_pbar(self, n: int) -> None:
if self.pbar is not None:
self.pbar.update(n)
postfix = {}
for metric in self.metric_sums:
included_metrics = self.metric_sums.keys()
if self.max_metrics is not None:
included_metrics = list(self.metric_sums.keys())[: self.max_metrics]
for metric in included_metrics:
sum = self.metric_sums[metric]
divisor = max(1, self.metric_divisors[metric])
postfix[metric] = sum / divisor
Expand Down
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.