Browse Source

Merge pull request #592 from ionite34/fix-installed-sort

Chunk installed model requests with more than 100 installed models
pull/629/head
JT 7 months ago committed by GitHub
parent
commit
07af1c85d5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 1
      CHANGELOG.md
  2. 42
      StabilityMatrix.Avalonia/ViewModels/CheckpointBrowser/CivitAiBrowserViewModel.cs

1
CHANGELOG.md

@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning 2.0](https://semver.org/spec/v2
### Fixed ### Fixed
- Fixed [#559](https://github.com/LykosAI/StabilityMatrix/issues/559) - "Unable to load bitmap from provided data" error in Checkpoints page - Fixed [#559](https://github.com/LykosAI/StabilityMatrix/issues/559) - "Unable to load bitmap from provided data" error in Checkpoints page
- Fixed [#522](https://github.com/LykosAI/StabilityMatrix/issues/522) - Incorrect output directory path for latest Auto1111 - Fixed [#522](https://github.com/LykosAI/StabilityMatrix/issues/522) - Incorrect output directory path for latest Auto1111
- Fixed Civitai model browser error when sorting by Installed with more than 100 installed models
- Fixed CLIP Install errors due to setuptools distutils conflict, added default environment variable setting `SETUPTOOLS_USE_DISTUTILS=stdlib` - Fixed CLIP Install errors due to setuptools distutils conflict, added default environment variable setting `SETUPTOOLS_USE_DISTUTILS=stdlib`
## v2.10.0-pre.2 ## v2.10.0-pre.2

42
StabilityMatrix.Avalonia/ViewModels/CheckpointBrowser/CivitAiBrowserViewModel.cs

@ -196,10 +196,40 @@ public partial class CivitAiBrowserViewModel : TabViewModelBase, IInfinitelyScro
{ {
var timer = Stopwatch.StartNew(); var timer = Stopwatch.StartNew();
var queryText = request.Query; var queryText = request.Query;
var models = new List<CivitModel>();
CivitModelsResponse? modelsResponse = null;
try try
{ {
var modelsResponse = await civitApi.GetModels(request); if (!string.IsNullOrWhiteSpace(request.CommaSeparatedModelIds))
var models = modelsResponse.Items; {
// count IDs
var ids = request.CommaSeparatedModelIds.Split(',');
if (ids.Length > 100)
{
var idChunks = ids.Chunk(100);
foreach (var chunk in idChunks)
{
request.CommaSeparatedModelIds = string.Join(",", chunk);
var chunkModelsResponse = await civitApi.GetModels(request);
if (chunkModelsResponse.Items != null)
{
models.AddRange(chunkModelsResponse.Items);
}
}
}
else
{
modelsResponse = await civitApi.GetModels(request);
models = modelsResponse.Items;
}
}
else
{
modelsResponse = await civitApi.GetModels(request);
models = modelsResponse.Items;
}
if (models is null) if (models is null)
{ {
Logger.Debug( Logger.Debug(
@ -241,13 +271,13 @@ public partial class CivitAiBrowserViewModel : TabViewModelBase, IInfinitelyScro
InsertedAt = DateTimeOffset.UtcNow, InsertedAt = DateTimeOffset.UtcNow,
Request = request, Request = request,
Items = models, Items = models,
Metadata = modelsResponse.Metadata Metadata = modelsResponse?.Metadata
} }
); );
UpdateModelCards(models, isInfiniteScroll); UpdateModelCards(models, isInfiniteScroll);
NextPageCursor = modelsResponse.Metadata?.NextCursor; NextPageCursor = modelsResponse?.Metadata?.NextCursor;
} }
catch (OperationCanceledException) catch (OperationCanceledException)
{ {
@ -428,12 +458,14 @@ public partial class CivitAiBrowserViewModel : TabViewModelBase, IInfinitelyScro
{ {
var connectedModels = CheckpointFile var connectedModels = CheckpointFile
.GetAllCheckpointFiles(settingsManager.ModelsDirectory) .GetAllCheckpointFiles(settingsManager.ModelsDirectory)
.Where(c => c.IsConnectedModel); .Where(c => c.IsConnectedModel)
.ToList();
modelRequest.CommaSeparatedModelIds = string.Join( modelRequest.CommaSeparatedModelIds = string.Join(
",", ",",
connectedModels.Select(c => c.ConnectedModel!.ModelId).GroupBy(m => m).Select(g => g.First()) connectedModels.Select(c => c.ConnectedModel!.ModelId).GroupBy(m => m).Select(g => g.First())
); );
modelRequest.Sort = null; modelRequest.Sort = null;
modelRequest.Period = null; modelRequest.Period = null;
} }

Loading…
Cancel
Save