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"); var requirements = new FilePath(installLocation, "requirements_versions.txt");
await venvRunner await venvRunner
.PipInstallFromRequirements(requirements, onConsoleOutput) .PipInstallFromRequirements(requirements, onConsoleOutput, excludes: "torch")
.ConfigureAwait(false); .ConfigureAwait(false);
progress?.Report( progress?.Report(

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

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

14
StabilityMatrix.Core/Python/PyVenvRunner.cs

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

Loading…
Cancel
Save