Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/workflows/install_from_hub.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Notebook Execution and Error Check

on:
push:
branches:
- main
workflow_dispatch: # This enables manual triggering

jobs:
install_from_hub:
runs-on: ubuntu-latest
steps:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.11.x
- name: pip install from main
run: pip install git+https://github.com/guardrails-ai/guardrails.git@main
- name: Install PII validator
run: guardrails hub install hub://guardrails/detect_pii
- name: Verify PII validator is addressable
run: echo 'from guardrails.hub import DetectPII' | python
7 changes: 7 additions & 0 deletions guardrails/cli/hub/install.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import json
import os
import subprocess
import sys
Expand Down Expand Up @@ -44,6 +45,12 @@ def pip_process(
logger.debug(f"decoding output from pip {action} {package}")
if format == json_format:
parsed = BytesHeaderParser().parsebytes(output)
try:
return json.loads(str(parsed))
except Exception:
logger.debug(
f"json parse exception in decoding output from pip {action} {package}. Falling back to accumulating the byte stream", # noqa
)
accumulator = {}
for key, value in parsed.items():
accumulator[key] = value
Expand Down
5 changes: 4 additions & 1 deletion tests/unit_tests/cli/hub/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,13 @@ def parsebytes(self, *args):

response = pip_process("show", "pip", format="json")

assert mock_logger_debug.call_count == 2
assert mock_logger_debug.call_count == 3
debug_calls = [
call("running pip show pip"),
call("decoding output from pip show pip"),
call(
"json parse exception in decoding output from pip show pip. Falling back to accumulating the byte stream" # noqa
),
]
mock_logger_debug.assert_has_calls(debug_calls)

Expand Down