From db777eeb3c87f8d857720be37dd31780de3c5b6f Mon Sep 17 00:00:00 2001 From: JT Date: Mon, 15 Apr 2024 23:33:02 -0700 Subject: [PATCH] fix comment parsing & metadata parsing --- CHANGELOG.md | 5 +++++ StabilityMatrix.Core/Python/PipInstallArgs.cs | 2 +- .../Services/MetadataImportService.cs | 14 +++++++++++--- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a14178d4..baffe87a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,11 @@ All notable changes to Stability Matrix will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning 2.0](https://semver.org/spec/v2.0.0.html). +## v2.something +### Fixed +- Fixed more crashes when loading invalid connected model info files +- Fixed pip installs not parsing comments properly + ## v2.10.1 ### Added - Added SVD Shared Model & Output Folders for Forge (fixes [#580](https://github.com/LykosAI/StabilityMatrix/issues/580)) diff --git a/StabilityMatrix.Core/Python/PipInstallArgs.cs b/StabilityMatrix.Core/Python/PipInstallArgs.cs index 68e371f7..8c33f194 100644 --- a/StabilityMatrix.Core/Python/PipInstallArgs.cs +++ b/StabilityMatrix.Core/Python/PipInstallArgs.cs @@ -30,7 +30,7 @@ public record PipInstallArgs : ProcessArgsBuilder { var requirementsEntries = requirements .SplitLines(StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries) - .AsEnumerable(); + .Where(s => !s.StartsWith('#')); if (excludePattern is not null) { diff --git a/StabilityMatrix.Core/Services/MetadataImportService.cs b/StabilityMatrix.Core/Services/MetadataImportService.cs index 21ce5a2c..3830fa70 100644 --- a/StabilityMatrix.Core/Services/MetadataImportService.cs +++ b/StabilityMatrix.Core/Services/MetadataImportService.cs @@ -155,9 +155,17 @@ public class MetadataImportService( var cmInfoList = new Dictionary(); foreach (var cmInfoPath in directory.EnumerateFiles("*.cm-info.json", SearchOption.AllDirectories)) { - var cmInfo = JsonSerializer.Deserialize( - await cmInfoPath.ReadAllTextAsync().ConfigureAwait(false) - ); + ConnectedModelInfo? cmInfo; + try + { + cmInfo = JsonSerializer.Deserialize( + await cmInfoPath.ReadAllTextAsync().ConfigureAwait(false) + ); + } + catch (JsonException) + { + cmInfo = null; + } if (cmInfo == null) continue;