@@ -182,40 +182,48 @@ def test_background_install(
182182def test_not_inplace_install (
183183 mm2_installer : ModelInstallServiceBase , embedding_file : Path , mm2_app_config : InvokeAIAppConfig
184184) -> None :
185+ # An non in-place install will/should call `register_path()` internally
185186 source = LocalModelSource (path = embedding_file , inplace = False )
186187 job = mm2_installer .import_model (source )
187188 mm2_installer .wait_for_installs ()
188189 assert job is not None
189190 assert job .config_out is not None
191+ # Non in-place install should _move_ the model from the original location to the models path
192+ # The model config's path should be different from the original file
190193 assert Path (job .config_out .path ) != embedding_file
194+ # Original file should _not_ exist after install
195+ assert not embedding_file .exists ()
191196 assert (mm2_app_config .models_path / job .config_out .path ).exists ()
192197
193198
194199def test_inplace_install (
195200 mm2_installer : ModelInstallServiceBase , embedding_file : Path , mm2_app_config : InvokeAIAppConfig
196201) -> None :
202+ # An in-place install will/should call `install_path()` internally
197203 source = LocalModelSource (path = embedding_file , inplace = True )
198204 job = mm2_installer .import_model (source )
199205 mm2_installer .wait_for_installs ()
200206 assert job is not None
201207 assert job .config_out is not None
208+ # In-place install should not touch the model file, just register it
209+ # The model config's path should be the same as the original file
202210 assert Path (job .config_out .path ) == embedding_file
211+ # Model file should still exist after install
212+ assert embedding_file .exists ()
203213 assert Path (job .config_out .path ).exists ()
204214
205215
206216def test_delete_install (
207217 mm2_installer : ModelInstallServiceBase , embedding_file : Path , mm2_app_config : InvokeAIAppConfig
208218) -> None :
209219 store = mm2_installer .record_store
210- key = mm2_installer .install_path (embedding_file )
220+ key = mm2_installer .install_path (embedding_file ) # non in-place install
211221 model_record = store .get_model (key )
212222 assert (mm2_app_config .models_path / model_record .path ).exists ()
213- assert embedding_file .exists () # original should still be there after installation
223+ assert not embedding_file .exists ()
214224 mm2_installer .delete (key )
215- assert not (
216- mm2_app_config .models_path / model_record .path
217- ).exists () # after deletion, installed copy should not exist
218- assert embedding_file .exists () # but original should still be there
225+ # after deletion, installed copy should not exist
226+ assert not (mm2_app_config .models_path / model_record .path ).exists ()
219227 with pytest .raises (UnknownModelException ):
220228 store .get_model (key )
221229
@@ -224,10 +232,10 @@ def test_delete_register(
224232 mm2_installer : ModelInstallServiceBase , embedding_file : Path , mm2_app_config : InvokeAIAppConfig
225233) -> None :
226234 store = mm2_installer .record_store
227- key = mm2_installer .register_path (embedding_file )
235+ key = mm2_installer .register_path (embedding_file ) # in-place install
228236 model_record = store .get_model (key )
229237 assert Path (model_record .path ).exists ()
230- assert embedding_file .exists () # original should still be there after installation
238+ assert embedding_file .exists ()
231239 mm2_installer .delete (key )
232240 assert Path (model_record .path ).exists ()
233241 with pytest .raises (UnknownModelException ):
0 commit comments