Generate a table showing the current progress of tuning trials. Args: trials: List of trials for which progress is to be shown. metric_columns: Metrics to be displayed in the table. parameter_columns: List of parameters to be included in the data max_rows: Maximu
(
trials: List[Trial],
metric_columns: Union[List[str], Dict[str, str]],
parameter_columns: Optional[Union[List[str], Dict[str, str]]] = None,
max_rows: Optional[int] = None,
metric: Optional[str] = None,
mode: Optional[str] = None,
sort_by_metric: bool = False,
max_column_length: int = 20,
)
| 940 | |
| 941 | |
| 942 | def _get_progress_table_data( |
| 943 | trials: List[Trial], |
| 944 | metric_columns: Union[List[str], Dict[str, str]], |
| 945 | parameter_columns: Optional[Union[List[str], Dict[str, str]]] = None, |
| 946 | max_rows: Optional[int] = None, |
| 947 | metric: Optional[str] = None, |
| 948 | mode: Optional[str] = None, |
| 949 | sort_by_metric: bool = False, |
| 950 | max_column_length: int = 20, |
| 951 | ) -> Tuple[List, List[str], Tuple[bool, str]]: |
| 952 | """Generate a table showing the current progress of tuning trials. |
| 953 | |
| 954 | Args: |
| 955 | trials: List of trials for which progress is to be shown. |
| 956 | metric_columns: Metrics to be displayed in the table. |
| 957 | parameter_columns: List of parameters to be included in the data |
| 958 | max_rows: Maximum number of rows to show. If there's overflow, a |
| 959 | message will be shown to the user indicating that some rows |
| 960 | are not displayed |
| 961 | metric: Metric which is being tuned |
| 962 | mode: Sort the table in descending order if mode is "max"; |
| 963 | ascending otherwise |
| 964 | sort_by_metric: If true, the table will be sorted by the metric |
| 965 | max_column_length: Max number of characters in each column |
| 966 | |
| 967 | Returns: |
| 968 | - Trial data |
| 969 | - List of column names |
| 970 | - Overflow tuple: |
| 971 | - boolean indicating whether the table has rows which are hidden |
| 972 | - string with info about the overflowing rows |
| 973 | """ |
| 974 | num_trials = len(trials) |
| 975 | trials_by_state = _get_trials_by_state(trials) |
| 976 | |
| 977 | # Sort terminated trials by metric and mode, descending if mode is "max" |
| 978 | if sort_by_metric: |
| 979 | trials_by_state[Trial.TERMINATED] = sorted( |
| 980 | trials_by_state[Trial.TERMINATED], |
| 981 | reverse=(mode == "max"), |
| 982 | key=lambda t: unflattened_lookup(metric, t.last_result, default=None), |
| 983 | ) |
| 984 | |
| 985 | state_tbl_order = [ |
| 986 | Trial.RUNNING, |
| 987 | Trial.PAUSED, |
| 988 | Trial.PENDING, |
| 989 | Trial.TERMINATED, |
| 990 | Trial.ERROR, |
| 991 | ] |
| 992 | max_rows = max_rows or float("inf") |
| 993 | if num_trials > max_rows: |
| 994 | # TODO(ujvl): suggestion for users to view more rows. |
| 995 | trials_by_state_trunc = _fair_filter_trials( |
| 996 | trials_by_state, max_rows, sort_by_metric |
| 997 | ) |
| 998 | trials = [] |
| 999 | overflow_strs = [] |
no test coverage detected
searching dependent graphs…