@@ -217,6 +217,58 @@ def _format_int(value: int) -> str:
217217 return f"{ value :,} "
218218
219219
220+ def _format_short_tokens (value : int ) -> str :
221+ if value >= 1_000_000_000 :
222+ return f"{ value / 1_000_000_000 :.3f} B"
223+ if value >= 1_000_000 :
224+ return f"{ value / 1_000_000 :.1f} M"
225+ return _format_int (value )
226+
227+
228+ def _rows_by_length_and_kind (rows : Iterable [ReportRow ]) -> dict [int , dict [str , ReportRow ]]:
229+ result : dict [int , dict [str , ReportRow ]] = {}
230+ for row in rows :
231+ result .setdefault (row .length , {})[row .kind ] = row
232+ return result
233+
234+
235+ def _print_summary (rows : Iterable [ReportRow ]) -> None :
236+ """Print one unambiguous curriculum row per context length."""
237+ print (
238+ "| length | bs | tokens/step | code tokens | code steps | commit+PR-doc tokens | commit steps | main tokens | main steps | standalone PR tokens | +PR total steps | skipped files |"
239+ )
240+ print ("|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|" )
241+ for length , by_kind in sorted (_rows_by_length_and_kind (rows ).items ()):
242+ main = by_kind .get ("main_code_plus_commits" )
243+ if main is None :
244+ continue
245+ code = by_kind .get ("code_only" )
246+ commits = by_kind .get ("commits_with_pr_docstring" )
247+ pr = by_kind .get ("standalone_pr_side_stream" )
248+ main_pr = by_kind .get ("main_plus_standalone_pr" )
249+ skipped = sum (row .skipped_files for row in by_kind .values ())
250+ print (
251+ "| "
252+ + " | " .join (
253+ [
254+ str (length ),
255+ str (main .batch_size ),
256+ _format_int (main .tokens_per_step ),
257+ _format_short_tokens (code .trained_tokens ) if code else "-" ,
258+ _format_int (code .steps_by_trained_tokens ) if code else "-" ,
259+ _format_short_tokens (commits .trained_tokens ) if commits else "-" ,
260+ _format_int (commits .steps_by_trained_tokens ) if commits else "-" ,
261+ _format_short_tokens (main .trained_tokens ),
262+ _format_int (main .steps_by_trained_tokens ),
263+ _format_short_tokens (pr .trained_tokens ) if pr else "-" ,
264+ _format_int (main_pr .steps_by_trained_tokens ) if main_pr else "-" ,
265+ _format_int (skipped ),
266+ ]
267+ )
268+ + " |"
269+ )
270+
271+
220272def _print_markdown (rows : Iterable [ReportRow ]) -> None :
221273 print (
222274 "| kind | length | bs | tokens/step | files | skipped | rows | docs | trained tokens | steps(trained) | valid tokens | steps(valid) |"
@@ -272,7 +324,12 @@ def main() -> int:
272324 action = "store_true" ,
273325 help = "Skip files that disappear or are unreadable during live conveyor writes, and report the skip count." ,
274326 )
275- parser .add_argument ("--format" , choices = ("text" , "markdown" , "json" ), default = "text" )
327+ parser .add_argument (
328+ "--format" ,
329+ choices = ("summary" , "text" , "markdown" , "json" ),
330+ default = "summary" ,
331+ help = "summary prints one row per bucket; text/markdown print every source kind." ,
332+ )
276333 args = parser .parse_args ()
277334
278335 rows = build_report (
@@ -285,6 +342,8 @@ def main() -> int:
285342 )
286343 if args .format == "json" :
287344 print (json .dumps ([asdict (row ) for row in rows ], indent = 2 , sort_keys = True ))
345+ elif args .format == "summary" :
346+ _print_summary (rows )
288347 elif args .format == "markdown" :
289348 _print_markdown (rows )
290349 else :
0 commit comments