Skip to content

Change code style to use absolute imports - #33

Merged
pipmc merged 4 commits into
mainfrom
code-style
Nov 27, 2025
Merged

pipmc merged 4 commits into
mainfrom
code-style

Conversation

@pipmc

@pipmc pipmc commented Nov 25, 2025

Copy link
Copy Markdown
Contributor

Think it's best to do this before we move triframe into this repo, so that everything's consistent.

@pipmc pipmc self-assigned this Nov 25, 2025
Comment thread metr_agents/agents.py
Comment on lines -45 to +41
main_message += f"[usage] Tokens used so far: {sample_total_tokens():,}/{state.token_limit:,}."
main_message += f"[usage] Tokens used so far: {state.token_usage:,}/{state.token_limit:,}."

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

See inspect_ai/solver/_task_state.py - this method is now exposed via a public API.

Comment thread metr_agents/agents.py
Comment on lines -50 to +46
relative_usage = sample_total_tokens() / state.token_limit
relative_usage = state.token_usage / state.token_limit

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

See preceding comment

) -> inspect_ai.scorer.Score:
tools = list[inspect_ai.tool.ToolInfo]()
for event in reversed(inspect_ai.log.transcript().events):
if isinstance(event, inspect_ai.event.ModelEvent):

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Note that this was moved from the inspect.log package to the inspect.event package, see here

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not sure that the infra is using a version of inspect from before or after the move

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I believe we’re on 0.3.147 (at least that’s the version my eval sets were using this morning), so after the move

@pipmc
pipmc marked this pull request as ready for review November 25, 2025 14:38
@sjawhar

sjawhar commented Nov 27, 2025

Copy link
Copy Markdown
Contributor

BTW, "absolute imports" a different thing from importing modules instead of functions/classes

@pipmc

pipmc commented Nov 27, 2025

Copy link
Copy Markdown
Contributor Author

BTW, "absolute imports" a different thing from importing modules instead of functions/classes

Ah, I see - reread the Google style guide and some docs on absolute vs relative imports and now understand. Thanks!

@pipmc
pipmc merged commit 6926b8d into main Nov 27, 2025
3 checks passed
@pipmc
pipmc deleted the code-style branch November 27, 2025 21:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants