File tree Expand file tree Collapse file tree 3 files changed +33
-1
lines changed Expand file tree Collapse file tree 3 files changed +33
-1
lines changed Original file line number Diff line number Diff line change 1+ name : Notebook Execution and Error Check
2+
3+ on :
4+ push :
5+ branches :
6+ - main
7+ workflow_dispatch : # This enables manual triggering
8+
9+ jobs :
10+ install_from_hub :
11+ runs-on : ubuntu-latest
12+ steps :
13+ - name : Set up Python
14+ uses : actions/setup-python@v5
15+ with :
16+ python-version : 3.11.x
17+ - name : pip install from main
18+ run : pip install git+https://github.com/guardrails-ai/guardrails.git@main
19+ - name : Install PII validator
20+ run : guardrails hub install hub://guardrails/detect_pii
21+ - name : Verify PII validator is addressable
22+ run : echo 'from guardrails.hub import DetectPII' | python
Original file line number Diff line number Diff line change 1+ import json
12import os
23import subprocess
34import sys
@@ -44,6 +45,12 @@ def pip_process(
4445 logger .debug (f"decoding output from pip { action } { package } " )
4546 if format == json_format :
4647 parsed = BytesHeaderParser ().parsebytes (output )
48+ try :
49+ return json .loads (str (parsed ))
50+ except Exception :
51+ logger .debug (
52+ f"json parse exception in decoding output from pip { action } { package } . Falling back to accumulating the byte stream" , # noqa
53+ )
4754 accumulator = {}
4855 for key , value in parsed .items ():
4956 accumulator [key ] = value
Original file line number Diff line number Diff line change @@ -134,10 +134,13 @@ def parsebytes(self, *args):
134134
135135 response = pip_process ("show" , "pip" , format = "json" )
136136
137- assert mock_logger_debug .call_count == 2
137+ assert mock_logger_debug .call_count == 3
138138 debug_calls = [
139139 call ("running pip show pip" ),
140140 call ("decoding output from pip show pip" ),
141+ call (
142+ "json parse exception in decoding output from pip show pip. Falling back to accumulating the byte stream" # noqa
143+ ),
141144 ]
142145 mock_logger_debug .assert_has_calls (debug_calls )
143146
You can’t perform that action at this time.
0 commit comments