fix: shorten guardrail benchmark result filenames for Windows long path support#22039
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Greptile SummaryThis PR fixes #21941 by shortening guardrail benchmark result filenames to avoid exceeding the Windows 260-character
Confidence Score: 4/5
|
| Filename | Overview |
|---|---|
| litellm/proxy/guardrails/guardrail_hooks/litellm_content_filter/guardrail_benchmarks/test_eval.py | Reworked _save_confusion_results to produce shorter filenames. Logic correctly handles all ContentFilter labels. Minor cosmetic issue: dots in model version numbers (e.g., "4.5") are silently stripped during sanitization, producing slightly misleading filenames for LLM judge results. |
| litellm/proxy/guardrails/guardrail_hooks/litellm_content_filter/guardrail_benchmarks/results/insults_cf.json | Renamed from long path with parentheses to short insults_cf.json. Contents unchanged — file content correctly preserved. |
| litellm/proxy/guardrails/guardrail_hooks/litellm_content_filter/guardrail_benchmarks/results/investment_cf.json | Renamed from long path with parentheses to short investment_cf.json. Contents unchanged — file content correctly preserved. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["_save_confusion_results(label)"] --> B["Split label on em dash (—)"]
B --> C["Extract topic: strip 'block ', lowercase, underscores"]
B --> D["Extract method_full from second part"]
D --> E["Parse method_name: remove parenthetical"]
D --> F["Parse qualifier: extract from parens, drop file extension"]
E --> G{method_name == 'contentfilter'?}
G -- Yes --> H["safe_label = {topic}_cf"]
G -- No --> I{qualifier present?}
I -- Yes --> J["safe_label = {topic}_{method}_{qualifier}"]
I -- No --> K["safe_label = {topic}_{method}"]
H --> L["Sanitize: replace spaces, remove invalid chars, collapse underscores"]
J --> L
K --> L
L --> M["Write {safe_label}.json to results/"]
Last reviewed commit: d3e2439
...lm/proxy/guardrails/guardrail_hooks/litellm_content_filter/guardrail_benchmarks/test_eval.py
Outdated
Show resolved
Hide resolved
Review1. Does this PR fix the issue it describes? 2. Has this issue already been solved elsewhere? 3. Are there other PRs addressing the same problem? 4. Are there other issues this potentially closes? ✅ LGTM — clean fix for Windows compatibility. |
…th support Fixes BerriAI#21941 The generated result filenames from _save_confusion_results contained parentheses, dots, and full yaml filenames, producing paths that exceed the Windows 260-char MAX_PATH limit. Rework the safe_label logic to produce short {topic}_{method_abbrev} filenames (e.g. insults_cf.json) while preserving the full label inside the JSON content. Rename existing tracked result files to match the new naming convention.
…r/guardrail_benchmarks/test_eval.py Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
1c5ff70 to
bcf9acf
Compare
Fixes #21941
The generated result filenames from save_confusion_results contained parentheses, dots, and full yaml filenames, producing paths that exceed the Windows 260-char
MAX_PATHlimit. Rework thesafe_labellogic to produce short{topic}_{method_abbrev}filenames (e.g. insults_cf.json) while preserving the full label inside the JSON content.Rename existing tracked result files to match the new naming convention.
Relevant issues
#21941
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
tests/litellm/directory, Adding at least 1 test is a hard requirement - see detailsmake test-unit@greptileaiand received a Confidence Score of at least 4/5 before requesting a maintainer reviewCI (LiteLLM team)
Branch creation CI run
Link:
CI run for the last commit
Link:
Merge / cherry-pick CI run
Links:
Type
🐛 Bug Fix
✅ Test
Changes