Skip to content

Commit

Permalink
Merge pull request LykosAI#717 from ionite34/fixes
Browse files Browse the repository at this point in the history
Fixes
  • Loading branch information
ionite34 authored Jul 4, 2024
2 parents de46fa8 + e1595e4 commit a00b61e
Show file tree
Hide file tree
Showing 9 changed files with 82 additions and 34 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@ and this project adheres to [Semantic Versioning 2.0](https://semver.org/spec/v2
## v2.11.4
### Changed
- Base Python install will now use `setuptools==69.5.1` for compatibility with `torchsde`. Individual Packages can upgrade as required.
- Improved formatting of "Copy Details" action on the Unexpected Error dialog
- (Debug) Logging verbosity for classes can now be configured with environment variables (`Logging__LogLevel__<TypeFullName>`).
### Fixed
- Fixed ComfyUI slower generation speed with new torch versions not including flash attention for windows, pinned `torch==2.1.2` for ComfyUI on Windows CUDA
- Fixed [#719](https://github.com/LykosAI/StabilityMatrix/issues/719) - Fix comments in Inference prompt not being ignored
- Fixed TaskCanceledException when Inference prompts finish before the delayed progress handler (250ms)
### Supporters
#### Visionaries
- Huge thanks to our Visionary-tier supporters on Patreon, **Scopp Mcdee** and **Waterclouds**! Your support helps us continue to improve Stability Matrix!
Expand Down
24 changes: 16 additions & 8 deletions StabilityMatrix.Avalonia/App.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,7 @@ internal static IServiceCollection ConfigureServices()
Config = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.AddEnvironmentVariables()
.Build();

services.Configure<DebugOptions>(Config.GetSection(nameof(DebugOptions)));
Expand Down Expand Up @@ -927,15 +928,22 @@ private static LoggingConfiguration ConfigureLogging()
builder.ForLogger("Microsoft.*").WriteToNil(NLog.LogLevel.Warn);
builder.ForLogger("Microsoft.Extensions.Http.*").WriteToNil(NLog.LogLevel.Warn);
// Disable console trace logging by default
builder
.ForLogger("StabilityMatrix.Avalonia.ViewModels.ConsoleViewModel")
.WriteToNil(NLog.LogLevel.Debug);
// Disable some trace logging by default, unless overriden by app settings
var typesToDisableTrace = new[] { typeof(ConsoleViewModel), typeof(LoadableViewModelBase) };
// Disable LoadableViewModelBase trace logging by default
builder
.ForLogger("StabilityMatrix.Avalonia.ViewModels.Base.LoadableViewModelBase")
.WriteToNil(NLog.LogLevel.Debug);
foreach (var type in typesToDisableTrace)
{
// Skip if app settings already set a level for this type
if (
Config[$"Logging:LogLevel:{type.FullName}"] is { } levelStr
&& Enum.TryParse<LogLevel>(levelStr, true, out _)
)
{
continue;
}
builder.ForLogger(type.FullName).FilterMinLevel(NLog.LogLevel.Debug);
}
// Debug console logging
/*if (Debugger.IsAttached)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,13 @@ protected async Task RunGeneration(ImageGenerationEventArgs args, CancellationTo
},
cancellationToken
)
.SafeFireAndForget();
.SafeFireAndForget(ex =>
{
if (ex is TaskCanceledException)
return;
Logger.Error(ex, "Error while attaching running node change handler");
});

// Wait for prompt to finish
try
Expand Down
54 changes: 37 additions & 17 deletions StabilityMatrix.Avalonia/ViewModels/Dialogs/ExceptionViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
using System.ComponentModel;
using System.Text;
using Sentry;
using StabilityMatrix.Avalonia.ViewModels.Base;
using StabilityMatrix.Avalonia.Views.Dialogs;
Expand All @@ -9,7 +11,7 @@ namespace StabilityMatrix.Avalonia.ViewModels.Dialogs;
[View(typeof(ExceptionDialog))]
[ManagedService]
[Transient]
public partial class ExceptionViewModel : ViewModelBase
public class ExceptionViewModel : ViewModelBase
{
public Exception? Exception { get; set; }

Expand All @@ -19,35 +21,53 @@ public partial class ExceptionViewModel : ViewModelBase

public string? ExceptionType => Exception?.GetType().Name ?? "";

[Localizable(false)]
public string? FormatAsMarkdown()
{
if (Exception is null)
{
return null;
}
var msgBuilder = new StringBuilder();
msgBuilder.AppendLine();

var message = $"## Exception\n{ExceptionType}: {Message}\n";
if (Exception is not null)
{
msgBuilder.AppendLine("## Exception");
msgBuilder.AppendLine($"```{ExceptionType}: {Message}```");

if (SentryId is not null)
if (Exception.InnerException is not null)
{
msgBuilder.AppendLine(
$"```{Exception.InnerException.GetType().Name}: {Exception.InnerException.Message}```"
);
}
}
else
{
message += $"### Sentry ID\n```\n{SentryId}\n```\n";
msgBuilder.AppendLine("## Exception");
msgBuilder.AppendLine("```(None)```");
}

if (Exception.StackTrace != null)
if (SentryId is { } id)
{
message += $"### Stack Trace\n```\n{Exception.StackTrace}\n```\n";
msgBuilder.AppendLine("### Sentry ID");
msgBuilder.AppendLine($"[`{id.ToString()[..8]}`]({GetIssueUrl(id)})");
}

if (Exception.InnerException is { } innerException)
if (Exception?.StackTrace is not null)
{
message += $"## Inner Exception\n{innerException.GetType().Name}: {innerException.Message}\n";
msgBuilder.AppendLine("### Stack Trace");
msgBuilder.AppendLine($"```{Exception.StackTrace}```");
}

if (innerException.StackTrace != null)
{
message += $"### Stack Trace\n```\n{innerException.StackTrace}\n```\n";
}
if (Exception?.InnerException is { StackTrace: not null } innerException)
{
msgBuilder.AppendLine($"```{innerException.StackTrace}```");
}

return message;
return msgBuilder.ToString();
}

[Localizable(false)]
private static string GetIssueUrl(SentryId sentryId)
{
return $"https://stability-matrix.sentry.io/issues/?query=id%3A{sentryId.ToString()}&referrer=sm-app-ex&statsPeriod=90d";
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using AsyncAwaitBestPractices;
using Avalonia.Controls;
using Avalonia.Threading;
using FluentAvalonia.UI.Controls;
Expand Down Expand Up @@ -86,7 +84,7 @@ private void PackageModificationRunnerOnProgressChanged(object? sender, Progress

public async Task ShowProgressDialog()
{
Progress.CloseWhenFinished = true;
Progress.CloseWhenFinished = packageModificationRunner.CloseWhenFinished;
dialog = new BetterContentDialog
{
MaxDialogWidth = 900,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public interface IPackageModificationRunner

bool HideCloseButton { get; init; }

bool CloseWhenFinished { get; init; }

string? ModificationCompleteTitle { get; init; }

string ModificationCompleteMessage { get; init; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ public async Task ExecuteSteps(IReadOnlyList<IPackageStep> steps)

public bool HideCloseButton { get; init; }

public bool CloseWhenFinished { get; init; } = true;

public bool ShowDialogOnStart { get; init; }

public string? ModificationCompleteTitle { get; init; } = "Install Complete";
Expand Down
15 changes: 10 additions & 5 deletions StabilityMatrix.Core/Models/Packages/ComfyUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,21 +192,23 @@ public override async Task InstallPackage(
)
{
progress?.Report(new ProgressReport(-1, "Setting up venv", isIndeterminate: true));
// Setup venv
await using var venvRunner = await SetupVenvPure(installLocation).ConfigureAwait(false);

await venvRunner.PipInstall("--upgrade pip wheel", onConsoleOutput).ConfigureAwait(false);

progress?.Report(
new ProgressReport(-1f, "Installing Package Requirements...", isIndeterminate: true)
);

var pipArgs = new PipInstallArgs();

pipArgs = torchVersion switch
{
TorchVersion.DirectMl => pipArgs.WithTorchDirectML(),
TorchVersion.Mps => pipArgs.WithTorch().WithTorchVision().WithTorchExtraIndex("cpu"),
TorchVersion.Cuda when Compat.IsWindows
=> pipArgs
.AddArg("--upgrade")
.WithTorch("==2.1.2")
.WithTorchVision("==0.16.2")
.WithTorchAudio("==2.1.2")
.WithTorchExtraIndex("cu121"),
_
=> pipArgs
.AddArg("--upgrade")
Expand Down Expand Up @@ -237,6 +239,9 @@ await requirements.ReadAllTextAsync().ConfigureAwait(false),
excludePattern: "torch"
);

progress?.Report(
new ProgressReport(-1f, "Installing Package Requirements...", isIndeterminate: true)
);
await venvRunner.PipInstall(pipArgs, onConsoleOutput).ConfigureAwait(false);

progress?.Report(new ProgressReport(1, "Installed Package Requirements", isIndeterminate: false));
Expand Down
3 changes: 3 additions & 0 deletions StabilityMatrix.Core/Python/PipInstallArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

namespace StabilityMatrix.Core.Python;

[SuppressMessage("ReSharper", "StringLiteralTypo")]
public record PipInstallArgs : ProcessArgsBuilder
{
public PipInstallArgs(params Argument[] arguments)
Expand All @@ -16,6 +17,8 @@ public PipInstallArgs(params Argument[] arguments)

public PipInstallArgs WithTorchVision(string version = "") => this.AddArg($"torchvision{version}");

public PipInstallArgs WithTorchAudio(string version = "") => this.AddArg($"torchaudio{version}");

public PipInstallArgs WithXFormers(string version = "") => this.AddArg($"xformers{version}");

public PipInstallArgs WithExtraIndex(string indexUrl) => this.AddArg(("--extra-index-url", indexUrl));
Expand Down

0 comments on commit a00b61e

Please sign in to comment.