From 806966ceb195fd18362f50ea0dd2aea34f32f70e Mon Sep 17 00:00:00 2001 From: JT Date: Fri, 21 Jun 2024 21:44:56 -0700 Subject: [PATCH 1/7] Migrate StableSwarm -> SwarmUI (cherry picked from commit 30be4f67d3f06a405fa1dbbe01701dcbee26e358) --- .../Models/Packages/StableSwarm.cs | 80 +++++++++++++++---- 1 file changed, 63 insertions(+), 17 deletions(-) diff --git a/StabilityMatrix.Core/Models/Packages/StableSwarm.cs b/StabilityMatrix.Core/Models/Packages/StableSwarm.cs index 961fd6da6..09e159c92 100644 --- a/StabilityMatrix.Core/Models/Packages/StableSwarm.cs +++ b/StabilityMatrix.Core/Models/Packages/StableSwarm.cs @@ -5,6 +5,7 @@ using StabilityMatrix.Core.Exceptions; using StabilityMatrix.Core.Helper; using StabilityMatrix.Core.Helper.Cache; +using StabilityMatrix.Core.Models.Database; using StabilityMatrix.Core.Models.FDS; using StabilityMatrix.Core.Models.FileInterfaces; using StabilityMatrix.Core.Models.Progress; @@ -24,20 +25,18 @@ IPrerequisiteHelper prerequisiteHelper private Process? dotnetProcess; public override string Name => "StableSwarmUI"; - public override string DisplayName { get; set; } = "StableSwarmUI"; - public override string Author => "Stability-AI"; + public override string DisplayName { get; set; } = "SwarmUI"; + public override string Author => "mcmonkeyprojects"; public override string Blurb => "A Modular Stable Diffusion Web-User-Interface, with an emphasis on making powertools easily accessible, high performance, and extensibility."; public override string LicenseType => "MIT"; public override string LicenseUrl => - "https://github.com/Stability-AI/StableSwarmUI/blob/master/LICENSE.txt"; + "https://github.com/mcmonkeyprojects/SwarmUI/blob/master/LICENSE.txt"; public override string LaunchCommand => string.Empty; public override Uri PreviewImageUri => - new( - "https://raw.githubusercontent.com/Stability-AI/StableSwarmUI/master/.github/images/stableswarmui.jpg" - ); + new("https://github.com/mcmonkeyprojects/SwarmUI/raw/master/.github/images/swarmui.jpg"); public override string OutputFolderName => "Output"; public override IEnumerable AvailableSharedFolderMethods => [SharedFolderMethod.Symlink, SharedFolderMethod.Configuration, SharedFolderMethod.None]; @@ -133,7 +132,7 @@ public override async Task InstallPackage( Action? onConsoleOutput = null ) { - progress?.Report(new ProgressReport(-1f, "Installing StableSwarmUI...", isIndeterminate: true)); + progress?.Report(new ProgressReport(-1f, "Installing SwarmUI...", isIndeterminate: true)); var comfy = settingsManager.Settings.InstalledPackages.FirstOrDefault( x => x.PackageName == nameof(ComfyUI) @@ -141,7 +140,7 @@ public override async Task InstallPackage( if (comfy == null) { - throw new InvalidOperationException("ComfyUI must be installed to use StableSwarmUI"); + throw new InvalidOperationException("ComfyUI must be installed to use SwarmUI"); } try @@ -166,16 +165,16 @@ await prerequisiteHelper // ignore, probably means the source is already there } + var srcFolder = Path.Combine(installLocation, "src"); + var csprojName = "StableSwarmUI.csproj"; + if (File.Exists(Path.Combine(srcFolder, "SwarmUI.csproj"))) + { + csprojName = "SwarmUI.csproj"; + } + await prerequisiteHelper .RunDotnet( - [ - "build", - "src/StableSwarmUI.csproj", - "--configuration", - "Release", - "-o", - "src/bin/live_release" - ], + ["build", $"src/{csprojName}", "--configuration", "Release", "-o", "src/bin/live_release"], workingDirectory: installLocation, onProcessOutput: onConsoleOutput ) @@ -273,9 +272,16 @@ void HandleConsoleOutput(ProcessOutput s) } } + var releaseFolder = Path.Combine(installedPackagePath, "src", "bin", "live_release"); + var dllName = "StableSwarmUI.dll"; + if (File.Exists(Path.Combine(releaseFolder, "SwarmUI.dll"))) + { + dllName = "SwarmUI.dll"; + } + dotnetProcess = await prerequisiteHelper .RunDotnet( - args: $"src{Path.DirectorySeparatorChar}bin{Path.DirectorySeparatorChar}live_release{Path.DirectorySeparatorChar}StableSwarmUI.dll {arguments.TrimEnd()}", + args: $"{Path.Combine(releaseFolder, dllName)} {arguments.TrimEnd()}", workingDirectory: installedPackagePath, envVars: aspEnvVars, onProcessOutput: HandleConsoleOutput, @@ -284,6 +290,46 @@ void HandleConsoleOutput(ProcessOutput s) .ConfigureAwait(false); } + public override async Task CheckForUpdates(InstalledPackage package) + { + var needsMigrate = false; + try + { + var output = await prerequisiteHelper + .GetGitOutput(["remote", "get-url", "origin"], package.FullPath) + .ConfigureAwait(false); + + if ( + output.StandardOutput != null + && output.StandardOutput.Contains("Stability", StringComparison.OrdinalIgnoreCase) + ) + { + needsMigrate = true; + } + } + catch (Exception) + { + needsMigrate = true; + } + + if (needsMigrate) + { + await prerequisiteHelper + .RunGit( + ["remote", "set-url", "origin", $"https://github.com/{Author}/SwarmUI"], + package.FullPath + ) + .ConfigureAwait(false); + } + + return await base.CheckForUpdates(package).ConfigureAwait(false); + } + + public override Task?> GetAllCommits(string branch, int page = 1, int perPage = 10) + { + return GithubApi.GetAllCommits(Author, "SwarmUI", branch, page, perPage); + } + public override Task SetupModelFolders( DirectoryPath installDirectory, SharedFolderMethod sharedFolderMethod From c75b1f11f3607fc90c15a750bec6f0befa4c71b6 Mon Sep 17 00:00:00 2001 From: JT Date: Fri, 21 Jun 2024 21:47:37 -0700 Subject: [PATCH 2/7] chagenlog (cherry picked from commit 2ea24f727e1ff41e4ffbc89e10c32d80c0db5b4b) --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 741a4ac41..71ebbbda4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,11 @@ 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.2 +### Changed +- StableSwarmUI installs will be migrated to SwarmUI by mcmonkeyprojects the next time the package is updated + - Note: As of 2024/06/21 StableSwarmUI will no longer be maintained under Stability AI. The original developer will be maintaining an independent version of this project + ## v2.11.1 ### Added - Added Rename option back to the Checkpoints page From 65a39a5bffcf0671151ee2e5a0aaaf6ecda382a0 Mon Sep 17 00:00:00 2001 From: JT Date: Fri, 21 Jun 2024 22:27:22 -0700 Subject: [PATCH 3/7] fix url for new installs (cherry picked from commit 2f712b096054913f20c494fa30b691bd74c665f3) --- StabilityMatrix.Core/Models/Packages/StableSwarm.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/StabilityMatrix.Core/Models/Packages/StableSwarm.cs b/StabilityMatrix.Core/Models/Packages/StableSwarm.cs index 09e159c92..c740a6161 100644 --- a/StabilityMatrix.Core/Models/Packages/StableSwarm.cs +++ b/StabilityMatrix.Core/Models/Packages/StableSwarm.cs @@ -27,7 +27,7 @@ IPrerequisiteHelper prerequisiteHelper public override string Name => "StableSwarmUI"; public override string DisplayName { get; set; } = "SwarmUI"; public override string Author => "mcmonkeyprojects"; - + public override string GithubUrl => $"https://github.com/{Author}/SwarmUI"; public override string Blurb => "A Modular Stable Diffusion Web-User-Interface, with an emphasis on making powertools easily accessible, high performance, and extensibility."; From 93f868be3b050d432f0d0f6e1996e63bf45a13f1 Mon Sep 17 00:00:00 2001 From: JT Date: Sat, 22 Jun 2024 12:32:17 -0700 Subject: [PATCH 4/7] Update SDWebForge.cs --- StabilityMatrix.Core/Models/Packages/SDWebForge.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/StabilityMatrix.Core/Models/Packages/SDWebForge.cs b/StabilityMatrix.Core/Models/Packages/SDWebForge.cs index 9e3049559..795678bb3 100644 --- a/StabilityMatrix.Core/Models/Packages/SDWebForge.cs +++ b/StabilityMatrix.Core/Models/Packages/SDWebForge.cs @@ -169,7 +169,7 @@ public override async Task InstallPackage( await requirements.WriteAllTextAsync(requirementsContent).ConfigureAwait(false); } - var pipArgs = new PipInstallArgs(); + var pipArgs = new PipInstallArgs("setuptools==69.5.1"); if (torchVersion is TorchVersion.DirectMl) { pipArgs = pipArgs.WithTorchDirectML(); From 77fc9cf732216643ff6a6b6b8bc37ac290ad4af2 Mon Sep 17 00:00:00 2001 From: JT Date: Sat, 22 Jun 2024 12:32:41 -0700 Subject: [PATCH 5/7] Update CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 71ebbbda4..86bee48f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning 2.0](https://semver.org/spec/v2 ### Changed - StableSwarmUI installs will be migrated to SwarmUI by mcmonkeyprojects the next time the package is updated - Note: As of 2024/06/21 StableSwarmUI will no longer be maintained under Stability AI. The original developer will be maintaining an independent version of this project +### Fixed +- Fixed [#700](https://github.com/LykosAI/StabilityMatrix/issues/700) - `cannot import 'packaging'` error for Forge ## v2.11.1 ### Added From 902ba4aada66c3ec49f700e9e32f6765e0158029 Mon Sep 17 00:00:00 2001 From: JT Date: Sat, 22 Jun 2024 12:34:59 -0700 Subject: [PATCH 6/7] supporters --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 86bee48f6..902115838 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,11 @@ and this project adheres to [Semantic Versioning 2.0](https://semver.org/spec/v2 - Note: As of 2024/06/21 StableSwarmUI will no longer be maintained under Stability AI. The original developer will be maintaining an independent version of this project ### Fixed - Fixed [#700](https://github.com/LykosAI/StabilityMatrix/issues/700) - `cannot import 'packaging'` error for Forge +### Supporters +#### Visionaries +- Huge thanks to our Visionary-tier supporters on Patreon, **Scopp Mcdee** and **Waterclouds**! Your support helps us continue to improve Stability Matrix! +#### Pioneers +- Thank you to our Pioneer-tier supporters on Patreon, **tankfox** and **tanangular**! Your support is greatly appreciated! ## v2.11.1 ### Added From e5b30947d85fee3e78409a5d308ab4f893b2915f Mon Sep 17 00:00:00 2001 From: JT Date: Sat, 22 Jun 2024 13:53:05 -0700 Subject: [PATCH 7/7] swarm fix to main --- .../Models/Packages/BaseGitPackage.cs | 44 +++++++++++-------- .../Models/Packages/StableSwarm.cs | 13 +----- 2 files changed, 28 insertions(+), 29 deletions(-) diff --git a/StabilityMatrix.Core/Models/Packages/BaseGitPackage.cs b/StabilityMatrix.Core/Models/Packages/BaseGitPackage.cs index ff1117a9b..8c2347dbe 100644 --- a/StabilityMatrix.Core/Models/Packages/BaseGitPackage.cs +++ b/StabilityMatrix.Core/Models/Packages/BaseGitPackage.cs @@ -29,12 +29,15 @@ public abstract class BaseGitPackage : BasePackage protected readonly IPrerequisiteHelper PrerequisiteHelper; public PyVenvRunner? VenvRunner; + public virtual string RepositoryName => Name; + public virtual string RepositoryAuthor => Author; + /// /// URL of the hosted web page on launch /// protected string WebUrl = string.Empty; - public override string GithubUrl => $"https://github.com/{Author}/{Name}"; + public override string GithubUrl => $"https://github.com/{RepositoryAuthor}/{RepositoryName}"; public string DownloadLocation => Path.Combine(SettingsManager.LibraryDir, "Packages", $"{Name}.zip"); @@ -42,17 +45,17 @@ protected string GetDownloadUrl(DownloadPackageVersionOptions versionOptions) { if (!string.IsNullOrWhiteSpace(versionOptions.CommitHash)) { - return $"https://github.com/{Author}/{Name}/archive/{versionOptions.CommitHash}.zip"; + return $"https://github.com/{RepositoryAuthor}/{RepositoryName}/archive/{versionOptions.CommitHash}.zip"; } if (!string.IsNullOrWhiteSpace(versionOptions.VersionTag)) { - return $"https://api.github.com/repos/{Author}/{Name}/zipball/{versionOptions.VersionTag}"; + return $"https://api.github.com/repos/{RepositoryAuthor}/{RepositoryName}/zipball/{versionOptions.VersionTag}"; } if (!string.IsNullOrWhiteSpace(versionOptions.BranchName)) { - return $"https://api.github.com/repos/{Author}/{Name}/zipball/{versionOptions.BranchName}"; + return $"https://api.github.com/repos/{RepositoryAuthor}/{RepositoryName}/zipball/{versionOptions.BranchName}"; } throw new Exception("No download URL available"); @@ -75,7 +78,9 @@ public override async Task GetLatestVersion(bool { if (ShouldIgnoreReleases) { - var commits = await GithubApi.GetAllCommits(Author, Name, MainBranch).ConfigureAwait(false); + var commits = await GithubApi + .GetAllCommits(RepositoryAuthor, RepositoryName, MainBranch) + .ConfigureAwait(false); return new DownloadPackageVersionOptions { IsLatest = true, @@ -85,7 +90,7 @@ public override async Task GetLatestVersion(bool }; } - var releases = await GithubApi.GetAllReleases(Author, Name).ConfigureAwait(false); + var releases = await GithubApi.GetAllReleases(RepositoryAuthor, RepositoryName).ConfigureAwait(false); var latestRelease = includePrerelease ? releases.First() : releases.First(x => !x.Prerelease); return new DownloadPackageVersionOptions @@ -98,7 +103,7 @@ public override async Task GetLatestVersion(bool public override Task?> GetAllCommits(string branch, int page = 1, int perPage = 10) { - return GithubApi.GetAllCommits(Author, Name, branch, page, perPage); + return GithubApi.GetAllCommits(RepositoryAuthor, RepositoryName, branch, page, perPage); } public override async Task GetAllVersionOptions() @@ -107,7 +112,9 @@ public override async Task GetAllVersionOptions() if (!ShouldIgnoreReleases) { - var allReleases = await GithubApi.GetAllReleases(Author, Name).ConfigureAwait(false); + var allReleases = await GithubApi + .GetAllReleases(RepositoryAuthor, RepositoryName) + .ConfigureAwait(false); var releasesList = allReleases.ToList(); if (releasesList.Any()) { @@ -124,7 +131,9 @@ public override async Task GetAllVersionOptions() } // Branch mode - var allBranches = await GithubApi.GetAllBranches(Author, Name).ConfigureAwait(false); + var allBranches = await GithubApi + .GetAllBranches(RepositoryAuthor, RepositoryName) + .ConfigureAwait(false); packageVersionOptions.AvailableBranches = allBranches.Select( b => new PackageVersion { TagName = $"{b.Name}", ReleaseNotesMarkdown = string.Empty } ); @@ -197,7 +206,9 @@ public async Task SetupVenvPure( public override async Task> GetReleaseTags() { - var allReleases = await GithubApi.GetAllReleases(Author, Name).ConfigureAwait(false); + var allReleases = await GithubApi + .GetAllReleases(RepositoryAuthor, RepositoryName) + .ConfigureAwait(false); return allReleases; } @@ -576,8 +587,8 @@ SharedFolderMethod sharedFolderMethod await linkDir.DeleteAsync(false).ConfigureAwait(false); } - await StabilityMatrix - .Core.Helper.SharedFolders.UpdateLinksForPackage( + await Helper + .SharedFolders.UpdateLinksForPackage( sharedFolders, SettingsManager.ModelsDirectory, installDirectory @@ -597,7 +608,7 @@ SharedFolderMethod sharedFolderMethod { if (SharedFolders is not null && sharedFolderMethod == SharedFolderMethod.Symlink) { - StabilityMatrix.Core.Helper.SharedFolders.RemoveLinksForPackage(SharedFolders, installDirectory); + Helper.SharedFolders.RemoveLinksForPackage(SharedFolders, installDirectory); } return Task.CompletedTask; } @@ -606,7 +617,7 @@ public override Task SetupOutputFolderLinks(DirectoryPath installDirectory) { if (SharedOutputFolders is { } sharedOutputFolders) { - return StabilityMatrix.Core.Helper.SharedFolders.UpdateLinksForPackage( + return Helper.SharedFolders.UpdateLinksForPackage( sharedOutputFolders, SettingsManager.ImagesDirectory, installDirectory, @@ -621,10 +632,7 @@ public override Task RemoveOutputFolderLinks(DirectoryPath installDirectory) { if (SharedOutputFolders is { } sharedOutputFolders) { - StabilityMatrix.Core.Helper.SharedFolders.RemoveLinksForPackage( - sharedOutputFolders, - installDirectory - ); + Helper.SharedFolders.RemoveLinksForPackage(sharedOutputFolders, installDirectory); } return Task.CompletedTask; } diff --git a/StabilityMatrix.Core/Models/Packages/StableSwarm.cs b/StabilityMatrix.Core/Models/Packages/StableSwarm.cs index c740a6161..28ad81d5e 100644 --- a/StabilityMatrix.Core/Models/Packages/StableSwarm.cs +++ b/StabilityMatrix.Core/Models/Packages/StableSwarm.cs @@ -5,7 +5,6 @@ using StabilityMatrix.Core.Exceptions; using StabilityMatrix.Core.Helper; using StabilityMatrix.Core.Helper.Cache; -using StabilityMatrix.Core.Models.Database; using StabilityMatrix.Core.Models.FDS; using StabilityMatrix.Core.Models.FileInterfaces; using StabilityMatrix.Core.Models.Progress; @@ -25,9 +24,9 @@ IPrerequisiteHelper prerequisiteHelper private Process? dotnetProcess; public override string Name => "StableSwarmUI"; + public override string RepositoryName => "SwarmUI"; public override string DisplayName { get; set; } = "SwarmUI"; public override string Author => "mcmonkeyprojects"; - public override string GithubUrl => $"https://github.com/{Author}/SwarmUI"; public override string Blurb => "A Modular Stable Diffusion Web-User-Interface, with an emphasis on making powertools easily accessible, high performance, and extensibility."; @@ -315,21 +314,13 @@ public override async Task CheckForUpdates(InstalledPackage package) if (needsMigrate) { await prerequisiteHelper - .RunGit( - ["remote", "set-url", "origin", $"https://github.com/{Author}/SwarmUI"], - package.FullPath - ) + .RunGit(["remote", "set-url", "origin", GithubUrl], package.FullPath) .ConfigureAwait(false); } return await base.CheckForUpdates(package).ConfigureAwait(false); } - public override Task?> GetAllCommits(string branch, int page = 1, int perPage = 10) - { - return GithubApi.GetAllCommits(Author, "SwarmUI", branch, page, perPage); - } - public override Task SetupModelFolders( DirectoryPath installDirectory, SharedFolderMethod sharedFolderMethod