Skip to content

Commit

Permalink
[air/output] Only wrap header columns in rich (#36072)
Browse files Browse the repository at this point in the history
In the Ray AIR status table, we currently always try to wrap header columns that are too long using a newline character. However, in the regular console output, this breaks the design. The wraps only work in the rich reporter.

This PR updates the output module to not wrap headers columns per default (cut off instead).

Signed-off-by: Kai Fricke <kai@anyscale.com>
  • Loading branch information
krfricke authored Jun 6, 2023
1 parent 592ba28 commit 7b6028d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions python/ray/tune/experimental/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ def _get_trial_table_data(
param_keys: List[str],
metric_keys: List[str],
all_rows: bool = False,
wrap_headers: bool = False,
) -> _TrialTableData:
"""Generate a table showing the current progress of tuning trials.
Expand All @@ -369,6 +370,7 @@ def _get_trial_table_data(
Including both default and user defined.
Will only be shown if at least one trial is having the key.
all_rows: Force to show all rows.
wrap_headers: If True, header columns can be wrapped with ``\n``.
Returns:
Trial table data, including header and trial table per each status.
Expand All @@ -390,11 +392,11 @@ def _get_trial_table_data(

# get header from metric keys
formatted_metric_columns = [
_max_len(k, max_len=max_column_length, wrap=True) for k in metric_keys
_max_len(k, max_len=max_column_length, wrap=wrap_headers) for k in metric_keys
]

formatted_param_columns = [
_max_len(k, max_len=max_column_length, wrap=True) for k in param_keys
_max_len(k, max_len=max_column_length, wrap=wrap_headers) for k in param_keys
]

metric_header = [
Expand Down Expand Up @@ -633,6 +635,7 @@ def _detect_reporter(

class TuneReporterBase(ProgressReporter):
_heartbeat_threshold = AirVerbosity.DEFAULT
_wrap_headers = False

def __init__(
self,
Expand Down Expand Up @@ -688,6 +691,7 @@ def _get_heartbeat(
param_keys=self._inferred_params,
metric_keys=all_metrics,
all_rows=force_full_output,
wrap_headers=self._wrap_headers,
)
return result, trial_table_data

Expand Down Expand Up @@ -764,6 +768,8 @@ def _print_heartbeat(self, trials, *sys_args, force: bool = False):


class TuneRichReporter(TuneReporterBase):
_wrap_headers = True

def __init__(
self,
verbosity: AirVerbosity,
Expand Down

0 comments on commit 7b6028d

Please sign in to comment.