Skip to content

Commit

Permalink
Merge pull request #699 from LykosAI/main
Browse files Browse the repository at this point in the history
v2.11.1
  • Loading branch information
mohnjiles authored Jun 19, 2024
2 parents 2328673 + 1825be9 commit 52d9da0
Show file tree
Hide file tree
Showing 35 changed files with 887 additions and 278 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: 'Close stale issues'

permissions:
issues: write
pull-requests: write

on:
workflow_dispatch:
schedule:
- cron: '30 1 * * *'

jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v9
with:
stale-issue-message: 'This issue is pending because it has been awaiting a response for 14 days with no activity. Remove the pending label or comment, else this will be closed in 5 days.'
close-issue-message: 'This issue was closed because it has been pending for 5 days with no activity.'
only-labels: 'awaiting-feedback'
stale-issue-label: 'pending'
exempt-issue-labels: 'planned,milestone,work-in-progress'
days-before-issue-stale: 14
days-before-issue-close: 5
days-before-pr-close: -1
days-before-pr-stale: -1
operations-per-run: 45

- uses: actions/stale@v9
with:
stale-issue-message: 'This issue is stale because it has been open 30 days with no activity. Remove the stale label or comment, else this will be closed in 5 days.'
close-issue-message: 'This issue was closed because it has been stale for 5 days with no activity.'
stale-issue-label: 'stale'
exempt-issue-labels: 'planned,milestone,work-in-progress'
days-before-issue-stale: 30
days-before-issue-close: 5
days-before-pr-close: -1
days-before-pr-stale: -1
operations-per-run: 45
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,23 @@ 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.1
### Added
- Added Rename option back to the Checkpoints page
### Changed
- Unobserved Task Exceptions across the app will now show a toast notification to aid in debugging
- Updated SD.Next Package details and thumbnail - [#697](https://github.com/LykosAI/StabilityMatrix/pull/697)
### Fixed
- Fixed [#689](https://github.com/LykosAI/StabilityMatrix/issues/689) - New ComfyUI installs encountering launch error due to torch 2.0.0 update, added pinned `numpy==1.26.4` to install and update.
- Fixed Inference image mask editor's 'Load Mask' not able to load image files
- Fixed Fooocus ControlNet default config shared folder mode not taking effect
- Fixed tkinter python libraries not working on macOS with 'Can't find a usable init.tcl' error
### Supporters
#### Visionaries
- Shoutout to our Visionary-tier supporters on Patreon, **Scopp Mcdee** and **Waterclouds**! Your generous support is appreciated and helps us continue to make Stability Matrix better for everyone!
#### Pioneers
- A big thank you to our Pioneer-tier supporters on Patreon, **tankfox** and **tanangular**! Your support helps us continue to improve Stability Matrix!

## v2.11.0
### Added
#### Packages
Expand Down
31 changes: 31 additions & 0 deletions StabilityMatrix.Avalonia/App.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ private void ShowMainWindow()
DesktopLifetime.ShutdownRequested += OnShutdownRequested;

AppDomain.CurrentDomain.ProcessExit += OnExit;
TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException;

// Since we're manually shutting down NLog in OnExit
LogManager.AutoShutdown = false;
Expand Down Expand Up @@ -883,6 +884,36 @@ private void OnExit(object? sender, EventArgs _)
}
}

private static void TaskScheduler_UnobservedTaskException(
object? sender,
UnobservedTaskExceptionEventArgs e
)
{
if (e.Exception is not Exception unobservedEx)
return;

try
{
var notificationService = Services.GetRequiredService<INotificationService>();

Dispatcher.UIThread.Invoke(() =>
{
var originException = unobservedEx.InnerException ?? unobservedEx;
notificationService.ShowPersistent(
$"Unobserved Task Exception - {originException.GetType().Name}",
originException.Message
);
});

// Consider the exception observed if we were able to show a notification
e.SetObserved();
}
catch (Exception ex)
{
Logger.Error(ex, "Failed to show Unobserved Task Exception notification");
}
}

private static LoggingConfiguration ConfigureLogging()
{
var setupBuilder = LogManager.Setup();
Expand Down
2 changes: 2 additions & 0 deletions StabilityMatrix.Avalonia/DesignData/DesignData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ public static void Initialize()
new MockModelIndexService(),
notificationService,
dialogFactory,
null,
new LocalModelFile
{
SharedFolderType = SharedFolderType.StableDiffusion,
Expand Down Expand Up @@ -356,6 +357,7 @@ public static void Initialize()
new MockModelIndexService(),
notificationService,
dialogFactory,
null,
new LocalModelFile
{
RelativePath = "~/Models/Lora/model.safetensors",
Expand Down
2 changes: 1 addition & 1 deletion StabilityMatrix.Avalonia/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ UnobservedTaskExceptionEventArgs e
{
if (e.Exception is Exception ex)
{
Logger.Error(ex, "Unobserved task exception");
Logger.Error(ex, "Unobserved Task Exception");
}
}

Expand Down
2 changes: 1 addition & 1 deletion StabilityMatrix.Avalonia/StabilityMatrix.Avalonia.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<ApplicationManifest>app.manifest</ApplicationManifest>
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
<ApplicationIcon>./Assets/Icon.ico</ApplicationIcon>
<Version>2.11.0-dev.999</Version>
<Version>2.12.0-dev.999</Version>
<InformationalVersion>$(Version)</InformationalVersion>
<EnableWindowsTargeting>true</EnableWindowsTargeting>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
using System;
using System.Collections.Immutable;
using System.ComponentModel;
using System.IO;
using System.Threading.Tasks;
using Avalonia.Controls.Notifications;
using Avalonia.Data;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using FluentAvalonia.UI.Controls;
using Microsoft.Extensions.Logging;
using StabilityMatrix.Avalonia.Services;
using StabilityMatrix.Avalonia.ViewModels.Base;
using StabilityMatrix.Avalonia.ViewModels.Dialogs;
Expand Down Expand Up @@ -36,6 +39,7 @@ public partial class CheckpointFileViewModel : SelectableViewModelBase
private readonly IModelIndexService modelIndexService;
private readonly INotificationService notificationService;
private readonly ServiceManager<ViewModelBase> vmFactory;
private readonly ILogger logger;

public bool CanShowTriggerWords => CheckpointFile.ConnectedModelInfo?.TrainedWords?.Length > 0;
public string BaseModelName => CheckpointFile.ConnectedModelInfo?.BaseModel ?? string.Empty;
Expand All @@ -47,13 +51,15 @@ public CheckpointFileViewModel(
IModelIndexService modelIndexService,
INotificationService notificationService,
ServiceManager<ViewModelBase> vmFactory,
ILogger logger,
LocalModelFile checkpointFile
)
{
this.settingsManager = settingsManager;
this.modelIndexService = modelIndexService;
this.notificationService = notificationService;
this.vmFactory = vmFactory;
this.logger = logger;
CheckpointFile = checkpointFile;
ThumbnailUri = settingsManager.IsLibraryDirSet
? CheckpointFile.GetPreviewImageFullPath(settingsManager.ModelsDirectory)
Expand Down Expand Up @@ -186,4 +192,71 @@ private async Task DeleteAsync(bool showConfirmation = true)

await modelIndexService.RemoveModelAsync(CheckpointFile);
}

[RelayCommand]
private async Task RenameAsync()
{
// Parent folder path
var parentPath =
Path.GetDirectoryName((string?)CheckpointFile.GetFullPath(settingsManager.ModelsDirectory)) ?? "";

var textFields = new TextBoxField[]
{
new()
{
Label = "File name",
Validator = text =>
{
if (string.IsNullOrWhiteSpace(text))
throw new DataValidationException("File name is required");
if (File.Exists(Path.Combine(parentPath, text)))
throw new DataValidationException("File name already exists");
},
Text = CheckpointFile.FileName
}
};

var dialog = DialogHelper.CreateTextEntryDialog("Rename Model", "", textFields);

if (await dialog.ShowAsync() == ContentDialogResult.Primary)
{
var name = textFields[0].Text;
var nameNoExt = Path.GetFileNameWithoutExtension(name);
var originalNameNoExt = Path.GetFileNameWithoutExtension(CheckpointFile.FileName);
// Rename file in OS
try
{
var newFilePath = Path.Combine(parentPath, name);
File.Move(CheckpointFile.GetFullPath(settingsManager.ModelsDirectory), newFilePath);

// If preview image exists, rename it too
var previewPath = CheckpointFile.GetPreviewImageFullPath(settingsManager.ModelsDirectory);
if (previewPath != null && File.Exists(previewPath))
{
var newPreviewImagePath = Path.Combine(
parentPath,
$"{nameNoExt}.preview{Path.GetExtension(previewPath)}"
);
File.Move(previewPath, newPreviewImagePath);
}

// If connected model info exists, rename it too (<name>.cm-info.json)
if (CheckpointFile.HasConnectedModel)
{
var cmInfoPath = Path.Combine(parentPath, $"{originalNameNoExt}.cm-info.json");
if (File.Exists(cmInfoPath))
{
File.Move(cmInfoPath, Path.Combine(parentPath, $"{nameNoExt}.cm-info.json"));
}
}

await modelIndexService.RefreshIndex();
}
catch (Exception e)
{
logger.LogError(e, "Failed to rename checkpoint file");
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ or nameof(SortConnectedModelsFirst)
modelIndexService,
notificationService,
dialogFactory,
logger,
x
)
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.ComponentModel;
using System.Linq;
Expand Down Expand Up @@ -77,6 +76,9 @@ public partial class PaintCanvasViewModel(ILogger<PaintCanvasViewModel> logger)
[JsonIgnore]
private SKLayer BrushLayer => Layers["Brush"];

[JsonIgnore]
private SKLayer ImagesLayer => Layers["Images"];

[JsonIgnore]
private SKLayer BackgroundLayer => Layers["Background"];

Expand All @@ -99,9 +101,6 @@ public SKBitmap? BackgroundImage
}
}

[JsonIgnore]
public List<SKBitmap> LayerImages { get; } = [];

/// <summary>
/// Set by <see cref="PaintCanvas"/> to allow the view model to
/// refresh the canvas view after updating points or bitmap layers.
Expand All @@ -117,8 +116,7 @@ public void SetSourceCanvas(SKCanvas canvas)

public void LoadCanvasFromBitmap(SKBitmap bitmap)
{
LayerImages.Clear();
LayerImages.Add(bitmap);
ImagesLayer.Bitmaps = [bitmap];

RefreshCanvas?.Invoke();
}
Expand Down
4 changes: 2 additions & 2 deletions StabilityMatrix.Avalonia/Views/CheckpointsPage.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -367,8 +367,8 @@
IsVisible="{Binding CheckpointFile.HasConnectedModel}" />

<ui:MenuFlyoutSeparator />
<!-- <ui:MenuFlyoutItem Command="{Binding RenameCommand}" -->
<!-- Text="{x:Static lang:Resources.Action_Rename}" IconSource="Rename" /> -->
<ui:MenuFlyoutItem Command="{Binding RenameCommand}"
Text="{x:Static lang:Resources.Action_Rename}" IconSource="Rename" />
<ui:MenuFlyoutItem Command="{Binding DeleteCommand}"
CommandParameter="{StaticResource True}"
Text="{x:Static lang:Resources.Action_Delete}"
Expand Down
Loading

0 comments on commit 52d9da0

Please sign in to comment.