@@ -651,9 +651,9 @@ def _selected_model_paths(
651651
652652 model_to_path : t .Dict [str , Path ] = {}
653653 dependencies : t .Dict [str , t .Set [str ]] = {}
654- for relative_path , file_info in indexed_files .items ():
654+ for relative_path , file_models in indexed_files .items ():
655655 path = self .config_path / relative_path
656- for fqn , depends_on in file_info . get ( "models" , {}) .items ():
656+ for fqn , depends_on in file_models .items ():
657657 model_to_path [fqn ] = path
658658 dependencies [fqn ] = set (depends_on )
659659
@@ -673,17 +673,14 @@ def _write_model_index(self, models: UniqueKeyDict[str, Model]) -> None:
673673 if not model_paths :
674674 return
675675
676- files : t .Dict [str , t .Dict [str , t .Any ]] = {}
677- for path in model_paths :
678- files [str (path .relative_to (self .config_path ))] = {
679- "models" : {},
680- }
681-
676+ # Maps each model file to the models it defines and their dependencies.
677+ files : t .Dict [str , t .Dict [str , t .List [str ]]] = {
678+ str (path .relative_to (self .config_path )): {} for path in model_paths
679+ }
682680 for model in models .values ():
683- if model ._path not in model_paths :
684- continue
685- relative_path = str (t .cast (Path , model ._path ).relative_to (self .config_path ))
686- files [relative_path ]["models" ][model .fqn ] = sorted (model .depends_on )
681+ if model ._path in model_paths :
682+ relative_path = str (t .cast (Path , model ._path ).relative_to (self .config_path ))
683+ files [relative_path ][model .fqn ] = sorted (model .depends_on )
687684
688685 self ._model_index_path .parent .mkdir (parents = True , exist_ok = True )
689686 temporary_path = self ._model_index_path .with_suffix (".tmp" )
0 commit comments