Skip to content
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
5 changes: 1 addition & 4 deletions src/olmo_eval/cli/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
from typing import TYPE_CHECKING, Any

import click
from rich.console import Console

from olmo_eval.common import types
from olmo_eval.common.console import console

if TYPE_CHECKING:
from olmo_eval.evals.external.base import ExternalEval
Expand All @@ -19,9 +19,6 @@
from olmo_eval.launch.beaker.launcher import BeakerJobConfig


console = Console(force_terminal=True, width=120)


@dataclass
class FlaggedArg:
"""Argument with its flag type for order tracking."""
Expand Down
9 changes: 9 additions & 0 deletions src/olmo_eval/common/console.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"""Shared Rich console singleton.

Lives in `common` (not `cli`) so non-CLI modules can import it without pulling in
the CLI package and triggering circular imports through `harness.presets`.
"""

from rich.console import Console

console = Console(force_terminal=True, width=120)
16 changes: 2 additions & 14 deletions src/olmo_eval/common/inspection.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
from rich.table import Table
from rich.text import Text

from olmo_eval.common.console import console as shared_console

if TYPE_CHECKING:
from olmo_eval.common.types import Instance, LMRequest, Response

Expand Down Expand Up @@ -161,8 +163,6 @@ def inspect_object(
show_none: Whether to show fields with None values.
"""
if console is None:
from olmo_eval.cli.utils import console as shared_console

console = shared_console

if not is_dataclass(obj) or isinstance(obj, type):
Expand Down Expand Up @@ -208,8 +208,6 @@ def inspect_instance(
import json

if console is None:
from olmo_eval.cli.utils import console as shared_console

console = shared_console

renderables: list[Any] = []
Expand Down Expand Up @@ -308,8 +306,6 @@ def inspect_request(
max_string_length: Maximum length for string values.
"""
if console is None:
from olmo_eval.cli.utils import console as shared_console

console = shared_console

renderables: list[Any] = []
Expand Down Expand Up @@ -832,8 +828,6 @@ def inspect_formatted_request(
When truncating, shows first half and last half.
"""
if console is None:
from olmo_eval.cli.utils import console as shared_console

console = shared_console

# Pattern to match common special tokens
Expand Down Expand Up @@ -909,8 +903,6 @@ def inspect_tokens(
show_decoded: Whether to show decoded token values.
"""
if console is None:
from olmo_eval.cli.utils import console as shared_console

console = shared_console

# Get special token IDs
Expand Down Expand Up @@ -1051,8 +1043,6 @@ def inspect_response(
import json

if console is None:
from olmo_eval.cli.utils import console as shared_console

console = shared_console

renderables: list[Any] = []
Expand Down Expand Up @@ -1153,8 +1143,6 @@ def inspect_task_instances(
logger = get_logger(__name__)

if console is None:
from olmo_eval.cli.utils import console as shared_console

console = shared_console

tokenizer = None
Expand Down
2 changes: 1 addition & 1 deletion src/olmo_eval/runners/common/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from typing import TYPE_CHECKING, Any

from olmo_eval.cli.utils import console
from olmo_eval.common.console import console
from olmo_eval.common.logging import get_logger
from olmo_eval.runners.common.models import (
MetricsOutput,
Expand Down
2 changes: 1 addition & 1 deletion src/olmo_eval/runners/io/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from pathlib import Path
from typing import TYPE_CHECKING, Any

from olmo_eval.cli.utils import console
from olmo_eval.common.console import console
from olmo_eval.common.logging import get_logger
from olmo_eval.runners.common.models import S3Config
from olmo_eval.runners.io.formatting import build_s3_prefix
Expand Down
Loading