Skip to content

Commit

Permalink
Merge pull request #710 from LykosAI/main
Browse files Browse the repository at this point in the history
v2.11.2
  • Loading branch information
mohnjiles authored Jun 22, 2024
2 parents 52d9da0 + c250ee9 commit b50e644
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 37 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@ 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
### 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
- Added Rename option back to the Checkpoints page
Expand Down
44 changes: 26 additions & 18 deletions StabilityMatrix.Core/Models/Packages/BaseGitPackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,30 +29,33 @@ public abstract class BaseGitPackage : BasePackage
protected readonly IPrerequisiteHelper PrerequisiteHelper;
public PyVenvRunner? VenvRunner;

public virtual string RepositoryName => Name;
public virtual string RepositoryAuthor => Author;

/// <summary>
/// URL of the hosted web page on launch
/// </summary>
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");

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");
Expand All @@ -75,7 +78,9 @@ public override async Task<DownloadPackageVersionOptions> 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,
Expand All @@ -85,7 +90,7 @@ public override async Task<DownloadPackageVersionOptions> 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
Expand All @@ -98,7 +103,7 @@ public override async Task<DownloadPackageVersionOptions> GetLatestVersion(bool

public override Task<IEnumerable<GitCommit>?> 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<PackageVersionOptions> GetAllVersionOptions()
Expand All @@ -107,7 +112,9 @@ public override async Task<PackageVersionOptions> 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())
{
Expand All @@ -124,7 +131,9 @@ public override async Task<PackageVersionOptions> 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 }
);
Expand Down Expand Up @@ -197,7 +206,9 @@ public async Task<PyVenvRunner> SetupVenvPure(

public override async Task<IEnumerable<Release>> GetReleaseTags()
{
var allReleases = await GithubApi.GetAllReleases(Author, Name).ConfigureAwait(false);
var allReleases = await GithubApi
.GetAllReleases(RepositoryAuthor, RepositoryName)
.ConfigureAwait(false);
return allReleases;
}

Expand Down Expand Up @@ -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
Expand All @@ -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;
}
Expand All @@ -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,
Expand All @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion StabilityMatrix.Core/Models/Packages/SDWebForge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
73 changes: 55 additions & 18 deletions StabilityMatrix.Core/Models/Packages/StableSwarm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,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 RepositoryName => "SwarmUI";
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<SharedFolderMethod> AvailableSharedFolderMethods =>
[SharedFolderMethod.Symlink, SharedFolderMethod.Configuration, SharedFolderMethod.None];
Expand Down Expand Up @@ -133,15 +131,15 @@ public override async Task InstallPackage(
Action<ProcessOutput>? 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)
);

if (comfy == null)
{
throw new InvalidOperationException("ComfyUI must be installed to use StableSwarmUI");
throw new InvalidOperationException("ComfyUI must be installed to use SwarmUI");
}

try
Expand All @@ -166,16 +164,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
)
Expand Down Expand Up @@ -273,9 +271,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,
Expand All @@ -284,6 +289,38 @@ void HandleConsoleOutput(ProcessOutput s)
.ConfigureAwait(false);
}

public override async Task<bool> 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", GithubUrl], package.FullPath)
.ConfigureAwait(false);
}

return await base.CheckForUpdates(package).ConfigureAwait(false);
}

public override Task SetupModelFolders(
DirectoryPath installDirectory,
SharedFolderMethod sharedFolderMethod
Expand Down

0 comments on commit b50e644

Please sign in to comment.