Skip to content

Commit

Permalink
Merge pull request LykosAI#356 from ionite34/downmerge
Browse files Browse the repository at this point in the history
Downmerge
  • Loading branch information
mohnjiles authored Nov 20, 2023
2 parents b641a77 + c48abc0 commit 6671969
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 43 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ and this project adheres to [Semantic Versioning 2.0](https://semver.org/spec/v2
- Better error reporting including outputs for git subprocess errors during package install / update
- Fixed `'accelerate' is not recognized as an internal or external command` error when starting training in kohya_ss
- Fixed some instances of `ModuleNotFoundError: No module named 'bitsandbytes.cuda_setup.paths'` error when using 8-bit optimizers in kohya_ss
- Fixed errors preventing Inference outputs from loading in the img2img tabs of other packages

## v2.6.1
### Changed
Expand Down
2 changes: 1 addition & 1 deletion StabilityMatrix.Avalonia/Helpers/PngDataHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ private static byte[] BuildTextChunk(string key, string value)
var dataBytes = Encoding.UTF8.GetBytes(textData);
var textDataLength = BitConverter.GetBytes(dataBytes.Length).Reverse();
var textDataBytes = Text.Concat(dataBytes).ToArray();
var crc = BitConverter.GetBytes(Crc32Algorithm.Compute(textDataBytes));
var crc = BitConverter.GetBytes(Crc32Algorithm.Compute(textDataBytes)).Reverse();

return textDataLength.Concat(textDataBytes).Concat(crc).ToArray();
}
Expand Down
32 changes: 20 additions & 12 deletions StabilityMatrix.Avalonia/ViewModels/Dialogs/InstallerViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using FluentAvalonia.UI.Controls;
using NLog;
using Microsoft.Extensions.Logging;
using StabilityMatrix.Avalonia.Controls;
using StabilityMatrix.Avalonia.Extensions;
using StabilityMatrix.Avalonia.Languages;
using StabilityMatrix.Avalonia.Services;
using StabilityMatrix.Avalonia.ViewModels.Base;
Expand All @@ -24,6 +25,7 @@
using StabilityMatrix.Core.Helper.Factory;
using StabilityMatrix.Core.Models;
using StabilityMatrix.Core.Models.Database;
using StabilityMatrix.Core.Models.FileInterfaces;
using StabilityMatrix.Core.Models.PackageModification;
using StabilityMatrix.Core.Models.Packages;
using StabilityMatrix.Core.Processes;
Expand All @@ -36,14 +38,13 @@ namespace StabilityMatrix.Avalonia.ViewModels.Dialogs;
[Transient]
public partial class InstallerViewModel : ContentDialogViewModelBase
{
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();

private readonly ISettingsManager settingsManager;
private readonly IPackageFactory packageFactory;
private readonly IPyRunner pyRunner;
private readonly IDownloadService downloadService;
private readonly INotificationService notificationService;
private readonly IPrerequisiteHelper prerequisiteHelper;
private readonly ILogger<InstallerViewModel> logger;

[ObservableProperty]
private BasePackage selectedPackage;
Expand Down Expand Up @@ -130,7 +131,8 @@ public InstallerViewModel(
IPyRunner pyRunner,
IDownloadService downloadService,
INotificationService notificationService,
IPrerequisiteHelper prerequisiteHelper
IPrerequisiteHelper prerequisiteHelper,
ILogger<InstallerViewModel> logger
)
{
this.settingsManager = settingsManager;
Expand All @@ -139,6 +141,7 @@ IPrerequisiteHelper prerequisiteHelper
this.downloadService = downloadService;
this.notificationService = notificationService;
this.prerequisiteHelper = prerequisiteHelper;
this.logger = logger;

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

Expand Down Expand Up @@ -187,7 +190,7 @@ public override async Task OnLoadedAsync()
}
catch (Exception e)
{
Logger.Warn("Error getting versions: {Exception}", e.ToString());
logger.LogWarning("Error getting versions: {Exception}", e.ToString());
}
finally
{
Expand All @@ -209,7 +212,7 @@ private async Task Install()
else
{
var ex = result.Exception!;
Logger.Error(ex, $"Error installing package: {ex}");
logger.LogError(ex, $"Error installing package: {ex}");

var dialog = new BetterContentDialog
{
Expand All @@ -221,7 +224,7 @@ private async Task Install()
}
}

private Task ActuallyInstall()
private async Task ActuallyInstall()
{
if (string.IsNullOrWhiteSpace(InstallName))
{
Expand All @@ -232,12 +235,18 @@ private Task ActuallyInstall()
NotificationType.Error
)
);
return Task.CompletedTask;
return;
}

var setPackageInstallingStep = new SetPackageInstallingStep(settingsManager, InstallName);

var installLocation = Path.Combine(settingsManager.LibraryDir, "Packages", InstallName);
if (Directory.Exists(installLocation))
{
var installPath = new DirectoryPath(installLocation);
await installPath.DeleteVerboseAsync(logger);
}

var prereqStep = new SetupPrerequisitesStep(prerequisiteHelper, pyRunner);

var downloadOptions = new DownloadPackageVersionOptions();
Expand Down Expand Up @@ -313,7 +322,6 @@ private Task ActuallyInstall()
};

Steps = steps;
return Task.CompletedTask;
}

public void Cancel()
Expand Down Expand Up @@ -401,7 +409,7 @@ partial void OnSelectedVersionTypeChanged(PackageVersionType value)
Dispatcher.UIThread
.InvokeAsync(async () =>
{
Logger.Debug($"Release mode: {IsReleaseMode}");
logger.LogDebug($"Release mode: {IsReleaseMode}");
var versionOptions = await SelectedPackage.GetAllVersionOptions();

AvailableVersions = IsReleaseMode
Expand All @@ -413,7 +421,7 @@ partial void OnSelectedVersionTypeChanged(PackageVersionType value)
return;

ReleaseNotes = SelectedVersion.ReleaseNotesMarkdown;
Logger.Debug($"Loaded release notes for {ReleaseNotes}");
logger.LogDebug($"Loaded release notes for {ReleaseNotes}");

if (!IsReleaseMode)
{
Expand Down Expand Up @@ -492,7 +500,7 @@ partial void OnSelectedVersionChanged(PackageVersion? value)
}
catch (Exception e)
{
Logger.Warn($"Error getting commits: {e.Message}");
logger.LogWarning(e, $"Error getting commits: {e.Message}");
}
})
.SafeFireAndForget();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using Microsoft.Extensions.Logging;
using StabilityMatrix.Avalonia.Extensions;
using StabilityMatrix.Avalonia.Languages;
using StabilityMatrix.Avalonia.Services;
using StabilityMatrix.Avalonia.ViewModels.Base;
using StabilityMatrix.Core.Attributes;
using StabilityMatrix.Core.Helper;
using StabilityMatrix.Core.Helper.Factory;
using StabilityMatrix.Core.Models;
using StabilityMatrix.Core.Models.FileInterfaces;
using StabilityMatrix.Core.Models.PackageModification;
using StabilityMatrix.Core.Models.Packages;
using StabilityMatrix.Core.Python;
Expand Down Expand Up @@ -139,6 +141,11 @@ private async Task DoInstall()
"Packages",
SelectedPackage.Name
);
if (Directory.Exists(installLocation))
{
var installPath = new DirectoryPath(installLocation);
await installPath.DeleteVerboseAsync(logger);
}

var downloadVersion = await SelectedPackage.GetLatestVersion();
var installedVersion = new InstalledPackageVersion { IsPrerelease = false };
Expand Down
44 changes: 14 additions & 30 deletions StabilityMatrix.Core/Models/Packages/BaseGitPackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,36 +181,20 @@ public override async Task DownloadPackage(
IProgress<ProgressReport>? progress = null
)
{
if (!string.IsNullOrWhiteSpace(versionOptions.VersionTag))
{
await PrerequisiteHelper
.RunGit(
new[]
{
"clone",
"--branch",
versionOptions.VersionTag,
GithubUrl,
installLocation
}
)
.ConfigureAwait(false);
}
else if (!string.IsNullOrWhiteSpace(versionOptions.BranchName))
{
await PrerequisiteHelper
.RunGit(
new[]
{
"clone",
"--branch",
versionOptions.BranchName,
GithubUrl,
installLocation
}
)
.ConfigureAwait(false);
}
await PrerequisiteHelper
.RunGit(
new[]
{
"clone",
"--branch",
!string.IsNullOrWhiteSpace(versionOptions.VersionTag)
? versionOptions.VersionTag
: versionOptions.BranchName ?? MainBranch,
GithubUrl,
installLocation
}
)
.ConfigureAwait(false);

if (!versionOptions.IsLatest && !string.IsNullOrWhiteSpace(versionOptions.CommitHash))
{
Expand Down

0 comments on commit 6671969

Please sign in to comment.