ResultRecorder
ResultRecorder ¶
An abstract base class for recording experiment results, including configuration, metrics, and model outputs.
This class defines the interface for different result recording implementations, such as saving to a local directory, uploading to wandb, or integrating with MLflow.
Source code in flexeval/core/result_recorder/base.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | |
record_config
abstractmethod
¶
record_config(
config: dict[str, Any], group: str | None = None
) -> None
Record the configuration parameters of the experiment.
Parameters:
-
config(dict[str, Any]) –A dictionary containing the configuration parameters of the evaluation.
-
group(str | None, default:None) –An optional group name to organize the configuration.
Source code in flexeval/core/result_recorder/base.py
16 17 18 19 20 21 22 23 24 25 | |
record_metrics
abstractmethod
¶
record_metrics(
metrics: dict[str, Any], group: str | None = None
) -> None
Record the evaluation metrics of the experiment.
Parameters:
-
metrics(dict[str, Any]) –A dictionary containing the evaluation metrics, where keys are metric names and values are the corresponding results.
-
group(str | None, default:None) –An optional group name to organize the metrics.
Source code in flexeval/core/result_recorder/base.py
27 28 29 30 31 32 33 34 35 36 | |
record_model_outputs
abstractmethod
¶
record_model_outputs(
model_outputs: list[dict[str, Any]],
group: str | None = None,
) -> None
Record the outputs generated by the model during evaluation.
Parameters:
-
model_outputs(list[dict[str, Any]]) –A list of dictionaries, where each dictionary represents a single model output. The structure of these dictionaries may vary depending on the specific model and task.
-
group(str | None, default:None) –An optional group name to organize the model outputs.
Source code in flexeval/core/result_recorder/base.py
38 39 40 41 42 43 44 45 46 47 48 | |
is_metrics_saved ¶
is_metrics_saved(group: str | None = None) -> bool
Check if the evaluation metrics have already been saved.
Parameters:
-
group(str | None, default:None) –An optional group name to check for saved metrics.
Source code in flexeval/core/result_recorder/base.py
50 51 52 53 54 55 56 57 | |
acquire_lock ¶
acquire_lock(group: str | None = None) -> bool
Try to acquire an exclusive lock for the evaluation run of the given group, so that multiple processes can share the same output location without running the same evaluation.
Returns:
-
bool–True if the lock is acquired (or the recorder does not support locking),
-
bool–False if another process already holds the lock.
Source code in flexeval/core/result_recorder/base.py
59 60 61 62 63 64 65 66 67 68 | |
release_lock ¶
release_lock(group: str | None = None) -> None
Release the lock acquired by acquire_lock.
Source code in flexeval/core/result_recorder/base.py
70 71 72 73 | |
LocalRecorder ¶
A class to record the results in JSON format.
Parameters:
-
output_dir(str) –The directory to save the results.
-
force(bool, default:False) –Overwrite the existing results.
-
lock_timeout(float, default:300.0) –A lock file (
.lock) that has not been updated for this many seconds is regarded as stale (left by a dead process) and can be taken over. -
heartbeat_interval(float | None, default:None) –The interval in seconds to update the lock file while it is held. Defaults to
lock_timeout / 20.
Source code in flexeval/core/result_recorder/local_recorder.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 | |
heartbeat_interval
instance-attribute
¶
heartbeat_interval = (
heartbeat_interval
if heartbeat_interval is not None
else lock_timeout / 20
)
__init__ ¶
__init__(
output_dir: str,
force: bool = False,
lock_timeout: float = 300.0,
heartbeat_interval: float | None = None,
) -> None
Source code in flexeval/core/result_recorder/local_recorder.py
59 60 61 62 63 64 65 66 67 68 69 70 | |
record_config ¶
record_config(
config: dict[str, Any], group: str | None = None
) -> None
Source code in flexeval/core/result_recorder/local_recorder.py
83 84 85 86 87 88 89 90 91 92 | |
record_metrics ¶
record_metrics(
metrics: dict[str, Any], group: str | None = None
) -> None
Source code in flexeval/core/result_recorder/local_recorder.py
94 95 96 97 98 99 100 101 102 103 | |
record_model_outputs ¶
record_model_outputs(
model_outputs: list[dict[str, Any]],
group: str | None = None,
) -> None
Source code in flexeval/core/result_recorder/local_recorder.py
105 106 107 108 109 110 111 112 113 114 | |
is_metrics_saved ¶
is_metrics_saved(group: str | None = None) -> bool
Source code in flexeval/core/result_recorder/local_recorder.py
116 117 118 119 120 | |
acquire_lock ¶
acquire_lock(group: str | None = None) -> bool
Source code in flexeval/core/result_recorder/local_recorder.py
172 173 174 175 176 177 178 179 180 | |
release_lock ¶
release_lock(group: str | None = None) -> None
Source code in flexeval/core/result_recorder/local_recorder.py
182 183 184 185 186 187 188 189 | |
WandBRecorder ¶
A class to record the results to Weights & Biases.
Parameters:
-
init_kwargs(dict[str, Any] | None, default:None) –The arguments for the
wandb.initfunction. Please refer to the official documentation for the details.
Source code in flexeval/core/result_recorder/wandb_recorder.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | |
__init__ ¶
__init__(init_kwargs: dict[str, Any] | None = None) -> None
Source code in flexeval/core/result_recorder/wandb_recorder.py
17 18 19 20 21 22 23 24 25 | |
record_config ¶
record_config(
config: dict[str, Any], group: str | None = None
) -> None
Source code in flexeval/core/result_recorder/wandb_recorder.py
27 28 29 30 31 | |
record_metrics ¶
record_metrics(
metrics: dict[str, Any], group: str | None = None
) -> None
Source code in flexeval/core/result_recorder/wandb_recorder.py
33 34 35 36 37 | |
record_model_outputs ¶
record_model_outputs(
model_outputs: list[dict[str, Any]],
group: str | None = None,
) -> None
Source code in flexeval/core/result_recorder/wandb_recorder.py
39 40 41 42 43 44 45 46 | |
__del__ ¶
__del__() -> None
Source code in flexeval/core/result_recorder/wandb_recorder.py
48 49 | |