From 491c9e75e217bc0f76300fae8537372608216a61 Mon Sep 17 00:00:00 2001 From: Ionite Date: Mon, 29 Jul 2024 23:57:22 -0400 Subject: [PATCH 01/12] Merge pull request #738 from ionite34/settings-relay Add nested expressions support for SettingsManager.RelayPropertyFor (cherry picked from commit 4f45c38cb10ec0f958648ad4563948f008f0f3f5) --- StabilityMatrix.Core/Helper/Expressions.cs | 33 ------------- .../Services/SettingsManager.cs | 49 +++++++++---------- .../StabilityMatrix.Core.csproj | 1 + .../Core/ExpressionsTests.cs | 41 ---------------- 4 files changed, 25 insertions(+), 99 deletions(-) delete mode 100644 StabilityMatrix.Core/Helper/Expressions.cs delete mode 100644 StabilityMatrix.Tests/Core/ExpressionsTests.cs diff --git a/StabilityMatrix.Core/Helper/Expressions.cs b/StabilityMatrix.Core/Helper/Expressions.cs deleted file mode 100644 index c830d645a..000000000 --- a/StabilityMatrix.Core/Helper/Expressions.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System.Linq.Expressions; -using System.Reflection; - -namespace StabilityMatrix.Core.Helper; - -public static class Expressions -{ - public static (string propertyName, Expression> assigner) - GetAssigner(Expression> propertyAccessor) - { - if (propertyAccessor.Body is not MemberExpression memberExpression) - { - throw new ArgumentException( - $"Expression must be a member expression, not {propertyAccessor.Body.NodeType}"); - } - - var propertyInfo = memberExpression.Member as PropertyInfo; - if (propertyInfo == null) - { - throw new ArgumentException( - $"Expression member must be a property, not {memberExpression.Member.MemberType}"); - } - - var propertyName = propertyInfo.Name; - var typeParam = Expression.Parameter(typeof(T)); - var valueParam = Expression.Parameter(typeof(TValue)); - var expr = Expression.Lambda>( - Expression.Assign( - Expression.MakeMemberAccess(typeParam, propertyInfo), - valueParam), typeParam, valueParam); - return (propertyName, expr); - } -} diff --git a/StabilityMatrix.Core/Services/SettingsManager.cs b/StabilityMatrix.Core/Services/SettingsManager.cs index 23bd3d9f4..992ccace7 100644 --- a/StabilityMatrix.Core/Services/SettingsManager.cs +++ b/StabilityMatrix.Core/Services/SettingsManager.cs @@ -4,6 +4,7 @@ using System.Reflection; using System.Text.Json; using AsyncAwaitBestPractices; +using CompiledExpressions; using Microsoft.Extensions.Logging; using StabilityMatrix.Core.Attributes; using StabilityMatrix.Core.Helper; @@ -170,49 +171,48 @@ public void RelayPropertyFor( ) where T : INotifyPropertyChanged { - var sourceGetter = sourceProperty.Compile(); - var (propertyName, assigner) = Expressions.GetAssigner(sourceProperty); - var sourceSetter = assigner.Compile(); + var sourceInstanceAccessor = CompiledExpression.CreateAccessor(sourceProperty).WithInstance(source); + var settingsAccessor = CompiledExpression.CreateAccessor(settingsProperty); - var settingsGetter = settingsProperty.Compile(); - var (targetPropertyName, settingsAssigner) = Expressions.GetAssigner(settingsProperty); - var settingsSetter = settingsAssigner.Compile(); + var sourcePropertyPath = sourceInstanceAccessor.FullName; + var settingsPropertyPath = settingsAccessor.FullName; var sourceTypeName = source.GetType().Name; // Update source when settings change SettingsPropertyChanged += (sender, args) => { - if (args.PropertyName != targetPropertyName) + if (args.PropertyName != settingsPropertyPath) return; // Skip if event is relay and the sender is the source, to prevent duplicate if (args.IsRelay && ReferenceEquals(sender, source)) return; + logger.LogTrace( - "[RelayPropertyFor] " + "Settings.{TargetProperty:l} -> {SourceType:l}.{SourceProperty:l}", - targetPropertyName, + "[RelayPropertyFor] " + "Settings.{SettingsProperty:l} -> {SourceType:l}.{SourceProperty:l}", + settingsPropertyPath, sourceTypeName, - propertyName + sourcePropertyPath ); - sourceSetter(source, settingsGetter(Settings)); + sourceInstanceAccessor.Set(source, settingsAccessor.Get(Settings)); }; // Set and Save settings when source changes source.PropertyChanged += (sender, args) => { - if (args.PropertyName != propertyName) + if (args.PropertyName != sourcePropertyPath) return; logger.LogTrace( - "[RelayPropertyFor] " + "{SourceType:l}.{SourceProperty:l} -> Settings.{TargetProperty:l}", + "[RelayPropertyFor] {SourceType:l}.{SourceProperty:l} -> Settings.{SettingsProperty:l}", sourceTypeName, - propertyName, - targetPropertyName + sourcePropertyPath, + settingsPropertyPath ); - settingsSetter(Settings, sourceGetter(source)); + settingsAccessor.Set(Settings, sourceInstanceAccessor.Get()); if (IsLibraryDirSet) { @@ -228,24 +228,24 @@ public void RelayPropertyFor( else { logger.LogWarning( - "[RelayPropertyFor] LibraryDir not set when saving ({SourceType:l}.{SourceProperty:l} -> Settings.{TargetProperty:l})", + "[RelayPropertyFor] LibraryDir not set when saving ({SourceType:l}.{SourceProperty:l} -> Settings.{SettingsProperty:l})", sourceTypeName, - propertyName, - targetPropertyName + sourcePropertyPath, + settingsPropertyPath ); } // Invoke property changed event, passing along sender SettingsPropertyChanged?.Invoke( sender, - new RelayPropertyChangedEventArgs(targetPropertyName, true) + new RelayPropertyChangedEventArgs(settingsPropertyPath, true) ); }; // Set initial value if requested if (setInitial) { - sourceSetter(source, settingsGetter(Settings)); + sourceInstanceAccessor.Set(settingsAccessor.Get(Settings)); } } @@ -255,16 +255,15 @@ public void RegisterPropertyChangedHandler( Action onPropertyChanged ) { - var settingsGetter = settingsProperty.Compile(); - var (propertyName, _) = Expressions.GetAssigner(settingsProperty); + var settingsAccessor = CompiledExpression.CreateAccessor(settingsProperty); // Invoke handler when settings change SettingsPropertyChanged += (_, args) => { - if (args.PropertyName != propertyName) + if (args.PropertyName != settingsAccessor.FullName) return; - onPropertyChanged(settingsGetter(Settings)); + onPropertyChanged(settingsAccessor.Get(Settings)); }; } diff --git a/StabilityMatrix.Core/StabilityMatrix.Core.csproj b/StabilityMatrix.Core/StabilityMatrix.Core.csproj index 00f63c9a4..7813e2d0e 100644 --- a/StabilityMatrix.Core/StabilityMatrix.Core.csproj +++ b/StabilityMatrix.Core/StabilityMatrix.Core.csproj @@ -23,6 +23,7 @@ + diff --git a/StabilityMatrix.Tests/Core/ExpressionsTests.cs b/StabilityMatrix.Tests/Core/ExpressionsTests.cs deleted file mode 100644 index 4d6f51a0c..000000000 --- a/StabilityMatrix.Tests/Core/ExpressionsTests.cs +++ /dev/null @@ -1,41 +0,0 @@ -using StabilityMatrix.Core.Helper; - -namespace StabilityMatrix.Tests.Core; - -[TestClass] -public class ExpressionsTests -{ - private class TestClass - { - public int Id { get; set; } - public NestedTestClass? Nested { get; set; } - } - - private class NestedTestClass - { - public string Text { get; set; } = ""; - } - - [TestMethod] - public void GetAssigner_Simple_PropertyName() - { - var (propertyName, _) = - Expressions.GetAssigner(x => x.Id); - - // Check that the property name is correct - Assert.AreEqual("Id", propertyName); - } - - [TestMethod] - public void GetAssigner_Simple_PropertyAssignment() - { - var obj = new TestClass(); - - var (_, assigner) = - Expressions.GetAssigner(x => x.Id); - - assigner.Compile()(obj, 42); - - Assert.AreEqual(42, obj.Id); - } -} From 194592d300972c9bcd084efedeb709e7e222bdf4 Mon Sep 17 00:00:00 2001 From: JT Date: Fri, 2 Aug 2024 11:55:47 -0700 Subject: [PATCH 02/12] fix ip adapter links in huggingface browser --- CHANGELOG.md | 3 +++ .../Assets/hf-packages.json | 27 +++++-------------- 2 files changed, 10 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cec0e2d37..5a17e2d4c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,9 @@ All notable changes to Stability Matrix will be documented in this file. 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.11.6 +### Fixed +- Fixed incorrect IPAdapter download links in the HuggingFace model browser ## v2.11.5 ### Added diff --git a/StabilityMatrix.Avalonia/Assets/hf-packages.json b/StabilityMatrix.Avalonia/Assets/hf-packages.json index 6bbeecbbc..267e36827 100644 --- a/StabilityMatrix.Avalonia/Assets/hf-packages.json +++ b/StabilityMatrix.Avalonia/Assets/hf-packages.json @@ -390,10 +390,8 @@ "ModelName": "SD 1.5 Adapter", "RepositoryPath": "InvokeAI/ip_adapter_sd15", "Files": [ - "image_encoder.txt", - "ip_adapter.bin" + "ip-adapter_sd15.safetensors" ], - "Subfolder": "ip_adapter_sd15", "LicenseType": "Apache 2.0" }, { @@ -401,8 +399,7 @@ "ModelName": "SD 1.5 Light Adapter", "RepositoryPath": "InvokeAI/ip_adapter_sd15_light", "Files": [ - "image_encoder.txt", - "ip_adapter.bin" + "ip-adapter_sd15_light.safetensors" ], "Subfolder": "ip_adapter_sd15_light", "LicenseType": "Apache 2.0" @@ -412,10 +409,8 @@ "ModelName": "SD 1.5 Plus Adapter", "RepositoryPath": "InvokeAI/ip_adapter_plus_sd15", "Files": [ - "image_encoder.txt", - "ip_adapter.bin" + "ip-adapter-plus_sd15.safetensors" ], - "Subfolder": "ip_adapter_plus_sd15", "LicenseType": "Apache 2.0" }, { @@ -423,10 +418,8 @@ "ModelName": "SD 1.5 Face Plus Adapter", "RepositoryPath": "InvokeAI/ip_adapter_plus_face_sd15", "Files": [ - "image_encoder.txt", - "ip_adapter.bin" + "ip-adapter-plus-face_sd15.safetensors" ], - "Subfolder": "ip_adapter_plus_face_sd15", "LicenseType": "Apache 2.0" }, { @@ -434,10 +427,8 @@ "ModelName": "SDXL Adapter", "RepositoryPath": "InvokeAI/ip_adapter_sdxl", "Files": [ - "image_encoder.txt", - "ip_adapter.bin" + "ip-adapter_sdxl.safetensors" ], - "Subfolder": "ip_adapter_sdxl", "LicenseType": "Apache 2.0" }, { @@ -445,10 +436,8 @@ "ModelName": "SDXL Plus Adapter", "RepositoryPath": "InvokeAI/ip-adapter-plus_sdxl_vit-h", "Files": [ - "image_encoder.txt", - "ip_adapter.bin" + "ip-adapter-plus_sdxl_vit-h.safetensors" ], - "Subfolder": "ip_adapter_plus_sdxl_vit-h", "LicenseType": "Apache 2.0" }, { @@ -456,10 +445,8 @@ "ModelName": "SDXL Face Plus Adapter", "RepositoryPath": "InvokeAI/ip-adapter-plus-face_sdxl_vit-h", "Files": [ - "image_encoder.txt", - "ip_adapter.bin" + "ip-adapter-plus-face_sdxl_vit-h.safetensors" ], - "Subfolder": "ip_adapter_plus_face_sdxl_vit-h", "LicenseType": "CreativeML Open RAIL-M" }, { From f9233bb0ce2ce3635e383eb231e30126e7c78962 Mon Sep 17 00:00:00 2001 From: Ionite Date: Sat, 3 Aug 2024 19:47:20 -0400 Subject: [PATCH 03/12] Merge pull request #750 from ionite34/disposables-improvement Add IDisposable return for RelayPropertyFor subscriptions, and use dispose for transients (cherry picked from commit fe741d7c7ecb1e4a5284e7b85f7cef7cde247c6c) # Conflicts: # CHANGELOG.md # StabilityMatrix.Core/Services/SettingsManager.cs # StabilityMatrix.Core/StabilityMatrix.Core.csproj --- CHANGELOG.md | 55 ++++++++++++++ .../Base/DisposableLoadableViewModelBase.cs | 75 +++++++++++++++++++ .../Base/DisposableViewModelBase.cs | 75 +++++++++++++++++++ .../Base/InferenceGenerationViewModelBase.cs | 2 +- .../Base/InferenceTabViewModelBase.cs | 14 +--- .../Inference/ImageFolderCardViewModel.cs | 14 ++-- .../InferenceTextToImageViewModel.cs | 19 +++-- .../Inference/PromptCardViewModel.cs | 17 +++-- .../Services/ISettingsManager.cs | 2 +- .../Services/SettingsManager.cs | 44 ++++++++++- .../StabilityMatrix.Core.csproj | 4 + 11 files changed, 286 insertions(+), 35 deletions(-) create mode 100644 StabilityMatrix.Avalonia/ViewModels/Base/DisposableLoadableViewModelBase.cs create mode 100644 StabilityMatrix.Avalonia/ViewModels/Base/DisposableViewModelBase.cs diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a17e2d4c..ea1a1e80a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,9 +5,64 @@ All notable changes to Stability Matrix will be documented in this file. 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). +<<<<<<< HEAD +======= +## v2.12.0-dev.3 +### Added +- Added Settings option "Console: History Size" to adjust the number of lines stored in the console history when running packages. Defaults to 9001 lines. +#### Model Browser +- Added AuraFlow & Flux base model types to the CivitAI model browser +#### Checkpoint Manager +- Added "New Directory" and "Delete" options to the context menu of the tree view. +- Added new toggle for drag & drop - when enabled, all selected models will now move together with the dragged model +- Added "File Size" sorting option +- Added "Hide Empty Categories" toggle +- Added "Select All" button to the InfoBar (shown when at least one model is selected) +- Added "unet" shared model folder for ComfyUI +### Changed +- The "Download Failed" message for model downloads is now persistent until dismissed +### Fixed +- Fixed "The version of the native libSkiaSharp library (88.1) is incompatible with this version of SkiaSharp." error for Linux users +- Fixed download links for IPAdapters in the HuggingFace model browser +- Fixed potential memory leak of transient controls (Inference Prompt and Output Image Viewer) not being garbage collected due to event subscriptions + +## v2.12.0-dev.2 +### Added +- Added Face Detailer module to Inference +- Added ultralytics models to HuggingFace model browser +- Added DoRA category to CivitAI model browser +- Added macOS support for Fooocus & related forks +- (Windows, Linux) Added Vulkan rendering support using launch argument `--vulkan`. (On Windows, the default WinUI composition renderer is likely still preferrable. Linux users are encouraged to try the new renderer to see if it improves performance and responsiveness.) +### Changed +- (Internal) Updated Avalonia to 11.1.1 - Includes major rendering and performance optimizations, animation refinements, improved IME / text selection, and improvements for window sizing / z-order / multi-monitor DPI scaling. ([avaloniaui.net/blog/avalonia-11-1-a-quantum-leap-in-cross-platform-ui-development](https://avaloniaui.net/blog/avalonia-11-1-a-quantum-leap-in-cross-platform-ui-development)) +- (Internal) Updated SkiaSharp (Rendering Backend) to 3.0.0-preview.4.1, potentially fixes issues with window rendering artifacts on some machines. +- (Internal) Updated other dependencies for security and bug fixes. +### Fixed +- Fixed some ScrollViewers changing scroll position when focus changes +- Fixed [#782](https://github.com/LykosAI/StabilityMatrix/issues/782) - conflict error when launching new versions of Forge +- Fixed incorrect torch versions being installed for InvokeAI +### Supporters +#### Visionaries +- A huge thank you goes out to our esteemed Visionary-tier Patreon backers: **Scopp Mcdee**, **Waterclouds**, and **Akiro_Senkai**. Your kind support means the world! + +## v2.12.0-dev.1 +### Added +- Added new package: [Fooocus - mashb1t's 1-Up Edition](https://github.com/mashb1t/Fooocus) by mashb1t +- Added new package: [Stable Diffusion WebUI reForge](https://github.com/Panchovix/stable-diffusion-webui-reForge/) by Panchovix +- Image viewer context menus now have 2 options: `Copy (Ctrl+C)` which now always copies the image as a file, and `Copy as Bitmap (Shift+Ctrl+C)` (Available on Windows) which copies to the clipboard as native bitmap. This changes the previous single `Copy` button behavior that would first attempt a native bitmap copy on Windows when available, and fall back to a file copy if not. +- Added "Change Version" option to the package card overflow menu, allowing you to downgrade or upgrade a package to a specific version or commit +- Added "Disable Update Check" option to the package card overflow menu, allowing you to disable update checks for a specific package +- Added "Run Command" option in Settings for running a command with the embedded Python or Git executables +- Added Intel OneAPI XPU backend (IPEX) option for SD.Next +### Supporters +#### Visionaries +- Shoutout to our Visionary-tier Patreon supporters, **Scopp Mcdee**, **Waterclouds**, and our newest Visionary, **Akiro_Senkai**! Many thanks for your generous support! + +>>>>>>> fe741d7c (Merge pull request #750 from ionite34/disposables-improvement) ## v2.11.6 ### Fixed - Fixed incorrect IPAdapter download links in the HuggingFace model browser +- Fixed potential memory leak of transient controls (Inference Prompt and Output Image Viewer) not being garbage collected due to event subscriptions ## v2.11.5 ### Added diff --git a/StabilityMatrix.Avalonia/ViewModels/Base/DisposableLoadableViewModelBase.cs b/StabilityMatrix.Avalonia/ViewModels/Base/DisposableLoadableViewModelBase.cs new file mode 100644 index 000000000..1db67f957 --- /dev/null +++ b/StabilityMatrix.Avalonia/ViewModels/Base/DisposableLoadableViewModelBase.cs @@ -0,0 +1,75 @@ +using System; +using System.Reactive.Disposables; +using JetBrains.Annotations; + +namespace StabilityMatrix.Avalonia.ViewModels.Base; + +public abstract class DisposableLoadableViewModelBase : LoadableViewModelBase, IDisposable +{ + private readonly CompositeDisposable instanceDisposables = new(); + + /// + /// Adds a disposable to be disposed when this view model is disposed. + /// + /// The disposable to add. + protected void AddDisposable([HandlesResourceDisposal] IDisposable disposable) + { + instanceDisposables.Add(disposable); + } + + /// + /// Adds disposables to be disposed when this view model is disposed. + /// + /// The disposables to add. + protected void AddDisposable([HandlesResourceDisposal] params IDisposable[] disposables) + { + foreach (var disposable in disposables) + { + instanceDisposables.Add(disposable); + } + } + + /// + /// Adds a disposable to be disposed when this view model is disposed. + /// + /// The disposable to add. + /// The type of the disposable. + /// The disposable that was added. + protected T AddDisposable([HandlesResourceDisposal] T disposable) + where T : IDisposable + { + instanceDisposables.Add(disposable); + return disposable; + } + + /// + /// Adds disposables to be disposed when this view model is disposed. + /// + /// The disposables to add. + /// The type of the disposables. + /// The disposables that were added. + protected T[] AddDisposable([HandlesResourceDisposal] params T[] disposables) + where T : IDisposable + { + foreach (var disposable in disposables) + { + instanceDisposables.Add(disposable); + } + + return disposables; + } + + protected virtual void Dispose(bool disposing) + { + if (disposing) + { + instanceDisposables.Dispose(); + } + } + + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } +} diff --git a/StabilityMatrix.Avalonia/ViewModels/Base/DisposableViewModelBase.cs b/StabilityMatrix.Avalonia/ViewModels/Base/DisposableViewModelBase.cs new file mode 100644 index 000000000..bfc1c5d9e --- /dev/null +++ b/StabilityMatrix.Avalonia/ViewModels/Base/DisposableViewModelBase.cs @@ -0,0 +1,75 @@ +using System; +using System.Reactive.Disposables; +using JetBrains.Annotations; + +namespace StabilityMatrix.Avalonia.ViewModels.Base; + +public abstract class DisposableViewModelBase : ViewModelBase, IDisposable +{ + private readonly CompositeDisposable instanceDisposables = new(); + + /// + /// Adds a disposable to be disposed when this view model is disposed. + /// + /// The disposable to add. + protected void AddDisposable([HandlesResourceDisposal] IDisposable disposable) + { + instanceDisposables.Add(disposable); + } + + /// + /// Adds disposables to be disposed when this view model is disposed. + /// + /// The disposables to add. + protected void AddDisposable([HandlesResourceDisposal] params IDisposable[] disposables) + { + foreach (var disposable in disposables) + { + instanceDisposables.Add(disposable); + } + } + + /// + /// Adds a disposable to be disposed when this view model is disposed. + /// + /// The disposable to add. + /// The type of the disposable. + /// The disposable that was added. + protected T AddDisposable([HandlesResourceDisposal] T disposable) + where T : IDisposable + { + instanceDisposables.Add(disposable); + return disposable; + } + + /// + /// Adds disposables to be disposed when this view model is disposed. + /// + /// The disposables to add. + /// The type of the disposables. + /// The disposables that were added. + protected T[] AddDisposable([HandlesResourceDisposal] params T[] disposables) + where T : IDisposable + { + foreach (var disposable in disposables) + { + instanceDisposables.Add(disposable); + } + + return disposables; + } + + protected virtual void Dispose(bool disposing) + { + if (disposing) + { + instanceDisposables.Dispose(); + } + } + + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } +} diff --git a/StabilityMatrix.Avalonia/ViewModels/Base/InferenceGenerationViewModelBase.cs b/StabilityMatrix.Avalonia/ViewModels/Base/InferenceGenerationViewModelBase.cs index 774e97a70..9c1621d47 100644 --- a/StabilityMatrix.Avalonia/ViewModels/Base/InferenceGenerationViewModelBase.cs +++ b/StabilityMatrix.Avalonia/ViewModels/Base/InferenceGenerationViewModelBase.cs @@ -93,7 +93,7 @@ RunningPackageService runningPackageService ClientManager = inferenceClientManager; ImageGalleryCardViewModel = vmFactory.Get(); - ImageFolderCardViewModel = vmFactory.Get(); + ImageFolderCardViewModel = AddDisposable(vmFactory.Get()); GenerateImageCommand.WithConditionalNotificationErrorHandler(notificationService); } diff --git a/StabilityMatrix.Avalonia/ViewModels/Base/InferenceTabViewModelBase.cs b/StabilityMatrix.Avalonia/ViewModels/Base/InferenceTabViewModelBase.cs index 0cb757bdc..2ae913689 100644 --- a/StabilityMatrix.Avalonia/ViewModels/Base/InferenceTabViewModelBase.cs +++ b/StabilityMatrix.Avalonia/ViewModels/Base/InferenceTabViewModelBase.cs @@ -33,8 +33,7 @@ namespace StabilityMatrix.Avalonia.ViewModels.Base; public abstract partial class InferenceTabViewModelBase - : LoadableViewModelBase, - IDisposable, + : DisposableLoadableViewModelBase, IPersistentViewProvider, IDropTarget { @@ -158,21 +157,16 @@ private async Task DebugLoadViewState() } } - protected virtual void Dispose(bool disposing) + protected override void Dispose(bool disposing) { + base.Dispose(disposing); + if (disposing) { ((IPersistentViewProvider)this).AttachedPersistentView = null; } } - /// - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } - /// /// Loads image and metadata from a file path /// diff --git a/StabilityMatrix.Avalonia/ViewModels/Inference/ImageFolderCardViewModel.cs b/StabilityMatrix.Avalonia/ViewModels/Inference/ImageFolderCardViewModel.cs index 3eb061440..5fdc28ca8 100644 --- a/StabilityMatrix.Avalonia/ViewModels/Inference/ImageFolderCardViewModel.cs +++ b/StabilityMatrix.Avalonia/ViewModels/Inference/ImageFolderCardViewModel.cs @@ -36,7 +36,7 @@ namespace StabilityMatrix.Avalonia.ViewModels.Inference; [View(typeof(ImageFolderCard))] [ManagedService] [Transient] -public partial class ImageFolderCardViewModel : ViewModelBase +public partial class ImageFolderCardViewModel : DisposableViewModelBase { private readonly ILogger logger; private readonly IImageIndexService imageIndexService; @@ -83,11 +83,13 @@ INotificationService notificationService .Bind(LocalImages) .Subscribe(); - settingsManager.RelayPropertyFor( - this, - vm => vm.ImageSize, - settings => settings.InferenceImageSize, - delay: TimeSpan.FromMilliseconds(250) + AddDisposable( + settingsManager.RelayPropertyFor( + this, + vm => vm.ImageSize, + settings => settings.InferenceImageSize, + delay: TimeSpan.FromMilliseconds(250) + ) ); } diff --git a/StabilityMatrix.Avalonia/ViewModels/Inference/InferenceTextToImageViewModel.cs b/StabilityMatrix.Avalonia/ViewModels/Inference/InferenceTextToImageViewModel.cs index 04e46f059..33f567601 100644 --- a/StabilityMatrix.Avalonia/ViewModels/Inference/InferenceTextToImageViewModel.cs +++ b/StabilityMatrix.Avalonia/ViewModels/Inference/InferenceTextToImageViewModel.cs @@ -83,7 +83,8 @@ RunningPackageService runningPackageService samplerCard.DenoiseStrength = 1.0d; }); - PromptCardViewModel = vmFactory.Get(); + PromptCardViewModel = AddDisposable(vmFactory.Get()); + BatchSizeCardViewModel = vmFactory.Get(); ModulesCardViewModel = vmFactory.Get(modulesCard => @@ -108,13 +109,15 @@ RunningPackageService runningPackageService ); // When refiner is provided in model card, enable for sampler - ModelCardViewModel - .WhenPropertyChanged(x => x.IsRefinerSelectionEnabled) - .Subscribe(e => - { - SamplerCardViewModel.IsRefinerStepsEnabled = - e.Sender is { IsRefinerSelectionEnabled: true, SelectedRefiner: not null }; - }); + AddDisposable( + ModelCardViewModel + .WhenPropertyChanged(x => x.IsRefinerSelectionEnabled) + .Subscribe(e => + { + SamplerCardViewModel.IsRefinerStepsEnabled = + e.Sender is { IsRefinerSelectionEnabled: true, SelectedRefiner: not null }; + }) + ); } /// diff --git a/StabilityMatrix.Avalonia/ViewModels/Inference/PromptCardViewModel.cs b/StabilityMatrix.Avalonia/ViewModels/Inference/PromptCardViewModel.cs index 919e4e309..a11eba3d3 100644 --- a/StabilityMatrix.Avalonia/ViewModels/Inference/PromptCardViewModel.cs +++ b/StabilityMatrix.Avalonia/ViewModels/Inference/PromptCardViewModel.cs @@ -28,7 +28,10 @@ namespace StabilityMatrix.Avalonia.ViewModels.Inference; [View(typeof(PromptCard))] [ManagedService] [Transient] -public partial class PromptCardViewModel : LoadableViewModelBase, IParametersLoadableState, IComfyStep +public partial class PromptCardViewModel + : DisposableLoadableViewModelBase, + IParametersLoadableState, + IComfyStep { private readonly IModelIndexService modelIndexService; private readonly ISettingsManager settingsManager; @@ -75,11 +78,13 @@ SharedState sharedState vm.AvailableModules = [typeof(PromptExpansionModule)]; }); - settingsManager.RelayPropertyFor( - this, - vm => vm.IsAutoCompletionEnabled, - settings => settings.IsPromptCompletionEnabled, - true + AddDisposable( + settingsManager.RelayPropertyFor( + this, + vm => vm.IsAutoCompletionEnabled, + settings => settings.IsPromptCompletionEnabled, + true + ) ); } diff --git a/StabilityMatrix.Core/Services/ISettingsManager.cs b/StabilityMatrix.Core/Services/ISettingsManager.cs index d0970f06b..1cf8a41b1 100644 --- a/StabilityMatrix.Core/Services/ISettingsManager.cs +++ b/StabilityMatrix.Core/Services/ISettingsManager.cs @@ -73,7 +73,7 @@ public interface ISettingsManager /// /// Register a source observable object and property to be relayed to Settings /// - void RelayPropertyFor( + IDisposable RelayPropertyFor( T source, Expression> sourceProperty, Expression> settingsProperty, diff --git a/StabilityMatrix.Core/Services/SettingsManager.cs b/StabilityMatrix.Core/Services/SettingsManager.cs index 23bd3d9f4..47befa35b 100644 --- a/StabilityMatrix.Core/Services/SettingsManager.cs +++ b/StabilityMatrix.Core/Services/SettingsManager.cs @@ -1,6 +1,11 @@ using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using System.Linq.Expressions; +<<<<<<< HEAD +======= +using System.Reactive.Disposables; +using System.Reactive.Linq; +>>>>>>> fe741d7c (Merge pull request #750 from ionite34/disposables-improvement) using System.Reflection; using System.Text.Json; using AsyncAwaitBestPractices; @@ -161,7 +166,7 @@ public void Transaction(Expression> expression, T } /// - public void RelayPropertyFor( + public IDisposable RelayPropertyFor( T source, Expression> sourceProperty, Expression> settingsProperty, @@ -181,7 +186,7 @@ public void RelayPropertyFor( var sourceTypeName = source.GetType().Name; // Update source when settings change - SettingsPropertyChanged += (sender, args) => + void OnSettingsPropertyChanged(object? sender, RelayPropertyChangedEventArgs args) { if (args.PropertyName != targetPropertyName) return; @@ -196,11 +201,16 @@ public void RelayPropertyFor( propertyName ); +<<<<<<< HEAD sourceSetter(source, settingsGetter(Settings)); }; +======= + sourceInstanceAccessor.Set(source, settingsAccessor.Get(Settings)); + } +>>>>>>> fe741d7c (Merge pull request #750 from ionite34/disposables-improvement) // Set and Save settings when source changes - source.PropertyChanged += (sender, args) => + void OnSourcePropertyChanged(object? sender, PropertyChangedEventArgs args) { if (args.PropertyName != propertyName) return; @@ -240,13 +250,41 @@ public void RelayPropertyFor( sender, new RelayPropertyChangedEventArgs(targetPropertyName, true) ); +<<<<<<< HEAD }; // Set initial value if requested if (setInitial) { sourceSetter(source, settingsGetter(Settings)); +======= +>>>>>>> fe741d7c (Merge pull request #750 from ionite34/disposables-improvement) } + + var subscription = Disposable.Create(() => + { + source.PropertyChanged -= OnSourcePropertyChanged; + SettingsPropertyChanged -= OnSettingsPropertyChanged; + }); + + try + { + SettingsPropertyChanged += OnSettingsPropertyChanged; + source.PropertyChanged += OnSourcePropertyChanged; + + // Set initial value if requested + if (setInitial) + { + sourceInstanceAccessor.Set(settingsAccessor.Get(Settings)); + } + } + catch + { + subscription.Dispose(); + throw; + } + + return subscription; } /// diff --git a/StabilityMatrix.Core/StabilityMatrix.Core.csproj b/StabilityMatrix.Core/StabilityMatrix.Core.csproj index 00f63c9a4..3db6fbda3 100644 --- a/StabilityMatrix.Core/StabilityMatrix.Core.csproj +++ b/StabilityMatrix.Core/StabilityMatrix.Core.csproj @@ -23,6 +23,10 @@ +<<<<<<< HEAD +======= + +>>>>>>> fe741d7c (Merge pull request #750 from ionite34/disposables-improvement) From 55fbf12ffd1e87d12a3a0e9d2bcd7fdb21b706b8 Mon Sep 17 00:00:00 2001 From: Ionite Date: Sat, 3 Aug 2024 19:49:47 -0400 Subject: [PATCH 04/12] Fix backport merge --- CHANGELOG.md | 53 ---------------------------------------------------- 1 file changed, 53 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ea1a1e80a..083bda03a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,60 +5,7 @@ All notable changes to Stability Matrix will be documented in this file. 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). -<<<<<<< HEAD -======= -## v2.12.0-dev.3 -### Added -- Added Settings option "Console: History Size" to adjust the number of lines stored in the console history when running packages. Defaults to 9001 lines. -#### Model Browser -- Added AuraFlow & Flux base model types to the CivitAI model browser -#### Checkpoint Manager -- Added "New Directory" and "Delete" options to the context menu of the tree view. -- Added new toggle for drag & drop - when enabled, all selected models will now move together with the dragged model -- Added "File Size" sorting option -- Added "Hide Empty Categories" toggle -- Added "Select All" button to the InfoBar (shown when at least one model is selected) -- Added "unet" shared model folder for ComfyUI -### Changed -- The "Download Failed" message for model downloads is now persistent until dismissed -### Fixed -- Fixed "The version of the native libSkiaSharp library (88.1) is incompatible with this version of SkiaSharp." error for Linux users -- Fixed download links for IPAdapters in the HuggingFace model browser -- Fixed potential memory leak of transient controls (Inference Prompt and Output Image Viewer) not being garbage collected due to event subscriptions - -## v2.12.0-dev.2 -### Added -- Added Face Detailer module to Inference -- Added ultralytics models to HuggingFace model browser -- Added DoRA category to CivitAI model browser -- Added macOS support for Fooocus & related forks -- (Windows, Linux) Added Vulkan rendering support using launch argument `--vulkan`. (On Windows, the default WinUI composition renderer is likely still preferrable. Linux users are encouraged to try the new renderer to see if it improves performance and responsiveness.) -### Changed -- (Internal) Updated Avalonia to 11.1.1 - Includes major rendering and performance optimizations, animation refinements, improved IME / text selection, and improvements for window sizing / z-order / multi-monitor DPI scaling. ([avaloniaui.net/blog/avalonia-11-1-a-quantum-leap-in-cross-platform-ui-development](https://avaloniaui.net/blog/avalonia-11-1-a-quantum-leap-in-cross-platform-ui-development)) -- (Internal) Updated SkiaSharp (Rendering Backend) to 3.0.0-preview.4.1, potentially fixes issues with window rendering artifacts on some machines. -- (Internal) Updated other dependencies for security and bug fixes. -### Fixed -- Fixed some ScrollViewers changing scroll position when focus changes -- Fixed [#782](https://github.com/LykosAI/StabilityMatrix/issues/782) - conflict error when launching new versions of Forge -- Fixed incorrect torch versions being installed for InvokeAI -### Supporters -#### Visionaries -- A huge thank you goes out to our esteemed Visionary-tier Patreon backers: **Scopp Mcdee**, **Waterclouds**, and **Akiro_Senkai**. Your kind support means the world! - -## v2.12.0-dev.1 -### Added -- Added new package: [Fooocus - mashb1t's 1-Up Edition](https://github.com/mashb1t/Fooocus) by mashb1t -- Added new package: [Stable Diffusion WebUI reForge](https://github.com/Panchovix/stable-diffusion-webui-reForge/) by Panchovix -- Image viewer context menus now have 2 options: `Copy (Ctrl+C)` which now always copies the image as a file, and `Copy as Bitmap (Shift+Ctrl+C)` (Available on Windows) which copies to the clipboard as native bitmap. This changes the previous single `Copy` button behavior that would first attempt a native bitmap copy on Windows when available, and fall back to a file copy if not. -- Added "Change Version" option to the package card overflow menu, allowing you to downgrade or upgrade a package to a specific version or commit -- Added "Disable Update Check" option to the package card overflow menu, allowing you to disable update checks for a specific package -- Added "Run Command" option in Settings for running a command with the embedded Python or Git executables -- Added Intel OneAPI XPU backend (IPEX) option for SD.Next -### Supporters -#### Visionaries -- Shoutout to our Visionary-tier Patreon supporters, **Scopp Mcdee**, **Waterclouds**, and our newest Visionary, **Akiro_Senkai**! Many thanks for your generous support! ->>>>>>> fe741d7c (Merge pull request #750 from ionite34/disposables-improvement) ## v2.11.6 ### Fixed - Fixed incorrect IPAdapter download links in the HuggingFace model browser From 267a60429f3d3545c5abf1bc217fd02155882389 Mon Sep 17 00:00:00 2001 From: Ionite Date: Sat, 3 Aug 2024 19:50:09 -0400 Subject: [PATCH 05/12] Fix formatting --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 083bda03a..a29178939 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,6 @@ All notable changes to Stability Matrix will be documented in this file. 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.11.6 ### Fixed - Fixed incorrect IPAdapter download links in the HuggingFace model browser From eaa88d5acae3f1e5007784cf21d523634f09602c Mon Sep 17 00:00:00 2001 From: Ionite Date: Sat, 3 Aug 2024 19:51:20 -0400 Subject: [PATCH 06/12] Fix merge --- StabilityMatrix.Core/StabilityMatrix.Core.csproj | 3 --- 1 file changed, 3 deletions(-) diff --git a/StabilityMatrix.Core/StabilityMatrix.Core.csproj b/StabilityMatrix.Core/StabilityMatrix.Core.csproj index 3db6fbda3..3b6a7e1cd 100644 --- a/StabilityMatrix.Core/StabilityMatrix.Core.csproj +++ b/StabilityMatrix.Core/StabilityMatrix.Core.csproj @@ -23,10 +23,7 @@ -<<<<<<< HEAD -======= ->>>>>>> fe741d7c (Merge pull request #750 from ionite34/disposables-improvement) From d92b5f9b1091398d02af21d33e9ee74954eef172 Mon Sep 17 00:00:00 2001 From: Ionite Date: Sat, 3 Aug 2024 19:57:55 -0400 Subject: [PATCH 07/12] Fix merge --- .../Services/SettingsManager.cs | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/StabilityMatrix.Core/Services/SettingsManager.cs b/StabilityMatrix.Core/Services/SettingsManager.cs index 47befa35b..e246481da 100644 --- a/StabilityMatrix.Core/Services/SettingsManager.cs +++ b/StabilityMatrix.Core/Services/SettingsManager.cs @@ -1,11 +1,8 @@ using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using System.Linq.Expressions; -<<<<<<< HEAD -======= using System.Reactive.Disposables; using System.Reactive.Linq; ->>>>>>> fe741d7c (Merge pull request #750 from ionite34/disposables-improvement) using System.Reflection; using System.Text.Json; using AsyncAwaitBestPractices; @@ -201,13 +198,8 @@ void OnSettingsPropertyChanged(object? sender, RelayPropertyChangedEventArgs arg propertyName ); -<<<<<<< HEAD - sourceSetter(source, settingsGetter(Settings)); - }; -======= sourceInstanceAccessor.Set(source, settingsAccessor.Get(Settings)); } ->>>>>>> fe741d7c (Merge pull request #750 from ionite34/disposables-improvement) // Set and Save settings when source changes void OnSourcePropertyChanged(object? sender, PropertyChangedEventArgs args) @@ -250,15 +242,6 @@ void OnSourcePropertyChanged(object? sender, PropertyChangedEventArgs args) sender, new RelayPropertyChangedEventArgs(targetPropertyName, true) ); -<<<<<<< HEAD - }; - - // Set initial value if requested - if (setInitial) - { - sourceSetter(source, settingsGetter(Settings)); -======= ->>>>>>> fe741d7c (Merge pull request #750 from ionite34/disposables-improvement) } var subscription = Disposable.Create(() => From c99f9a1615d029f4a655f0c76a963638c238c289 Mon Sep 17 00:00:00 2001 From: Ionite Date: Sat, 3 Aug 2024 20:01:39 -0400 Subject: [PATCH 08/12] Actually fix merge --- .../Services/SettingsManager.cs | 37 +++++++++---------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/StabilityMatrix.Core/Services/SettingsManager.cs b/StabilityMatrix.Core/Services/SettingsManager.cs index e246481da..d7cd53353 100644 --- a/StabilityMatrix.Core/Services/SettingsManager.cs +++ b/StabilityMatrix.Core/Services/SettingsManager.cs @@ -172,30 +172,29 @@ public IDisposable RelayPropertyFor( ) where T : INotifyPropertyChanged { - var sourceGetter = sourceProperty.Compile(); - var (propertyName, assigner) = Expressions.GetAssigner(sourceProperty); - var sourceSetter = assigner.Compile(); + var sourceInstanceAccessor = CompiledExpression.CreateAccessor(sourceProperty).WithInstance(source); + var settingsAccessor = CompiledExpression.CreateAccessor(settingsProperty); - var settingsGetter = settingsProperty.Compile(); - var (targetPropertyName, settingsAssigner) = Expressions.GetAssigner(settingsProperty); - var settingsSetter = settingsAssigner.Compile(); + var sourcePropertyPath = sourceInstanceAccessor.FullName; + var settingsPropertyPath = settingsAccessor.FullName; var sourceTypeName = source.GetType().Name; // Update source when settings change void OnSettingsPropertyChanged(object? sender, RelayPropertyChangedEventArgs args) { - if (args.PropertyName != targetPropertyName) + if (args.PropertyName != settingsPropertyPath) return; // Skip if event is relay and the sender is the source, to prevent duplicate if (args.IsRelay && ReferenceEquals(sender, source)) return; + logger.LogTrace( - "[RelayPropertyFor] " + "Settings.{TargetProperty:l} -> {SourceType:l}.{SourceProperty:l}", - targetPropertyName, + "[RelayPropertyFor] " + "Settings.{SettingsProperty:l} -> {SourceType:l}.{SourceProperty:l}", + settingsPropertyPath, sourceTypeName, - propertyName + sourcePropertyPath ); sourceInstanceAccessor.Set(source, settingsAccessor.Get(Settings)); @@ -204,17 +203,17 @@ void OnSettingsPropertyChanged(object? sender, RelayPropertyChangedEventArgs arg // Set and Save settings when source changes void OnSourcePropertyChanged(object? sender, PropertyChangedEventArgs args) { - if (args.PropertyName != propertyName) + if (args.PropertyName != sourcePropertyPath) return; logger.LogTrace( - "[RelayPropertyFor] " + "{SourceType:l}.{SourceProperty:l} -> Settings.{TargetProperty:l}", + "[RelayPropertyFor] {SourceType:l}.{SourceProperty:l} -> Settings.{SettingsProperty:l}", sourceTypeName, - propertyName, - targetPropertyName + sourcePropertyPath, + settingsPropertyPath ); - settingsSetter(Settings, sourceGetter(source)); + settingsAccessor.Set(Settings, sourceInstanceAccessor.Get()); if (IsLibraryDirSet) { @@ -230,17 +229,17 @@ void OnSourcePropertyChanged(object? sender, PropertyChangedEventArgs args) else { logger.LogWarning( - "[RelayPropertyFor] LibraryDir not set when saving ({SourceType:l}.{SourceProperty:l} -> Settings.{TargetProperty:l})", + "[RelayPropertyFor] LibraryDir not set when saving ({SourceType:l}.{SourceProperty:l} -> Settings.{SettingsProperty:l})", sourceTypeName, - propertyName, - targetPropertyName + sourcePropertyPath, + settingsPropertyPath ); } // Invoke property changed event, passing along sender SettingsPropertyChanged?.Invoke( sender, - new RelayPropertyChangedEventArgs(targetPropertyName, true) + new RelayPropertyChangedEventArgs(settingsPropertyPath, true) ); } From 861b6d80a39ff87f78000a2dbd617679d1a3fe49 Mon Sep 17 00:00:00 2001 From: Ionite Date: Sat, 3 Aug 2024 20:06:11 -0400 Subject: [PATCH 09/12] Missing usings --- StabilityMatrix.Core/Services/SettingsManager.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/StabilityMatrix.Core/Services/SettingsManager.cs b/StabilityMatrix.Core/Services/SettingsManager.cs index d7cd53353..4f369095c 100644 --- a/StabilityMatrix.Core/Services/SettingsManager.cs +++ b/StabilityMatrix.Core/Services/SettingsManager.cs @@ -1,4 +1,4 @@ -using System.ComponentModel; +using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using System.Linq.Expressions; using System.Reactive.Disposables; @@ -6,6 +6,7 @@ using System.Reflection; using System.Text.Json; using AsyncAwaitBestPractices; +using CompiledExpressions; using Microsoft.Extensions.Logging; using StabilityMatrix.Core.Attributes; using StabilityMatrix.Core.Helper; From 59557c8de17d2ebfd418c70f81531bd27cc2800a Mon Sep 17 00:00:00 2001 From: JT Date: Sun, 4 Aug 2024 20:13:31 -0700 Subject: [PATCH 10/12] Merge pull request #753 from ionite34/fix-batch-seed Fix batch count seed increments not being recorded in project or image metadata (cherry picked from commit 6b46cb5eb9afd0fbc4b325b0890ff798a07e8886) --- CHANGELOG.md | 1 + .../Inference/InferenceTextToImageViewModel.cs | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a29178939..49760832b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning 2.0](https://semver.org/spec/v2 ### Fixed - Fixed incorrect IPAdapter download links in the HuggingFace model browser - Fixed potential memory leak of transient controls (Inference Prompt and Output Image Viewer) not being garbage collected due to event subscriptions +- Fixed Batch Count seeds not being recorded properly in Inference projects and image metadata ## v2.11.5 ### Added diff --git a/StabilityMatrix.Avalonia/ViewModels/Inference/InferenceTextToImageViewModel.cs b/StabilityMatrix.Avalonia/ViewModels/Inference/InferenceTextToImageViewModel.cs index 33f567601..4d628edac 100644 --- a/StabilityMatrix.Avalonia/ViewModels/Inference/InferenceTextToImageViewModel.cs +++ b/StabilityMatrix.Avalonia/ViewModels/Inference/InferenceTextToImageViewModel.cs @@ -214,13 +214,23 @@ CancellationToken cancellationToken var buildPromptArgs = new BuildPromptEventArgs { Overrides = overrides, SeedOverride = seed }; BuildPrompt(buildPromptArgs); + // update seed in project for batches + var inferenceProject = InferenceProjectDocument.FromLoadable(this); + if (inferenceProject.State?["Seed"]?["Seed"] is not null) + { + inferenceProject = inferenceProject.WithState(x => x["Seed"]["Seed"] = seed); + } + var generationArgs = new ImageGenerationEventArgs { Client = ClientManager.Client, Nodes = buildPromptArgs.Builder.ToNodeDictionary(), OutputNodeNames = buildPromptArgs.Builder.Connections.OutputNodeNames.ToArray(), - Parameters = SaveStateToParameters(new GenerationParameters()), - Project = InferenceProjectDocument.FromLoadable(this), + Parameters = SaveStateToParameters(new GenerationParameters()) with + { + Seed = Convert.ToUInt64(seed) + }, + Project = inferenceProject, FilesToTransfer = buildPromptArgs.FilesToTransfer, BatchIndex = i, // Only clear output images on the first batch From 9ded82d5ade35a8b8598bb9b671bdbc1acfd9364 Mon Sep 17 00:00:00 2001 From: JT Date: Wed, 7 Aug 2024 21:44:11 -0700 Subject: [PATCH 11/12] Merge pull request #758 from ionite34/fix-swarm-args Fix swarm args (cherry picked from commit 191df85fd58bcf5158c17c55aaaa2c38566156dd) --- CHANGELOG.md | 6 ++++++ StabilityMatrix.Core/Models/Packages/StableSwarm.cs | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 49760832b..5e3e56fdf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,12 @@ and this project adheres to [Semantic Versioning 2.0](https://semver.org/spec/v2 - Fixed incorrect IPAdapter download links in the HuggingFace model browser - Fixed potential memory leak of transient controls (Inference Prompt and Output Image Viewer) not being garbage collected due to event subscriptions - Fixed Batch Count seeds not being recorded properly in Inference projects and image metadata +- Fixed [#795](https://github.com/LykosAI/StabilityMatrix/issues/795) - SwarmUI launch args not working properly +### Supporters +#### Visionaries +- Shoutout to our Visionary-tier Patreon supporter, **Scopp Mcdee**! Huge thanks for your continued support! +#### Pioneers +- Many thanks to our Pioneer-tier supporters on Patreon: **tankfox**, **tanangular**, **Mr. Unknown**, and **Szir777**! Your continued support is greatly appreciated! ## v2.11.5 ### Added diff --git a/StabilityMatrix.Core/Models/Packages/StableSwarm.cs b/StabilityMatrix.Core/Models/Packages/StableSwarm.cs index 32ca92eb2..b64f4ca43 100644 --- a/StabilityMatrix.Core/Models/Packages/StableSwarm.cs +++ b/StabilityMatrix.Core/Models/Packages/StableSwarm.cs @@ -280,7 +280,9 @@ void HandleConsoleOutput(ProcessOutput s) dotnetProcess = await prerequisiteHelper .RunDotnet( - args: [Path.Combine(releaseFolder, dllName), arguments.TrimEnd()], + args: new ProcessArgs(new[] { Path.Combine(releaseFolder, dllName) }).Concat( + arguments.TrimEnd() + ), workingDirectory: installedPackagePath, envVars: aspEnvVars, onProcessOutput: HandleConsoleOutput, From 2144816f5b29ea62a9d76c93767736f1fcc2b1b9 Mon Sep 17 00:00:00 2001 From: JT Date: Thu, 8 Aug 2024 20:21:33 -0700 Subject: [PATCH 12/12] Merge pull request #762 from ionite34/fix-swarm-env-vars actually pass the env vars to swarm (cherry picked from commit b1b06243a3996797e59daba01c7b637e098312d8) --- CHANGELOG.md | 1 + StabilityMatrix.Core/Models/Packages/StableSwarm.cs | 2 ++ 2 files changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e3e56fdf..bdae88aaf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning 2.0](https://semver.org/spec/v2 - Fixed potential memory leak of transient controls (Inference Prompt and Output Image Viewer) not being garbage collected due to event subscriptions - Fixed Batch Count seeds not being recorded properly in Inference projects and image metadata - Fixed [#795](https://github.com/LykosAI/StabilityMatrix/issues/795) - SwarmUI launch args not working properly +- Fixed [#745](https://github.com/LykosAI/StabilityMatrix/issues/745) - not passing Environment Variables to SwarmUI ### Supporters #### Visionaries - Shoutout to our Visionary-tier Patreon supporter, **Scopp Mcdee**! Huge thanks for your continued support! diff --git a/StabilityMatrix.Core/Models/Packages/StableSwarm.cs b/StabilityMatrix.Core/Models/Packages/StableSwarm.cs index b64f4ca43..65f6a75b4 100644 --- a/StabilityMatrix.Core/Models/Packages/StableSwarm.cs +++ b/StabilityMatrix.Core/Models/Packages/StableSwarm.cs @@ -3,6 +3,7 @@ using FreneticUtilities.FreneticDataSyntax; using StabilityMatrix.Core.Attributes; using StabilityMatrix.Core.Exceptions; +using StabilityMatrix.Core.Extensions; using StabilityMatrix.Core.Helper; using StabilityMatrix.Core.Helper.Cache; using StabilityMatrix.Core.Models.FDS; @@ -254,6 +255,7 @@ public override async Task RunPackage( ["ASPNETCORE_ENVIRONMENT"] = "Production", ["ASPNETCORE_URLS"] = "http://*:7801" }; + aspEnvVars.Update(settingsManager.Settings.EnvironmentVariables); void HandleConsoleOutput(ProcessOutput s) {