Skip to content

Commit 1424b7c

Browse files
authored
Merge branch 'main' into bugfix/heathen711/rocm-docker
2 parents ae4e38c + 933fb22 commit 1424b7c

File tree

4 files changed

+22
-22
lines changed

4 files changed

+22
-22
lines changed

invokeai/app/services/model_install/model_install_default.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import time
88
from pathlib import Path
99
from queue import Empty, Queue
10-
from shutil import copyfile, copytree, move, rmtree
10+
from shutil import move, rmtree
1111
from tempfile import mkdtemp
1212
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Type, Union
1313

@@ -193,7 +193,7 @@ def install_path(
193193
self.app_config.models_path / info.base.value / info.type.value / (preferred_name or model_path.name)
194194
)
195195
try:
196-
new_path = self._copy_model(model_path, dest_path)
196+
new_path = self._move_model(model_path, dest_path)
197197
except FileExistsError as excp:
198198
raise DuplicateModelException(
199199
f"A model named {model_path.name} is already installed at {dest_path.as_posix()}"
@@ -618,16 +618,6 @@ def sync_model_path(self, key: str) -> AnyModelConfig:
618618
self.record_store.update_model(key, ModelRecordChanges(path=model.path))
619619
return model
620620

621-
def _copy_model(self, old_path: Path, new_path: Path) -> Path:
622-
if old_path == new_path:
623-
return old_path
624-
new_path.parent.mkdir(parents=True, exist_ok=True)
625-
if old_path.is_dir():
626-
copytree(old_path, new_path)
627-
else:
628-
copyfile(old_path, new_path)
629-
return new_path
630-
631621
def _move_model(self, old_path: Path, new_path: Path) -> Path:
632622
if old_path == new_path:
633623
return old_path

invokeai/frontend/web/src/features/gallery/store/types.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ import z from 'zod';
33

44
const zGalleryView = z.enum(['images', 'assets']);
55
export type GalleryView = z.infer<typeof zGalleryView>;
6-
const zBoardId = z.union([z.literal('none'), z.intersection(z.string(), z.record(z.never(), z.never()))]);
7-
export type BoardId = z.infer<typeof zBoardId>;
6+
const zBoardId = z.string();
7+
// TS hack to get autocomplete for "none" but accept any string
8+
export type BoardId = 'none' | (string & {});
89
const zComparisonMode = z.enum(['slider', 'side-by-side', 'hover']);
910
export type ComparisonMode = z.infer<typeof zComparisonMode>;
1011
const zComparisonFit = z.enum(['contain', 'fill']);

invokeai/frontend/web/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export { default as InvokeAIUI } from './app/components/InvokeAIUI';
3232
export type { StudioInitAction } from './app/hooks/useStudioInitAction';
3333
export type { LoggingOverrides } from './app/logging/logger';
3434
export type { PartialAppConfig } from './app/types/invokeai';
35+
export { default as Loading } from './common/components/Loading/Loading';
3536
export { default as HotkeysModal } from './features/system/components/HotkeysModal/HotkeysModal';
3637
export { default as InvokeAiLogoComponent } from './features/system/components/InvokeAILogoComponent';
3738
export { default as SettingsModal } from './features/system/components/SettingsModal/SettingsModal';

tests/app/services/model_install/test_model_install.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -182,40 +182,48 @@ def test_background_install(
182182
def 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

194199
def 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

206216
def 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

Comments
 (0)