@@ -472,13 +472,56 @@ def test_can_parse_requires_nonempty_tb_dir(tmp_path):
472472
473473 tb_dir = tmp_path / "tb_logs" / "default"
474474 tb_dir .mkdir (parents = True )
475- (tb_dir / "events.out.tfevents" ).write_text ("x" )
475+ (tb_dir / "placeholder.txt" ).write_text ("x" )
476+ assert parser .can_parse (_tr (output_path = tmp_path )) is False # non-empty dir without event files
477+
478+ (tb_dir / "custom.tfevents.log" ).write_text ("x" )
476479 assert parser .can_parse (_tr (output_path = tmp_path )) is False # file-backed parsers also need config
477480
478- (tmp_path / "nemo_config.json" ).write_text ("{}" )
481+ (tmp_path / "nemo_config.json" ).write_text ('{"model": {}}' )
479482 assert parser .can_parse (_tr (output_path = tmp_path )) is True
480483
481484
485+ @pytest .mark .parametrize (
486+ ("parser" , "tb_path" , "config_path" , "config_contents" ),
487+ (
488+ pytest .param (NeMoRunParser (), "tb_logs/default" , "nemo_config.json" , "" , id = "nemo-empty-file" ),
489+ pytest .param (NeMoRunParser (), "tb_logs/default" , "nemo_config.json" , "{}" , id = "nemo-empty-object" ),
490+ pytest .param (NeMoRunParser (), "tb_logs/default" , "nemo_config.json" , "{" , id = "nemo-malformed" ),
491+ pytest .param (
492+ MegatronBridgeParser (),
493+ "experiment/tb_logs" ,
494+ "experiment/configs/ConfigContainer.yaml" ,
495+ "" ,
496+ id = "bridge-empty-file" ,
497+ ),
498+ pytest .param (
499+ MegatronBridgeParser (),
500+ "experiment/tb_logs" ,
501+ "experiment/configs/ConfigContainer.yaml" ,
502+ "{}" ,
503+ id = "bridge-empty-object" ,
504+ ),
505+ pytest .param (
506+ MegatronBridgeParser (),
507+ "experiment/tb_logs" ,
508+ "experiment/configs/ConfigContainer.yaml" ,
509+ "key: [" ,
510+ id = "bridge-malformed" ,
511+ ),
512+ ),
513+ )
514+ def test_can_parse_rejects_invalid_file_config (tmp_path , parser , tb_path , config_path , config_contents ):
515+ tb_dir = tmp_path / tb_path
516+ tb_dir .mkdir (parents = True )
517+ (tb_dir / "events.out.tfevents.1" ).write_text ("x" )
518+ artifact = tmp_path / config_path
519+ artifact .parent .mkdir (parents = True , exist_ok = True )
520+ artifact .write_text (config_contents )
521+
522+ assert parser .can_parse (_tr (output_path = tmp_path )) is False
523+
524+
482525def test_megatron_config_path_points_to_tb_event_file (tmp_path ):
483526 tb_dir = tmp_path / "tensorboard"
484527 tb_dir .mkdir ()
0 commit comments