diff --git a/src/olmo_eval/cli/utils.py b/src/olmo_eval/cli/utils.py index ba0ad2f0e..6fdd193cc 100644 --- a/src/olmo_eval/cli/utils.py +++ b/src/olmo_eval/cli/utils.py @@ -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 @@ -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.""" diff --git a/src/olmo_eval/common/console.py b/src/olmo_eval/common/console.py new file mode 100644 index 000000000..9106ccff6 --- /dev/null +++ b/src/olmo_eval/common/console.py @@ -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) diff --git a/src/olmo_eval/common/inspection.py b/src/olmo_eval/common/inspection.py index 28ef63fc1..f49b80a55 100644 --- a/src/olmo_eval/common/inspection.py +++ b/src/olmo_eval/common/inspection.py @@ -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 @@ -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): @@ -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] = [] @@ -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] = [] @@ -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 @@ -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 @@ -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] = [] @@ -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 diff --git a/src/olmo_eval/runners/common/mixins.py b/src/olmo_eval/runners/common/mixins.py index 14a685e9c..26fb3dc52 100644 --- a/src/olmo_eval/runners/common/mixins.py +++ b/src/olmo_eval/runners/common/mixins.py @@ -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, diff --git a/src/olmo_eval/runners/io/storage.py b/src/olmo_eval/runners/io/storage.py index f7dd48f96..3228efb82 100644 --- a/src/olmo_eval/runners/io/storage.py +++ b/src/olmo_eval/runners/io/storage.py @@ -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