@@ -385,6 +385,11 @@ def sync_to_config(self):
385385 def model_exists (self , model_name : str , base_model : BaseModelType , model_type : ModelType , * , rescan = False ) -> bool :
386386 """
387387 Given a model name, returns True if it is a valid identifier.
388+
389+ :param model_name: symbolic name of the model in models.yaml
390+ :param model_type: ModelType enum indicating the type of model to return
391+ :param base_model: BaseModelType enum indicating the base model used by this model
392+ :param rescan: if True, scan_models_directory
388393 """
389394 model_key = self .create_key (model_name , base_model , model_type )
390395 exists = model_key in self .models
@@ -470,7 +475,7 @@ def get_model(
470475
471476 else :
472477 self .models .pop (model_key , None )
473- raise ModelNotFoundException (f"Model not found - { model_key } " )
478+ raise ModelNotFoundException (f'Files for model " { model_key } " not found at { model_path } ' )
474479
475480 # TODO: path
476481 # TODO: is it accurate to use path as id
@@ -508,7 +513,13 @@ def get_model(
508513 _cache = self .cache ,
509514 )
510515
511- def _get_model_path (self , model_config : ModelConfigBase , submodel_type : SubModelType = None ) -> (Path , bool ):
516+ def _get_model_path (
517+ self , model_config : ModelConfigBase , submodel_type : Optional [SubModelType ] = None
518+ ) -> (Path , bool ):
519+ """Extract a model's filesystem path from its config.
520+
521+ :return: The fully qualified Path of the module (or submodule).
522+ """
512523 model_path = model_config .path
513524 is_submodel_override = False
514525
@@ -523,6 +534,7 @@ def _get_model_path(self, model_config: ModelConfigBase, submodel_type: SubModel
523534 return model_path , is_submodel_override
524535
525536 def _get_model_config (self , base_model , model_name , model_type ) -> ModelConfigBase :
537+ """Get a model's config object."""
526538 model_key = self .create_key (model_name , base_model , model_type )
527539 try :
528540 model_config = self .models [model_key ]
@@ -531,12 +543,18 @@ def _get_model_config(self, base_model, model_name, model_type) -> ModelConfigBa
531543 return model_config
532544
533545 def _get_implementation (self , base_model : BaseModelType , model_type : ModelType ) -> type [ModelBase ]:
546+ """Get the concrete implementation class for a specific model type."""
534547 model_class = MODEL_CLASSES [base_model ][model_type ]
535548 return model_class
536549
537550 def _instantiate (
538- self , model_name : str , base_model : BaseModelType , model_type : ModelType , submodel_type : SubModelType = None
551+ self ,
552+ model_name : str ,
553+ base_model : BaseModelType ,
554+ model_type : ModelType ,
555+ submodel_type : Optional [SubModelType ] = None ,
539556 ) -> ModelBase :
557+ """Make a new instance of this model, without loading it."""
540558 model_config = self ._get_model_config (base_model , model_name , model_type )
541559 model_path , is_submodel_override = self ._get_model_path (model_config , submodel_type )
542560 # FIXME: do non-overriden submodels get the right class?
0 commit comments