Browse Source

Fix line splitting in PipInstallFromRequirements

pull/165/head
Ionite 1 year ago
parent
commit
c9065dbb62
No known key found for this signature in database
  1. 2
      StabilityMatrix.Core/Models/Packages/A3WebUI.cs
  2. 6
      StabilityMatrix.Core/Models/Packages/ComfyUI.cs
  3. 2
      StabilityMatrix.Core/Models/Packages/Fooocus.cs
  4. 2
      StabilityMatrix.Core/Models/Packages/FooocusMre.cs
  5. 14
      StabilityMatrix.Core/Python/PyVenvRunner.cs

2
StabilityMatrix.Core/Models/Packages/A3WebUI.cs

@ -201,7 +201,7 @@ public class A3WebUI : BaseGitPackage
var requirements = new FilePath(installLocation, "requirements_versions.txt");
await venvRunner
.PipInstallFromRequirements(requirements, onConsoleOutput)
.PipInstallFromRequirements(requirements, onConsoleOutput, excludes: "torch")
.ConfigureAwait(false);
progress?.Report(

6
StabilityMatrix.Core/Models/Packages/ComfyUI.cs

@ -186,11 +186,7 @@ public class ComfyUI : BaseGitPackage
var requirementsFile = new FilePath(installLocation, "requirements.txt");
await venvRunner
.PipInstallFromRequirements(
requirementsFile,
onConsoleOutput,
excludes: new[] { "torch" }
)
.PipInstallFromRequirements(requirementsFile, onConsoleOutput, excludes: "torch")
.ConfigureAwait(false);
progress?.Report(

2
StabilityMatrix.Core/Models/Packages/Fooocus.cs

@ -128,7 +128,7 @@ public class Fooocus : BaseGitPackage
var requirements = new FilePath(installLocation, "requirements_versions.txt");
await venvRunner
.PipInstallFromRequirements(requirements, onConsoleOutput)
.PipInstallFromRequirements(requirements, onConsoleOutput, excludes: "torch")
.ConfigureAwait(false);
}

2
StabilityMatrix.Core/Models/Packages/FooocusMre.cs

@ -132,7 +132,7 @@ public class FooocusMre : BaseGitPackage
var requirements = new FilePath(installLocation, "requirements_versions.txt");
await venvRunner
.PipInstallFromRequirements(requirements, onConsoleOutput)
.PipInstallFromRequirements(requirements, onConsoleOutput, excludes: "torch")
.ConfigureAwait(false);
}

14
StabilityMatrix.Core/Python/PyVenvRunner.cs

@ -1,6 +1,7 @@
using System.Collections.Immutable;
using System.Diagnostics.CodeAnalysis;
using System.Text;
using System.Text.RegularExpressions;
using NLog;
using Salaros.Configuration;
using StabilityMatrix.Core.Exceptions;
@ -15,7 +16,6 @@ namespace StabilityMatrix.Core.Python;
/// <summary>
/// Python runner using a subprocess, mainly for venv support.
/// </summary>
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
public class PyVenvRunner : IDisposable, IAsyncDisposable
{
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
@ -248,21 +248,19 @@ public class PyVenvRunner : IDisposable, IAsyncDisposable
public async Task PipInstallFromRequirements(
FilePath file,
Action<ProcessOutput>? outputDataReceived = null,
IEnumerable<string>? excludes = null
[StringSyntax(StringSyntaxAttribute.Regex)] string? excludes = null
)
{
var requirementsText = await file.ReadAllTextAsync().ConfigureAwait(false);
var requirements = requirementsText
.Split(Environment.NewLine)
.Where(s => !string.IsNullOrWhiteSpace(s));
.SplitLines(StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries)
.AsEnumerable();
if (excludes is not null)
{
var excludesFilter = excludes.ToImmutableHashSet(
StringComparer.InvariantCultureIgnoreCase
);
var excludeRegex = new Regex(excludes);
requirements = requirements.Where(s => !excludesFilter.Contains(s));
requirements = requirements.Where(s => !excludeRegex.IsMatch(s));
}
var pipArgs = string.Join(' ', requirements);

Loading…
Cancel
Save