File tree Expand file tree Collapse file tree 1 file changed +14
-6
lines changed
Expand file tree Collapse file tree 1 file changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -148,27 +148,35 @@ def init_tuning_records(
148148
149149
150150def export_record_to_csv (
151- objects : list [TuningRecord ], dest_dir : Path , filename : str = "export.csv"
151+ tuning_records : list [TuningRecord ], dest_dir : Path , filename : str = "export.csv"
152152) -> Optional [Path ]:
153- if not objects :
153+ """
154+ Exports a list of `TuningRecord` objects to a CSV file.
155+
156+ - Each record becomes one CSV row.
157+ - Top-level attributes (e.g., `gen_id`, `benchmark_time_us`) are written as individual columns.
158+ - Nested object (i.e., `knob`) is flattened using dot notation: knob.tile_m, knob.intrinsic_mn
159+
160+ """
161+ if not tuning_records :
154162 return None
155163
156164 rows = []
157165 headers = []
158166
159- for obj in objects :
167+ for tuning_record in tuning_records :
160168 row = {}
161- for k , v in vars (obj ).items ():
169+ for k , v in vars (tuning_record ).items ():
162170 if hasattr (v , "__dict__" ):
163171 nested = vars (v )
164- if nested : # only if it has attrs
172+ if nested : # Only if it has attrs.
165173 for nk , nv in nested .items ():
166174 key = f"{ k } .{ nk } "
167175 row [key ] = nv
168176 if key not in headers :
169177 headers .append (key )
170178 else :
171- # skip empty nested object entirely
179+ # Skip empty nested object entirely.
172180 continue
173181 else :
174182 row [k ] = v
You can’t perform that action at this time.
0 commit comments