Browse Source

Merge pull request #83 from ionite34/fix-vlad

Fix vlad & update regex in A3WebUI
pull/5/head
Ionite 1 year ago committed by GitHub
parent
commit
fd0c5e36e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      StabilityMatrix/Models/CheckpointFile.cs
  2. 1
      StabilityMatrix/Models/ConnectedModelInfo.cs
  3. 4
      StabilityMatrix/Models/Packages/A3WebUI.cs
  4. 4
      StabilityMatrix/Models/Packages/ComfyUI.cs
  5. 43
      StabilityMatrix/Models/Packages/VladAutomatic.cs
  6. 1
      StabilityMatrix/ViewModels/CheckpointBrowserViewModel.cs

1
StabilityMatrix/Models/CheckpointFile.cs

@ -10,7 +10,6 @@ using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using NLog;
using StabilityMatrix.Extensions;
using StabilityMatrix.Models.Api;
namespace StabilityMatrix.Models;

1
StabilityMatrix/Models/ConnectedModelInfo.cs

@ -3,7 +3,6 @@ using System.IO;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
using StabilityMatrix.Extensions;
using StabilityMatrix.Models.Api;
namespace StabilityMatrix.Models;

4
StabilityMatrix/Models/Packages/A3WebUI.cs

@ -7,7 +7,6 @@ using System.Text.RegularExpressions;
using System.Threading.Tasks;
using StabilityMatrix.Helper;
using StabilityMatrix.Helper.Cache;
using StabilityMatrix.Python;
using StabilityMatrix.Services;
namespace StabilityMatrix.Models.Packages;
@ -152,8 +151,7 @@ public class A3WebUI : BaseGitPackage
if (s.Contains("Running on", StringComparison.OrdinalIgnoreCase))
{
var regex = new Regex(
"(?:https?|ftp)://[-a-zA-Z0-9.]+(:(6553[0-5]|655[0-2][0-9]|65[0-4][0-9][0-9]|6[0-4][0-9][0-9][0-9]|\\d{2,4}|[1-9]))?");
var regex = new Regex(@"(https?:\/\/)([^:\s]+):(\d+)");
var match = regex.Match(s);
if (match.Success)
{

4
StabilityMatrix/Models/Packages/ComfyUI.cs

@ -8,7 +8,6 @@ using System.Threading.Tasks;
using NLog;
using StabilityMatrix.Helper;
using StabilityMatrix.Helper.Cache;
using StabilityMatrix.Python;
using StabilityMatrix.Services;
namespace StabilityMatrix.Models.Packages;
@ -109,8 +108,7 @@ public class ComfyUI : BaseGitPackage
if (s.Contains("To see the GUI go to", StringComparison.OrdinalIgnoreCase))
{
var regex = new Regex(
@"(https?:\/\/)([^:\s]+):(\d+)");
var regex = new Regex(@"(https?:\/\/)([^:\s]+):(\d+)");
var match = regex.Match(s);
if (match.Success)
{

43
StabilityMatrix/Models/Packages/VladAutomatic.cs

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using StabilityMatrix.Helper;
using StabilityMatrix.Helper.Cache;
@ -75,7 +76,7 @@ public class VladAutomatic : BaseGitPackage
LaunchOptionDefinition.Extras
};
public override string ExtraLaunchArguments => "--skip-git";
public override string ExtraLaunchArguments => "";
public override Task<string> GetLatestVersion() => Task.FromResult("master");
@ -91,17 +92,29 @@ public class VladAutomatic : BaseGitPackage
public override async Task InstallPackage(IProgress<ProgressReport>? progress = null)
{
await UnzipPackage(progress);
var gitInitProcess =
ProcessRunner.StartProcess(Path.Combine(Helper.PrerequisiteHelper.GitBinPath, "git.exe"), "init",
InstallLocation);
await gitInitProcess.WaitForExitAsync();
await PrerequisiteHelper.SetupPythonDependencies(InstallLocation, "requirements.txt", progress,
OnConsoleOutput);
}
public override async Task<string?> DownloadPackage(string version, bool isCommitHash, IProgress<ProgressReport>? progress = null)
{
progress?.Report(new ProgressReport(0.1f, message: "Downloading package...", isIndeterminate: true, type: ProgressType.Download));
Directory.CreateDirectory(InstallLocation);
var gitCloneProcess =
ProcessRunner.StartProcess(Path.Combine(Helper.PrerequisiteHelper.GitBinPath, "git.exe"),
"clone https://github.com/vladmandic/automatic.git .", InstallLocation);
await gitCloneProcess.WaitForExitAsync();
var gitCheckoutProcess =
ProcessRunner.StartProcess(Path.Combine(Helper.PrerequisiteHelper.GitBinPath, "git.exe"),
$"checkout {version}", InstallLocation);
await gitCheckoutProcess.WaitForExitAsync();
return version;
}
public override async Task RunPackage(string installedPackagePath, string arguments)
{
await SetupVenv(installedPackagePath);
@ -109,13 +122,15 @@ public class VladAutomatic : BaseGitPackage
void HandleConsoleOutput(string? s)
{
if (s == null) return;
if (s.Contains("model loaded", StringComparison.OrdinalIgnoreCase))
{
OnStartupComplete(WebUrl);
}
if (s.Contains("Running on", StringComparison.OrdinalIgnoreCase))
if (s.Contains("Running on local URL", StringComparison.OrdinalIgnoreCase))
{
WebUrl = s.Split(" ")[5];
var regex = new Regex(@"(https?:\/\/)([^:\s]+):(\d+)");
var match = regex.Match(s);
if (match.Success)
{
WebUrl = match.Value;
OnStartupComplete(WebUrl);
}
}
Debug.WriteLine($"process stdout: {s}");
OnConsoleOutput($"{s}\n");

1
StabilityMatrix/ViewModels/CheckpointBrowserViewModel.cs

@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
using AsyncAwaitBestPractices;
using CommunityToolkit.Mvvm.ComponentModel;

Loading…
Cancel
Save