Skip to content

Commit 77dd69f

Browse files
ItsMrLinmeta-codesync[bot]
authored andcommitted
Override is_available_while_running on DerivedMetric (#5028)
Summary: Pull Request resolved: #5028 `DerivedMetric.is_available_while_running()` currently inherits the base `Metric` default of `False`. This causes `fetch_data_prefer_lookup` to skip derived metrics for running trials -- it returns cached data (which is empty) instead of computing from freshly-fetched base data. Override the classmethod to return `True` so derived metrics always attempt to compute. If base data isn't available, `fetch_trial_data` returns empty data which is handled gracefully downstream. Reviewed By: lena-kashtelyan Differential Revision: D96558279 fbshipit-source-id: 5ae71ecf24aa01f7a11a294ab3579e44f092d1fd
1 parent 1dda964 commit 77dd69f

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

ax/core/derived_metric.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,16 @@ def __init__(
107107
self._relativize_inputs = relativize_inputs
108108
self._as_percent = as_percent
109109

110+
@classmethod
111+
def is_available_while_running(cls) -> bool:
112+
# Derived metrics should always attempt to compute from base data.
113+
# If base data isn't available for running trials, fetch_trial_data
114+
# will return empty data, which is handled gracefully.
115+
# TODO: Ideally this would dynamically check whether all input metrics
116+
# are available while running, but that requires experiment context
117+
# that this classmethod doesn't have access to.
118+
return True
119+
110120
@property
111121
def input_metric_names(self) -> list[str]:
112122
"""Names of metrics that this metric depends on."""

0 commit comments

Comments
 (0)