Browse Source

Fix vlad & update regex in A3WebUI

pull/5/head
JT 1 year ago
parent
commit
c22b3ac5b7
  1. 3
      StabilityMatrix/Models/Packages/A3WebUI.cs
  2. 3
      StabilityMatrix/Models/Packages/ComfyUI.cs
  3. 44
      StabilityMatrix/Models/Packages/VladAutomatic.cs

3
StabilityMatrix/Models/Packages/A3WebUI.cs

@ -152,8 +152,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)
{

3
StabilityMatrix/Models/Packages/ComfyUI.cs

@ -109,8 +109,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)
{

44
StabilityMatrix/Models/Packages/VladAutomatic.cs

@ -3,7 +3,9 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Octokit;
using StabilityMatrix.Helper;
using StabilityMatrix.Helper.Cache;
using StabilityMatrix.Services;
@ -75,7 +77,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 +93,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 +123,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");

Loading…
Cancel
Save