Skip to content

Commit 3d2667f

Browse files
authored
Merge pull request LykosAI#1150 from ionite34/backport/main/pr-1149
[dev to main] backport: Fix uv python list output special characters causing install errors… (1149)
2 parents 749da3c + cfd6f2b commit 3d2667f

File tree

4 files changed

+32
-16
lines changed

4 files changed

+32
-16
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ and this project adheres to [Semantic Versioning 2.0](https://semver.org/spec/v2
1212
- Updated SageAttention installer to install v2.2.0-windows.post3
1313
- Updated Nunchaku installer to install v1.0.1
1414
### Fixed
15-
- Fixed [#1372](https://github.com/LykosAI/StabilityMatrix/issues/1372) - LiteAsyncException upon starting Stability Matrix v2.15.0
15+
- Fixed [#1372](https://github.com/LykosAI/StabilityMatrix/issues/1372), [#1399](https://github.com/LykosAI/StabilityMatrix/issues/1399) - LiteAsyncException upon starting Stability Matrix v2.15.0
1616
- Fixed [#1391](https://github.com/LykosAI/StabilityMatrix/issues/1391) - "Failed to parse" error when upgrading pip packages with extra index url
17+
- Fixed [#1401](https://github.com/LykosAI/StabilityMatrix/issues/1401) - "Python <version> was not found and/or failed to install" errors when path contains special characters
18+
- Fixed [#1403](https://github.com/LykosAI/StabilityMatrix/issues/1403) - Checkpoint Manager filters not being saved correctly
1719
- Fixed "cannot access local variable 'job' where it is not associated with a value" error when running jobs in AI Toolkit
1820
- Fixed Civitai browser not always returning at least 30 results when possible on initial search
1921

StabilityMatrix.Avalonia/ViewModels/CheckpointsPageViewModel.cs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -160,16 +160,14 @@ protected override async Task OnInitialLoadedAsync()
160160

161161
await base.OnInitialLoadedAsync();
162162

163-
var settingsSelectedBaseModels = settingsManager.Settings.SelectedBaseModels;
164-
165163
AddDisposable(
166164
BaseModelCache
167165
.Connect()
168166
.DeferUntilLoaded()
169167
.Transform(baseModel => new BaseModelOptionViewModel
170168
{
171169
ModelType = baseModel,
172-
IsSelected = settingsSelectedBaseModels.Contains(baseModel),
170+
IsSelected = settingsManager.Settings.SelectedBaseModels.Contains(baseModel),
173171
})
174172
.SortAndBind(
175173
BaseModelOptions,
@@ -179,10 +177,15 @@ protected override async Task OnInitialLoadedAsync()
179177
.ObserveOn(SynchronizationContext.Current)
180178
.Subscribe(next =>
181179
{
182-
if (next.Sender.IsSelected)
183-
SelectedBaseModels.Add(next.Sender.ModelType);
184-
else
185-
SelectedBaseModels.Remove(next.Sender.ModelType);
180+
switch (next.Sender.IsSelected)
181+
{
182+
case true when !SelectedBaseModels.Contains(next.Sender.ModelType):
183+
SelectedBaseModels.Add(next.Sender.ModelType);
184+
break;
185+
case false when SelectedBaseModels.Contains(next.Sender.ModelType):
186+
SelectedBaseModels.Remove(next.Sender.ModelType);
187+
break;
188+
}
186189

187190
OnPropertyChanged(nameof(ClearButtonText));
188191
OnPropertyChanged(nameof(SelectedBaseModels));
@@ -191,6 +194,7 @@ protected override async Task OnInitialLoadedAsync()
191194

192195
var settingsTransactionObservable = this.WhenPropertyChanged(x => x.SelectedBaseModels)
193196
.Throttle(TimeSpan.FromMilliseconds(50))
197+
.Skip(1)
194198
.ObserveOn(SynchronizationContext.Current)
195199
.Subscribe(_ =>
196200
{

StabilityMatrix.Core/Processes/ProcessRunner.cs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public static async Task<string> GetProcessOutputAsync(
166166
Arguments = arguments,
167167
UseShellExecute = false,
168168
RedirectStandardOutput = true,
169-
CreateNoWindow = true
169+
CreateNoWindow = true,
170170
};
171171

172172
if (environmentVariables != null)
@@ -196,7 +196,8 @@ public static async Task<ProcessResult> GetProcessResultAsync(
196196
string fileName,
197197
ProcessArgs arguments,
198198
string? workingDirectory = null,
199-
IReadOnlyDictionary<string, string>? environmentVariables = null
199+
IReadOnlyDictionary<string, string>? environmentVariables = null,
200+
bool useUtf8Encoding = false
200201
)
201202
{
202203
Logger.Debug($"Starting process '{fileName}' with arguments '{arguments}'");
@@ -208,9 +209,15 @@ public static async Task<ProcessResult> GetProcessResultAsync(
208209
UseShellExecute = false,
209210
RedirectStandardOutput = true,
210211
RedirectStandardError = true,
211-
CreateNoWindow = true
212+
CreateNoWindow = true,
212213
};
213214

215+
if (useUtf8Encoding)
216+
{
217+
info.StandardOutputEncoding = Encoding.UTF8;
218+
info.StandardErrorEncoding = Encoding.UTF8;
219+
}
220+
214221
if (environmentVariables != null)
215222
{
216223
foreach (var (key, value) in environmentVariables)
@@ -255,7 +262,7 @@ public static async Task<ProcessResult> GetProcessResultAsync(
255262
StandardOutput = stdout,
256263
StandardError = stderr,
257264
ProcessName = processName,
258-
Elapsed = elapsed
265+
Elapsed = elapsed,
259266
};
260267
}
261268

@@ -410,7 +417,7 @@ public static Process StartProcess(
410417
UseShellExecute = false,
411418
RedirectStandardOutput = true,
412419
RedirectStandardError = true,
413-
CreateNoWindow = true
420+
CreateNoWindow = true,
414421
};
415422

416423
if (environmentVariables != null)
@@ -458,7 +465,7 @@ public static AnsiProcess StartAnsiProcess(
458465
UseShellExecute = false,
459466
RedirectStandardOutput = true,
460467
RedirectStandardError = true,
461-
CreateNoWindow = true
468+
CreateNoWindow = true,
462469
};
463470

464471
if (environmentVariables != null)
@@ -544,7 +551,7 @@ public static async Task<ProcessResult> RunBashCommand(
544551
{
545552
ExitCode = process.ExitCode,
546553
StandardOutput = stdout.ToString(),
547-
StandardError = stderr.ToString()
554+
StandardError = stderr.ToString(),
548555
};
549556
}
550557

StabilityMatrix.Core/Python/UvManager.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
using System.Text.Encodings.Web;
12
using System.Text.Json;
23
using System.Text.Json.Serialization;
34
using System.Text.RegularExpressions;
5+
using System.Text.Unicode;
46
using Injectio.Attributes;
57
using NLog;
68
using StabilityMatrix.Core.Helper;
@@ -20,6 +22,7 @@ public partial class UvManager : IUvManager
2022
{
2123
Converters = { new JsonStringEnumConverter() },
2224
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
25+
Encoder = JavaScriptEncoder.Create(UnicodeRanges.All),
2326
};
2427
private string? uvExecutablePath;
2528
private DirectoryPath? uvPythonInstallPath;
@@ -120,7 +123,7 @@ public async Task<IReadOnlyList<UvPythonInfo>> ListAvailablePythonsAsync(
120123
var uvDirectory = Path.GetDirectoryName(uvExecutablePath);
121124

122125
var result = await ProcessRunner
123-
.GetProcessResultAsync(uvExecutablePath, args, uvDirectory, envVars)
126+
.GetProcessResultAsync(uvExecutablePath, args, uvDirectory, envVars, useUtf8Encoding: true)
124127
.ConfigureAwait(false);
125128

126129
if (!result.IsSuccessExitCode)

0 commit comments

Comments
 (0)