python/ray/tune/progress_reporter.py
def trial_progress_str(
    trials: List[Trial],
    metric_columns: Union[List[str], Dict[str, str]],
    parameter_columns: Optional[Union[List[str], Dict[str, str]]] = None,
    total_samples: int = 0,
    force_table: bool = False,
    fmt: str = "psql",
    max_rows: Optional[int] = None,
    done: bool = False,
    metric: Optional[str] = None,
    mode: Optional[str] = None,
    sort_by_metric: bool = False,
):
    """Returns a human readable message for printing to the console.

    This contains a table where each row represents a trial, its parameters
    and the current values of its metrics.

    Args:
        trials: List of trials to get progress string for.
        metric_columns: Names of metrics to include.
            If this is a dict, the keys are metric names and the values are
            the names to use in the message. If this is a list, the metric
            name is used in the message directly.
        parameter_columns: Names of parameters to
            include. If this is a dict, the keys are parameter names and the
            values are the names to use in the message. If this is a list,
            the parameter name is used in the message directly. If this is
            empty, all parameters are used in the message.
        total_samples: Total number of trials that will be generated.
        force_table: Force printing a table. If False, a table will
            be printed only at the end of the training for verbosity levels
            above `Verbosity.V2_TRIAL_NORM`.
        fmt: Output format (see tablefmt in tabulate API).
        max_rows: Maximum number of rows in the trial table. Defaults to
            unlimited.
        done: True indicates that the tuning run finished.
        metric: Metric used to sort trials.
        mode: One of [min, max]. Determines whether objective is
            minimizing or maximizing the metric attribute.
        sort_by_metric: Sort terminated trials by metric in the
            intermediate table. Defaults to False.
    """
    messages = []
    delim = "<br>" if fmt == "html" else "\n"
    if len(trials) < 1:
        return delim.join(messages)

    num_trials = len(trials)
    trials_by_state = _get_trials_by_state(trials)

    for local_dir in sorted({t.local_dir for t in trials}):
        messages.append("Result logdir: {}".format(local_dir))

    num_trials_strs = [
        "{} {}".format(len(trials_by_state[state]), state)
        for state in sorted(trials_by_state)
    ]

    if total_samples and total_samples >= sys.maxsize:
        total_samples = "infinite"

    messages.append(
        "Number of trials: {}{} ({})".format(
            num_trials,
            f"/{total_samples}" if total_samples else "",
            ", ".join(num_trials_strs),
        )
    )

    if force_table or (has_verbosity(Verbosity.V2_TRIAL_NORM) and done):
        messages += trial_progress_table(
            trials,
            metric_columns,
            parameter_columns,
            fmt,
            max_rows,
            metric,
            mode,
            sort_by_metric,
        )

    return delim.join(messages)
Returns a human readable message for printing to the console.

    This contains a table where each row represents a trial, its parameters
    and the current values of its metrics.

    Args:
        trials: List of trials to get progress string for.
        metric_columns: Names of metrics to include.
            If this is a dict, the keys are metric names and the values are
            the names to use in the message. If this is a list, the metric
            name is used in the message directly.
        parameter_columns: Names of parameters to
            include. If this is a dict, the keys are parameter names and the
            values are the names to use in the message. If this is a list,
            the parameter name is used in the message directly. If this is
            empty, all parameters are used in the message.
        total_samples: Total number of trials that will be generated.
        force_table: Force printing a table. If False, a table will
            be printed only at the end of the training for verbosity levels
            above `Verbosity.V2_TRIAL_NORM`.
        fmt: Output format (see tablefmt in tabulate API).
        max_rows: Maximum number of rows in the trial table. Defaults to
            unlimited.
        done: True indicates that the tuning run finished.
        metric: Metric used to sort trials.
        mode: One of [min, max]. Determines whether objective is
            minimizing or maximizing the metric attribute.
        sort_by_metric: Sort terminated trials by metric in the
            intermediate table. Defaults to False.
    
Returns a human readable message for printing to the console.
This contains a table where each row represents a trial, its parameters
and the current values of its metrics.
Returns a human readable message for printing to the console . This contains a table where each row represents a trial its parameters and the current values of its metrics .
def trial_progress_str(
    trials: List[Trial],
    metric_columns: Union[List[str], Dict[str, str]],
    parameter_columns: Optional[Union[List[str], Dict[str, str]]] = None,
    total_samples: int = 0,
    force_table: bool = False,
    fmt: str = "psql",
    max_rows: Optional[int] = None,
    done: bool = False,
    metric: Optional[str] = None,
    mode: Optional[str] = None,
    sort_by_metric: bool = False,
):
    messages = []
    delim = "<br>" if fmt == "html" else "\n"
    if len(trials) < 1:
        return delim.join(messages)
    num_trials = len(trials)
    trials_by_state = _get_trials_by_state(trials)
    for local_dir in sorted({t.local_dir for t in trials}):
        messages.append("Result logdir: {}".format(local_dir))
    num_trials_strs = [
        "{} {}".format(len(trials_by_state[state]), state)
        for state in sorted(trials_by_state)
    ]
    if total_samples and total_samples >= sys.maxsize:
        total_samples = "infinite"
    messages.append(
        "Number of trials: {}{} ({})".format(
            num_trials,
            f"/{total_samples}" if total_samples else "",
            ", ".join(num_trials_strs),
        )
    )
    if force_table or (has_verbosity(Verbosity.V2_TRIAL_NORM) and done):
        messages += trial_progress_table(
            trials,
            metric_columns,
            parameter_columns,
            fmt,
            max_rows,
            metric,
            mode,
            sort_by_metric,
        )
    return delim.join(messages)
def trial_progress_str ( trials : List [ Trial ] , metric_columns : Union [ List [ str ] , Dict [ str , str ] ] , parameter_columns : Optional [ Union [ List [ str ] , Dict [ str , str ] ] ] = None , total_samples : int = 0 , force_table : bool = False , fmt : str = "psql" , max_rows : Optional [ int ] = None , done : bool = False , metric : Optional [ str ] = None , mode : Optional [ str ] = None , sort_by_metric : bool = False , ) : messages = [ ] delim = "<br>" if fmt == "html" else "\n" if len ( trials ) < 1 : return delim . join ( messages ) num_trials = len ( trials ) trials_by_state = _get_trials_by_state ( trials ) for local_dir in sorted ( { t . local_dir for t in trials } ) : messages . append ( "Result logdir: {}" . format ( local_dir ) ) num_trials_strs = [ "{} {}" . format ( len ( trials_by_state [ state ] ) , state ) for state in sorted ( trials_by_state ) ] if total_samples and total_samples >= sys . maxsize : total_samples = "infinite" messages . append ( "Number of trials: {}{} ({})" . format ( num_trials , f"/{total_samples}" if total_samples else "" , ", " . join ( num_trials_strs ) , ) ) if force_table or ( has_verbosity ( Verbosity . V2_TRIAL_NORM ) and done ) : messages += trial_progress_table ( trials , metric_columns , parameter_columns , fmt , max_rows , metric , mode , sort_by_metric , ) return delim . join ( messages )
Returns a human readable message for printing to the console.
Returns a human readable message for printing to the console .
"""Returns a human readable message for printing to the console.

    This contains a table where each row represents a trial, its parameters
    and the current values of its metrics.

    Args:
        trials: List of trials to get progress string for.
        metric_columns: Names of metrics to include.
            If this is a dict, the keys are metric names and the values are
            the names to use in the message. If this is a list, the metric
            name is used in the message directly.
        parameter_columns: Names of parameters to
            include. If this is a dict, the keys are parameter names and the
            values are the names to use in the message. If this is a list,
            the parameter name is used in the message directly. If this is
            empty, all parameters are used in the message.
        total_samples: Total number of trials that will be generated.
        force_table: Force printing a table. If False, a table will
            be printed only at the end of the training for verbosity levels
            above `Verbosity.V2_TRIAL_NORM`.
        fmt: Output format (see tablefmt in tabulate API).
        max_rows: Maximum number of rows in the trial table. Defaults to
            unlimited.
        done: True indicates that the tuning run finished.
        metric: Metric used to sort trials.
        mode: One of [min, max]. Determines whether objective is
            minimizing or maximizing the metric attribute.
        sort_by_metric: Sort terminated trials by metric in the
            intermediate table. Defaults to False.
    """
trials
List[Trial]
List of trials to get progress string for.
List of trials to get progress string for .
metric_columns
Union[List[str], Dict[str, str]]
Names of metrics to include.
If this is a dict, the keys are metric names and the values are
the names to use in the message. If this is a list, the metric
name is used in the message directly.
Names of metrics to include . If this is a dict the keys are metric names and the values are the names to use in the message . If this is a list the metric name is used in the message directly .
parameter_columns
Optional[Union[List[str], Dict[str, str]]]
Names of parameters to
include. If this is a dict, the keys are parameter names and the
values are the names to use in the message. If this is a list,
the parameter name is used in the message directly. If this is
empty, all parameters are used in the message.
Names of parameters to include . If this is a dict the keys are parameter names and the values are the names to use in the message . If this is a list the parameter name is used in the message directly . If this is empty all parameters are used in the message .
total_samples
int
Total number of trials that will be generated.
Total number of trials that will be generated .
force_table
bool
Force printing a table. If False, a table will
be printed only at the end of the training for verbosity levels
above `Verbosity.V2_TRIAL_NORM`.
Force printing a table . If False a table will be printed only at the end of the training for verbosity levels above ` Verbosity . V2_TRIAL_NORM ` .
fmt
str
Output format .
Output format .
max_rows
Optional[int]
Maximum number of rows in the trial table. Defaults to
unlimited.
Maximum number of rows in the trial table . Defaults to unlimited .
done
bool
True indicates that the tuning run finished.
True indicates that the tuning run finished .
metric
Optional[str]
Metric used to sort trials.
Metric used to sort trials .
mode
Optional[str]
One of [min, max]. Determines whether objective is
minimizing or maximizing the metric attribute.
One of [ min max ] . Determines whether objective is minimizing or maximizing the metric attribute .
sort_by_metric
bool
Sort terminated trials by metric in the
intermediate table. Defaults to False.
Sort terminated trials by metric in the intermediate table . Defaults to False .