From 805dde5bd5725f68564bbcba78ce5fe0d77d912d Mon Sep 17 00:00:00 2001 From: JT Date: Sat, 13 Apr 2024 22:45:19 -0700 Subject: [PATCH] fixed a few more github issues --- CHANGELOG.md | 7 ++- .../CivitAiBrowserViewModel.cs | 2 + .../CheckpointManager/CheckpointFile.cs | 13 +++-- .../CheckpointManager/CheckpointFolder.cs | 19 +++++++- .../ViewModels/OpenArtBrowserViewModel.cs | 5 +- .../PackageManager/PackageCardViewModel.cs | 8 ++++ .../Views/PackageManagerPage.axaml | 7 ++- .../Views/Settings/MainSettingsPage.axaml | 33 +++++++------ .../Models/DownloadPackageVersionOptions.cs | 2 + .../Models/Packages/BaseGitPackage.cs | 48 +++++++++++++++++++ .../Models/Packages/BasePackage.cs | 2 + .../Models/Packages/UnknownPackage.cs | 17 ++++--- .../Models/SharedFolderType.cs | 1 + 13 files changed, 131 insertions(+), 33 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 605ba925..55f4d905 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,15 +6,20 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning 2.0](https://semver.org/spec/v2.0.0.html). ## v2.10.1 +### Added +- Added SVD Shared Model Folder for Forge (fixes [#580](https://github.com/LykosAI/StabilityMatrix/issues/580)) ### Changed - Improved error message when logging in with a Lykos account fails due to incorrect email or password. ### Fixed - Fixed package launch not working when environment variable `SETUPTOOLS_USE_DISTUTILS` is set due to conflict with a default environment variable. User environment variables will now correctly override any default environment variables. - Fixed "No refresh token found" error when failing to login with Lykos account in some cases. +- Fixed blank entries appearing in the Categories dropdown on the Checkpoints page +- Fixed crash when loading invalid connected model info files +- Fixed [#585](https://github.com/LykosAI/StabilityMatrix/issues/585) - Crash when drag & drop source and destination are the same - Fixed [#584](https://github.com/LykosAI/StabilityMatrix/issues/584) - `--launch-package` argument not working - Fixed [#581](https://github.com/LykosAI/StabilityMatrix/issues/581) - Inference teaching tip showing more often than it should -- Fixed [#574](https://github.com/LykosAI/StabilityMatrix/issues/574) - local images not showing on macOS or Linux - Fixed [#578](https://github.com/LykosAI/StabilityMatrix/issues/578) - "python setup.py egg_info did not run successfully" failure when installing Auto1111 or SDWebUI Forge +- Fixed [#574](https://github.com/LykosAI/StabilityMatrix/issues/574) - local images not showing on macOS or Linux ## v2.10.0 ### Added diff --git a/StabilityMatrix.Avalonia/ViewModels/CheckpointBrowser/CivitAiBrowserViewModel.cs b/StabilityMatrix.Avalonia/ViewModels/CheckpointBrowser/CivitAiBrowserViewModel.cs index ebf5401a..26364b0d 100644 --- a/StabilityMatrix.Avalonia/ViewModels/CheckpointBrowser/CivitAiBrowserViewModel.cs +++ b/StabilityMatrix.Avalonia/ViewModels/CheckpointBrowser/CivitAiBrowserViewModel.cs @@ -177,6 +177,8 @@ public partial class CivitAiBrowserViewModel : TabViewModelBase, IInfinitelyScro model => model.ShowNsfw, settings => settings.ModelBrowserNsfwEnabled ); + + SearchModelsCommand.ExecuteAsync(false); } /// diff --git a/StabilityMatrix.Avalonia/ViewModels/CheckpointManager/CheckpointFile.cs b/StabilityMatrix.Avalonia/ViewModels/CheckpointManager/CheckpointFile.cs index baebb0fd..15eb4f5d 100644 --- a/StabilityMatrix.Avalonia/ViewModels/CheckpointManager/CheckpointFile.cs +++ b/StabilityMatrix.Avalonia/ViewModels/CheckpointManager/CheckpointFile.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.IO; using System.Linq; +using System.Text.Json; using System.Threading.Tasks; using Avalonia.Data; using CommunityToolkit.Mvvm.ComponentModel; @@ -10,7 +11,6 @@ using CommunityToolkit.Mvvm.Input; using FluentAvalonia.UI.Controls; using Microsoft.Extensions.DependencyInjection; using NLog; -using StabilityMatrix.Avalonia.Languages; using StabilityMatrix.Avalonia.ViewModels.Base; using StabilityMatrix.Core.Attributes; using StabilityMatrix.Core.Extensions; @@ -333,8 +333,15 @@ public partial class CheckpointFile : ViewModelBase if (File.Exists(jsonPath)) { var json = File.ReadAllText(jsonPath); - var connectedModelInfo = ConnectedModelInfo.FromJson(json); - checkpointFile.ConnectedModel = connectedModelInfo; + try + { + var connectedModelInfo = ConnectedModelInfo.FromJson(json); + checkpointFile.ConnectedModel = connectedModelInfo; + } + catch (JsonException) + { + checkpointFile.ConnectedModel = null; + } } checkpointFile.PreviewImagePath = SupportedImageExtensions diff --git a/StabilityMatrix.Avalonia/ViewModels/CheckpointManager/CheckpointFolder.cs b/StabilityMatrix.Avalonia/ViewModels/CheckpointManager/CheckpointFolder.cs index 39408129..5f23e3fc 100644 --- a/StabilityMatrix.Avalonia/ViewModels/CheckpointManager/CheckpointFolder.cs +++ b/StabilityMatrix.Avalonia/ViewModels/CheckpointManager/CheckpointFolder.cs @@ -92,7 +92,8 @@ public partial class CheckpointFolder : ViewModelBase public string TitleWithFilesCount => CheckpointFiles.Any() || SubFolders.Any(f => f.CheckpointFiles.Any()) - ? $"{FolderType.GetDescription() ?? FolderType.GetStringValue()} ({CheckpointFiles.Count + SubFolders.Sum(folder => folder.CheckpointFiles.Count)})" + ? $"{FolderType.GetDescription() ?? (string.IsNullOrWhiteSpace(FolderType.GetStringValue()) ? Path.GetFileName(DirectoryPath) : FolderType.GetStringValue())} " + + $"({CheckpointFiles.Count + SubFolders.Sum(folder => folder.CheckpointFiles.Count)})" : FolderType.GetDescription() ?? FolderType.GetStringValue(); public ProgressViewModel Progress { get; } = new(); @@ -447,6 +448,22 @@ public partial class CheckpointFolder : ViewModelBase Progress.Value = 0; var copyPaths = files.ToDictionary(k => k, v => Path.Combine(DirectoryPath, Path.GetFileName(v))); + // remove files that are already in the folder + foreach (var (source, destination) in copyPaths) + { + if (source == destination) + { + copyPaths.Remove(source); + } + } + + if (copyPaths.Count == 0) + { + Progress.Text = "Import complete"; + Progress.Value = 100; + return; + } + var progress = new Progress(report => { Progress.IsIndeterminate = false; diff --git a/StabilityMatrix.Avalonia/ViewModels/OpenArtBrowserViewModel.cs b/StabilityMatrix.Avalonia/ViewModels/OpenArtBrowserViewModel.cs index de438ecc..cc13e869 100644 --- a/StabilityMatrix.Avalonia/ViewModels/OpenArtBrowserViewModel.cs +++ b/StabilityMatrix.Avalonia/ViewModels/OpenArtBrowserViewModel.cs @@ -12,7 +12,6 @@ using DynamicData.Binding; using FluentAvalonia.UI.Controls; using Refit; using StabilityMatrix.Avalonia.Controls; -using StabilityMatrix.Avalonia.Languages; using StabilityMatrix.Avalonia.Models; using StabilityMatrix.Avalonia.Services; using StabilityMatrix.Avalonia.ViewModels.Base; @@ -36,8 +35,7 @@ public partial class OpenArtBrowserViewModel( IOpenArtApi openArtApi, INotificationService notificationService, ISettingsManager settingsManager, - IPackageFactory packageFactory, - ServiceManager vmFactory + IPackageFactory packageFactory ) : TabViewModelBase, IInfinitelyScroll { private const int PageSize = 20; @@ -90,6 +88,7 @@ public partial class OpenArtBrowserViewModel( { searchResultsCache.Connect().DeferUntilLoaded().Bind(SearchResults).Subscribe(); SelectedSortMode = AllSortModes.First(); + DoSearch().SafeFireAndForget(); } [RelayCommand] diff --git a/StabilityMatrix.Avalonia/ViewModels/PackageManager/PackageCardViewModel.cs b/StabilityMatrix.Avalonia/ViewModels/PackageManager/PackageCardViewModel.cs index 71d624ec..496881bb 100644 --- a/StabilityMatrix.Avalonia/ViewModels/PackageManager/PackageCardViewModel.cs +++ b/StabilityMatrix.Avalonia/ViewModels/PackageManager/PackageCardViewModel.cs @@ -95,6 +95,9 @@ public partial class PackageCardViewModel( [ObservableProperty] private bool showWebUiButton; + [ObservableProperty] + private DownloadPackageVersionOptions? updateVersion; + private void RunningPackagesOnCollectionChanged(object? sender, NotifyCollectionChangedEventArgs e) { if (runningPackageService.RunningPackages.Select(x => x.Value) is not { } runningPackages) @@ -196,6 +199,10 @@ public partial class PackageCardViewModel( } IsUpdateAvailable = await HasUpdate(); + if (IsUpdateAvailable) + { + UpdateVersion = await basePackage.GetUpdate(currentPackage); + } if ( Package != null @@ -672,6 +679,7 @@ public partial class PackageCardViewModel( try { var hasUpdate = await basePackage.CheckForUpdates(Package); + UpdateVersion = await basePackage.GetUpdate(Package); await using (settingsManager.BeginTransaction()) { diff --git a/StabilityMatrix.Avalonia/Views/PackageManagerPage.axaml b/StabilityMatrix.Avalonia/Views/PackageManagerPage.axaml index 37b450db..f5d39fea 100644 --- a/StabilityMatrix.Avalonia/Views/PackageManagerPage.axaml +++ b/StabilityMatrix.Avalonia/Views/PackageManagerPage.axaml @@ -255,9 +255,14 @@ Margin="4,4,0,0" Padding="4" IsEnabled="{Binding !IsRunning}" - ToolTip.Tip="{x:Static lang:Resources.Label_UpdateAvailable}" markupExtensions:ShowDisabledTooltipExtension.ShowOnDisabled="True" Command="{Binding Update}"> + + + + + + diff --git a/StabilityMatrix.Avalonia/Views/Settings/MainSettingsPage.axaml b/StabilityMatrix.Avalonia/Views/Settings/MainSettingsPage.axaml index 5fb2d8a4..15eea9f1 100644 --- a/StabilityMatrix.Avalonia/Views/Settings/MainSettingsPage.axaml +++ b/StabilityMatrix.Avalonia/Views/Settings/MainSettingsPage.axaml @@ -82,19 +82,6 @@ Symbol="Alert" /> - - - - - - - - @@ -215,7 +202,7 @@ - + + + + + + + + + + + !string.IsNullOrWhiteSpace(VersionTag) ? VersionTag : $"{BranchName}@{CommitHash?[..7]}"; + + public string ReadableVersionString => GetReadableVersionString(); } diff --git a/StabilityMatrix.Core/Models/Packages/BaseGitPackage.cs b/StabilityMatrix.Core/Models/Packages/BaseGitPackage.cs index 86a103c5..e368790d 100644 --- a/StabilityMatrix.Core/Models/Packages/BaseGitPackage.cs +++ b/StabilityMatrix.Core/Models/Packages/BaseGitPackage.cs @@ -345,6 +345,54 @@ public abstract class BaseGitPackage : BasePackage } } + public override async Task GetUpdate(InstalledPackage installedPackage) + { + var currentVersion = installedPackage.Version; + if (currentVersion is null or { InstalledReleaseVersion: null, InstalledBranch: null }) + { + Logger.Warn( + "Could not check updates for package {Name}, version is invalid: {@currentVersion}", + Name, + currentVersion + ); + return null; + } + + var versionOptions = new DownloadPackageVersionOptions { IsLatest = true }; + + try + { + if (currentVersion.IsReleaseMode) + { + var latestVersion = await GetLatestVersion(currentVersion.IsPrerelease).ConfigureAwait(false); + versionOptions.IsPrerelease = latestVersion.IsPrerelease; + versionOptions.VersionTag = latestVersion.VersionTag; + return versionOptions; + } + + var allCommits = ( + await GetAllCommits(currentVersion.InstalledBranch!).ConfigureAwait(false) + )?.ToList(); + + if (allCommits == null || !allCommits.Any()) + { + Logger.Warn("No commits found for {Package}", installedPackage.PackageName); + return null; + } + var latestCommitHash = allCommits.First().Sha; + + versionOptions.CommitHash = latestCommitHash; + versionOptions.BranchName = currentVersion.InstalledBranch; + + return versionOptions; + } + catch (ApiException e) + { + Logger.Warn(e, "Failed to check for package updates"); + return null; + } + } + public override async Task Update( InstalledPackage installedPackage, TorchVersion torchVersion, diff --git a/StabilityMatrix.Core/Models/Packages/BasePackage.cs b/StabilityMatrix.Core/Models/Packages/BasePackage.cs index 368cf2bc..a603c2a4 100644 --- a/StabilityMatrix.Core/Models/Packages/BasePackage.cs +++ b/StabilityMatrix.Core/Models/Packages/BasePackage.cs @@ -237,4 +237,6 @@ public abstract class BasePackage onConsoleOutput ); } + + public abstract Task GetUpdate(InstalledPackage installedPackage); } diff --git a/StabilityMatrix.Core/Models/Packages/UnknownPackage.cs b/StabilityMatrix.Core/Models/Packages/UnknownPackage.cs index 89d021e0..b1e52339 100644 --- a/StabilityMatrix.Core/Models/Packages/UnknownPackage.cs +++ b/StabilityMatrix.Core/Models/Packages/UnknownPackage.cs @@ -15,8 +15,7 @@ public class UnknownPackage : BasePackage public override string GithubUrl => ""; public override string LicenseType => "AGPL-3.0"; - public override string LicenseUrl => - "https://github.com/LykosAI/StabilityMatrix/blob/main/LICENSE"; + public override string LicenseUrl => "https://github.com/LykosAI/StabilityMatrix/blob/main/LICENSE"; public override string Blurb => "A dank interface for diffusion"; public override string LaunchCommand => "test"; @@ -140,20 +139,20 @@ public class UnknownPackage : BasePackage public override List LaunchOptions => new(); public override Dictionary>? SharedFolders { get; } - public override Dictionary< - SharedOutputType, - IReadOnlyList - >? SharedOutputFolders { get; } + public override Dictionary>? SharedOutputFolders { get; } - public override Task GetLatestVersion( - bool includePrerelease = false - ) + public override Task GetLatestVersion(bool includePrerelease = false) { throw new NotImplementedException(); } public override string MainBranch { get; } + public override Task GetUpdate(InstalledPackage installedPackage) + { + return Task.FromResult(new DownloadPackageVersionOptions { IsLatest = true, VersionTag = "1.8.0" }); + } + public override Task GetAllVersionOptions() => Task.FromResult(new PackageVersionOptions()); diff --git a/StabilityMatrix.Core/Models/SharedFolderType.cs b/StabilityMatrix.Core/Models/SharedFolderType.cs index 50ba7db7..f94b46d8 100644 --- a/StabilityMatrix.Core/Models/SharedFolderType.cs +++ b/StabilityMatrix.Core/Models/SharedFolderType.cs @@ -39,6 +39,7 @@ public enum SharedFolderType InvokeIpAdapters15 = 1 << 24, InvokeIpAdaptersXl = 1 << 25, InvokeClipVision = 1 << 26, + SVD = 1 << 27, PromptExpansion = 1 << 30 }