Skip to content

Commit

Permalink
Merge pull request #432 from ionite34/fix-pip-list-parse
Browse files Browse the repository at this point in the history
Filter warnings in pip show parse
  • Loading branch information
ionite34 authored Dec 28, 2023
2 parents 38b14c9 + c076b67 commit 56ca83d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ and this project adheres to [Semantic Versioning 2.0](https://semver.org/spec/v2
### Changed
- ControlNet model selector will now show the parent directory of a model when relevant
### Fixed
- Fixed Python Packages dialog crash
- Fixed Python Packages dialog crash due to pip commands including warnings
- Fixed Base Model downloads from the Hugging Face tab downloading to the wrong folder

## v2.7.5
Expand Down
8 changes: 5 additions & 3 deletions StabilityMatrix.Core/Python/PipShowResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ public static PipShowResult Parse(string output)
// Decode each line by splitting on first ":" to key and value
var lines = output
.SplitLines(StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries)
.Select(line => line.Split(new[] { ':' }, 2))
// Filter warning lines
.Where(line => !line.StartsWith("WARNING", StringComparison.OrdinalIgnoreCase))
.Select(line => line.Split(':', 2))
.Where(split => split.Length == 2)
.Select(split => new KeyValuePair<string, string>(split[0].Trim(), split[1].Trim()))
.ToDictionary(pair => pair.Key, pair => pair.Value);
Expand All @@ -46,11 +48,11 @@ public static PipShowResult Parse(string output)
Location = lines.GetValueOrDefault("Location"),
Requires = lines
.GetValueOrDefault("Requires")
?.Split(new[] { ',' }, StringSplitOptions.TrimEntries)
?.Split(',', StringSplitOptions.TrimEntries)
.ToList(),
RequiredBy = lines
.GetValueOrDefault("Required-by")
?.Split(new[] { ',' }, StringSplitOptions.TrimEntries)
?.Split(',', StringSplitOptions.TrimEntries)
.ToList()
};
}
Expand Down

0 comments on commit 56ca83d

Please sign in to comment.