3737class JsonlMetricRecorder (MetricRecorder ):
3838 """Records metric values to JSONL files."""
3939
40- _RUN_PART_REGEX : Final = re .compile ("^[-_a-zA-Z0-9]+$" )
40+ _SECTION_PART_REGEX : Final = re .compile ("^[-_a-zA-Z0-9]+$" )
4141
4242 _output_dir : Path
4343 _file_system : FileSystem
@@ -63,21 +63,21 @@ def __init__(
6363 @override
6464 def record_metrics (
6565 self ,
66- run : str ,
66+ section : str ,
6767 values : Mapping [str , object ],
6868 step_nr : int | None = None ,
6969 * ,
7070 flush : bool = True ,
7171 ) -> None :
72- run = run .strip ()
72+ section = section .strip ()
7373
74- for part in run .split ("/" ):
75- if re .match (self ._RUN_PART_REGEX , part ) is None :
74+ for part in section .split ("/" ):
75+ if re .match (self ._SECTION_PART_REGEX , part ) is None :
7676 raise ValueError (
77- f"`run ` must contain only alphanumeric characters, dash, underscore, and forward slash, but is '{ run } ' instead."
77+ f"`section ` must contain only alphanumeric characters, dash, underscore, and forward slash, but is '{ section } ' instead."
7878 )
7979
80- stream = self ._get_stream (run )
80+ stream = self ._get_stream (section )
8181
8282 values_and_descriptors = []
8383
@@ -127,16 +127,16 @@ def sanitize(value: object, descriptor: MetricDescriptor) -> object:
127127 stream .flush ()
128128 except OSError as ex :
129129 raise MetricRecordError (
130- f"The metric values of the '{ run } ' cannot be saved to the JSON file. See the nested exception for details."
130+ f"The metric values of the '{ section } ' cannot be saved to the JSON file. See the nested exception for details."
131131 ) from ex
132132
133- def _get_stream (self , run : str ) -> TextIO :
133+ def _get_stream (self , section : str ) -> TextIO :
134134 try :
135- return self ._streams [run ]
135+ return self ._streams [section ]
136136 except KeyError :
137137 pass
138138
139- file = self ._output_dir .joinpath (run ).with_suffix (".jsonl" )
139+ file = self ._output_dir .joinpath (section ).with_suffix (".jsonl" )
140140
141141 try :
142142 self ._file_system .make_directory (file .parent )
@@ -149,10 +149,10 @@ def _get_stream(self, run: str) -> TextIO:
149149 fp = self ._file_system .open_text (file , mode = FileMode .APPEND )
150150 except OSError as ex :
151151 raise MetricRecordError (
152- f"The '{ file } ' metric file for the '{ run } run cannot be created. See the nested exception for details."
152+ f"The '{ file } ' metric file for the '{ section } section cannot be created. See the nested exception for details."
153153 ) from ex
154154
155- self ._streams [run ] = fp
155+ self ._streams [section ] = fp
156156
157157 return fp
158158
@@ -184,7 +184,9 @@ def __init__(
184184 self ._metric_descriptors = metric_descriptors
185185
186186 @override
187- def create (self , output_dir : Path , config : object ) -> MetricRecorder :
187+ def create (
188+ self , output_dir : Path , config : object , hyper_params : object
189+ ) -> MetricRecorder :
188190 config = structure (config , JsonlMetricRecorderConfig )
189191
190192 validate (config )
0 commit comments