Skip to content

Commit 6671969

Browse files
authored
Merge pull request LykosAI#356 from ionite34/downmerge
Downmerge
2 parents b641a77 + c48abc0 commit 6671969

File tree

5 files changed

+43
-43
lines changed

5 files changed

+43
-43
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ and this project adheres to [Semantic Versioning 2.0](https://semver.org/spec/v2
2828
- Better error reporting including outputs for git subprocess errors during package install / update
2929
- Fixed `'accelerate' is not recognized as an internal or external command` error when starting training in kohya_ss
3030
- Fixed some instances of `ModuleNotFoundError: No module named 'bitsandbytes.cuda_setup.paths'` error when using 8-bit optimizers in kohya_ss
31+
- Fixed errors preventing Inference outputs from loading in the img2img tabs of other packages
3132

3233
## v2.6.1
3334
### Changed

StabilityMatrix.Avalonia/Helpers/PngDataHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ private static byte[] BuildTextChunk(string key, string value)
104104
var dataBytes = Encoding.UTF8.GetBytes(textData);
105105
var textDataLength = BitConverter.GetBytes(dataBytes.Length).Reverse();
106106
var textDataBytes = Text.Concat(dataBytes).ToArray();
107-
var crc = BitConverter.GetBytes(Crc32Algorithm.Compute(textDataBytes));
107+
var crc = BitConverter.GetBytes(Crc32Algorithm.Compute(textDataBytes)).Reverse();
108108

109109
return textDataLength.Concat(textDataBytes).Concat(crc).ToArray();
110110
}

StabilityMatrix.Avalonia/ViewModels/Dialogs/InstallerViewModel.cs

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@
1414
using CommunityToolkit.Mvvm.ComponentModel;
1515
using CommunityToolkit.Mvvm.Input;
1616
using FluentAvalonia.UI.Controls;
17-
using NLog;
17+
using Microsoft.Extensions.Logging;
1818
using StabilityMatrix.Avalonia.Controls;
19+
using StabilityMatrix.Avalonia.Extensions;
1920
using StabilityMatrix.Avalonia.Languages;
2021
using StabilityMatrix.Avalonia.Services;
2122
using StabilityMatrix.Avalonia.ViewModels.Base;
@@ -24,6 +25,7 @@
2425
using StabilityMatrix.Core.Helper.Factory;
2526
using StabilityMatrix.Core.Models;
2627
using StabilityMatrix.Core.Models.Database;
28+
using StabilityMatrix.Core.Models.FileInterfaces;
2729
using StabilityMatrix.Core.Models.PackageModification;
2830
using StabilityMatrix.Core.Models.Packages;
2931
using StabilityMatrix.Core.Processes;
@@ -36,14 +38,13 @@ namespace StabilityMatrix.Avalonia.ViewModels.Dialogs;
3638
[Transient]
3739
public partial class InstallerViewModel : ContentDialogViewModelBase
3840
{
39-
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
40-
4141
private readonly ISettingsManager settingsManager;
4242
private readonly IPackageFactory packageFactory;
4343
private readonly IPyRunner pyRunner;
4444
private readonly IDownloadService downloadService;
4545
private readonly INotificationService notificationService;
4646
private readonly IPrerequisiteHelper prerequisiteHelper;
47+
private readonly ILogger<InstallerViewModel> logger;
4748

4849
[ObservableProperty]
4950
private BasePackage selectedPackage;
@@ -130,7 +131,8 @@ public InstallerViewModel(
130131
IPyRunner pyRunner,
131132
IDownloadService downloadService,
132133
INotificationService notificationService,
133-
IPrerequisiteHelper prerequisiteHelper
134+
IPrerequisiteHelper prerequisiteHelper,
135+
ILogger<InstallerViewModel> logger
134136
)
135137
{
136138
this.settingsManager = settingsManager;
@@ -139,6 +141,7 @@ IPrerequisiteHelper prerequisiteHelper
139141
this.downloadService = downloadService;
140142
this.notificationService = notificationService;
141143
this.prerequisiteHelper = prerequisiteHelper;
144+
this.logger = logger;
142145

143146
var filtered = packageFactory.GetAllAvailablePackages().Where(p => p.IsCompatible).ToList();
144147

@@ -187,7 +190,7 @@ public override async Task OnLoadedAsync()
187190
}
188191
catch (Exception e)
189192
{
190-
Logger.Warn("Error getting versions: {Exception}", e.ToString());
193+
logger.LogWarning("Error getting versions: {Exception}", e.ToString());
191194
}
192195
finally
193196
{
@@ -209,7 +212,7 @@ private async Task Install()
209212
else
210213
{
211214
var ex = result.Exception!;
212-
Logger.Error(ex, $"Error installing package: {ex}");
215+
logger.LogError(ex, $"Error installing package: {ex}");
213216

214217
var dialog = new BetterContentDialog
215218
{
@@ -221,7 +224,7 @@ private async Task Install()
221224
}
222225
}
223226

224-
private Task ActuallyInstall()
227+
private async Task ActuallyInstall()
225228
{
226229
if (string.IsNullOrWhiteSpace(InstallName))
227230
{
@@ -232,12 +235,18 @@ private Task ActuallyInstall()
232235
NotificationType.Error
233236
)
234237
);
235-
return Task.CompletedTask;
238+
return;
236239
}
237240

238241
var setPackageInstallingStep = new SetPackageInstallingStep(settingsManager, InstallName);
239242

240243
var installLocation = Path.Combine(settingsManager.LibraryDir, "Packages", InstallName);
244+
if (Directory.Exists(installLocation))
245+
{
246+
var installPath = new DirectoryPath(installLocation);
247+
await installPath.DeleteVerboseAsync(logger);
248+
}
249+
241250
var prereqStep = new SetupPrerequisitesStep(prerequisiteHelper, pyRunner);
242251

243252
var downloadOptions = new DownloadPackageVersionOptions();
@@ -313,7 +322,6 @@ private Task ActuallyInstall()
313322
};
314323

315324
Steps = steps;
316-
return Task.CompletedTask;
317325
}
318326

319327
public void Cancel()
@@ -401,7 +409,7 @@ partial void OnSelectedVersionTypeChanged(PackageVersionType value)
401409
Dispatcher.UIThread
402410
.InvokeAsync(async () =>
403411
{
404-
Logger.Debug($"Release mode: {IsReleaseMode}");
412+
logger.LogDebug($"Release mode: {IsReleaseMode}");
405413
var versionOptions = await SelectedPackage.GetAllVersionOptions();
406414

407415
AvailableVersions = IsReleaseMode
@@ -413,7 +421,7 @@ partial void OnSelectedVersionTypeChanged(PackageVersionType value)
413421
return;
414422

415423
ReleaseNotes = SelectedVersion.ReleaseNotesMarkdown;
416-
Logger.Debug($"Loaded release notes for {ReleaseNotes}");
424+
logger.LogDebug($"Loaded release notes for {ReleaseNotes}");
417425

418426
if (!IsReleaseMode)
419427
{
@@ -492,7 +500,7 @@ partial void OnSelectedVersionChanged(PackageVersion? value)
492500
}
493501
catch (Exception e)
494502
{
495-
Logger.Warn($"Error getting commits: {e.Message}");
503+
logger.LogWarning(e, $"Error getting commits: {e.Message}");
496504
}
497505
})
498506
.SafeFireAndForget();

StabilityMatrix.Avalonia/ViewModels/Dialogs/OneClickInstallViewModel.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@
77
using CommunityToolkit.Mvvm.ComponentModel;
88
using CommunityToolkit.Mvvm.Input;
99
using Microsoft.Extensions.Logging;
10+
using StabilityMatrix.Avalonia.Extensions;
1011
using StabilityMatrix.Avalonia.Languages;
1112
using StabilityMatrix.Avalonia.Services;
1213
using StabilityMatrix.Avalonia.ViewModels.Base;
1314
using StabilityMatrix.Core.Attributes;
1415
using StabilityMatrix.Core.Helper;
1516
using StabilityMatrix.Core.Helper.Factory;
1617
using StabilityMatrix.Core.Models;
18+
using StabilityMatrix.Core.Models.FileInterfaces;
1719
using StabilityMatrix.Core.Models.PackageModification;
1820
using StabilityMatrix.Core.Models.Packages;
1921
using StabilityMatrix.Core.Python;
@@ -139,6 +141,11 @@ private async Task DoInstall()
139141
"Packages",
140142
SelectedPackage.Name
141143
);
144+
if (Directory.Exists(installLocation))
145+
{
146+
var installPath = new DirectoryPath(installLocation);
147+
await installPath.DeleteVerboseAsync(logger);
148+
}
142149

143150
var downloadVersion = await SelectedPackage.GetLatestVersion();
144151
var installedVersion = new InstalledPackageVersion { IsPrerelease = false };

StabilityMatrix.Core/Models/Packages/BaseGitPackage.cs

Lines changed: 14 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -181,36 +181,20 @@ public override async Task DownloadPackage(
181181
IProgress<ProgressReport>? progress = null
182182
)
183183
{
184-
if (!string.IsNullOrWhiteSpace(versionOptions.VersionTag))
185-
{
186-
await PrerequisiteHelper
187-
.RunGit(
188-
new[]
189-
{
190-
"clone",
191-
"--branch",
192-
versionOptions.VersionTag,
193-
GithubUrl,
194-
installLocation
195-
}
196-
)
197-
.ConfigureAwait(false);
198-
}
199-
else if (!string.IsNullOrWhiteSpace(versionOptions.BranchName))
200-
{
201-
await PrerequisiteHelper
202-
.RunGit(
203-
new[]
204-
{
205-
"clone",
206-
"--branch",
207-
versionOptions.BranchName,
208-
GithubUrl,
209-
installLocation
210-
}
211-
)
212-
.ConfigureAwait(false);
213-
}
184+
await PrerequisiteHelper
185+
.RunGit(
186+
new[]
187+
{
188+
"clone",
189+
"--branch",
190+
!string.IsNullOrWhiteSpace(versionOptions.VersionTag)
191+
? versionOptions.VersionTag
192+
: versionOptions.BranchName ?? MainBranch,
193+
GithubUrl,
194+
installLocation
195+
}
196+
)
197+
.ConfigureAwait(false);
214198

215199
if (!versionOptions.IsLatest && !string.IsNullOrWhiteSpace(versionOptions.CommitHash))
216200
{

0 commit comments

Comments
 (0)