Skip to content

Commit 724c7f0

Browse files
authored
Merge pull request #1317 from guardrails-ai/0.6.7-pre-release-2
v0.6.7 Prerelease II
2 parents e478f57 + aa978c7 commit 724c7f0

File tree

18 files changed

+527
-1258
lines changed

18 files changed

+527
-1258
lines changed

.github/workflows/ci.yml

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,18 @@ jobs:
3737
# Setup Virtual Environment
3838
python3 -m venv ./.venv
3939
source .venv/bin/activate
40-
poetry install --extras dev
40+
41+
if [ "${{ matrix.python-version }}" == "3.9" ];
42+
then
43+
pip install .[dev]
44+
else
45+
poetry install --extras dev
46+
fi
4147
4248
- name: Check license
4349
run: |
4450
source .venv/bin/activate
45-
.venv/bin/pip install greenlet
51+
.venv/bin/pip install greenlet setuptools
4652
.venv/bin/liccheck
4753
Linting:
4854
runs-on: ubuntu-latest
@@ -60,12 +66,16 @@ jobs:
6066
uses: snok/install-poetry@v1
6167

6268
- name: Install Dependencies
63-
# TODO: fix errors so that we can run `make dev` instead
6469
run: |
6570
# Setup Virtual Environment
6671
python3 -m venv ./.venv
6772
source .venv/bin/activate
68-
make full
73+
if [ "${{ matrix.python-version }}" == "3.9" ];
74+
then
75+
pip install .[dev]
76+
else
77+
make dev
78+
fi
6979
7080
- name: Lint with ruff
7181
run: |
@@ -88,12 +98,16 @@ jobs:
8898
uses: snok/install-poetry@v1
8999

90100
- name: Install Dependencies
91-
# TODO: fix errors so that we can run `make dev` instead
92101
run: |
93102
# Setup Virtual Environment
94103
python3 -m venv ./.venv
95104
source .venv/bin/activate
96-
make full
105+
if [ "${{ matrix.python-version }}" == "3.9" ];
106+
then
107+
pip install .[dev,sql,vectordb,manifest,anthropic,huggingface,api,databricks,uv,llama]
108+
else
109+
make full
110+
fi
97111
98112
- name: Static analysis with pyright
99113
run: |
@@ -130,7 +144,13 @@ jobs:
130144
python3 -m venv ./.venv
131145
source .venv/bin/activate
132146
133-
make full
147+
if [ "${{ matrix.python-version }}" == "3.9" ];
148+
then
149+
pip install .[dev,sql,vectordb,manifest,anthropic,huggingface,api,databricks,uv,llama]
150+
else
151+
make full
152+
fi
153+
134154
if [ "${{ matrix.python-version }}" == "3.12" ]; then
135155
echo "Installing latest langchain-core and langsmith from PyPI"
136156
pip install "langchain-core>=0.2" "langsmith<0.2.0,>=0.1.75"

.github/workflows/server_ci.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@ on:
99
jobs:
1010
build-test-server:
1111
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
tag: ["fastapi", "flask"]
1215
steps:
1316
- name: Check out head
14-
uses: actions/checkout@v3
17+
uses: actions/checkout@v5
1518
with:
1619
persist-credentials: false
1720

@@ -29,17 +32,17 @@ jobs:
2932
uses: docker/build-push-action@v6
3033
with:
3134
context: .
32-
file: server_ci/Dockerfile
35+
file: server_ci/Dockerfile.${{ matrix.tag }}
3336
platforms: linux/amd64
3437
push: false
35-
tags: guardrails:${{ github.sha }}
38+
tags: guardrails:${{ matrix.tag }}
3639
load: true
3740
build-args: |
3841
GUARDRAILS_TOKEN=${{ secrets.GUARDRAILS_API_KEY }}
3942
4043
- name: Start Docker container
4144
run: |
42-
docker run -d --name guardrails-container -p 8000:8000 -e OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }} guardrails:${{ github.sha }}
45+
docker run -d --name guardrails-container -p 8000:8000 -e OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }} guardrails:${{ matrix.tag }}
4346
4447
- name: Wait for Docker container to be ready
4548
run: |
@@ -54,7 +57,7 @@ jobs:
5457
5558
- name: Run Pytest
5659
run: |
57-
pip install pytest openai guardrails-ai
60+
pip install pytest pytest-asyncio openai guardrails-ai
5861
pytest server_ci/tests
5962
docker stop guardrails-container
6063
docker rm guardrails-container

Makefile

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
11
MKDOCS_SERVE_ADDR ?= localhost:8000 # Default address for mkdocs serve, format: <host>:<port>, override with `make docs-serve MKDOCS_SERVE_ADDR=<host>:<port>`
22

33
autoformat:
4-
poetry run ruff check guardrails/ tests/ --fix
5-
poetry run ruff format guardrails/ tests/
6-
poetry run docformatter --in-place --recursive guardrails tests
4+
ruff check guardrails/ tests/ --fix
5+
ruff format guardrails/ tests/
6+
docformatter --in-place --recursive guardrails tests
77

88
.PHONY: type
99
type:
10-
poetry run pyright guardrails/
10+
pyright guardrails/
1111

1212
lint:
13-
poetry run ruff check guardrails/ tests/
14-
poetry run ruff format guardrails/ tests/ --check
13+
ruff check guardrails/ tests/
14+
ruff format guardrails/ tests/ --check
1515

1616
test:
17-
poetry run pytest tests/
17+
pytest tests/
1818

1919
test-basic:
2020
set -e
2121
python -c "import guardrails as gd"
2222
python -c "import guardrails.version as mversion"
2323

2424
test-cov:
25-
poetry run pytest tests/ --cov=./guardrails/ --cov-report=xml
25+
pytest tests/ --cov=./guardrails/ --cov-report=xml
2626

2727
view-test-cov:
28-
poetry run pytest tests/ --cov=./guardrails/ --cov-report html && open htmlcov/index.html
28+
pytest tests/ --cov=./guardrails/ --cov-report html && open htmlcov/index.html
2929

3030
view-test-cov-file:
31-
poetry run pytest tests/unit_tests/test_logger.py --cov=./guardrails/ --cov-report html && open htmlcov/index.html
31+
pytest tests/unit_tests/test_logger.py --cov=./guardrails/ --cov-report html && open htmlcov/index.html
3232

3333
docs-serve:
3434
poetry run mkdocs serve -a $(MKDOCS_SERVE_ADDR)
@@ -37,7 +37,7 @@ docs-deploy:
3737
poetry run mkdocs gh-deploy
3838

3939
dev:
40-
poetry install
40+
poetry install --extras "dev"
4141
poetry run pre-commit install
4242

4343
full:

guardrails/api_client.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import json
22
import os
3+
import sys
34
from typing import Any, Iterator, Optional
45

56
import requests
@@ -37,8 +38,15 @@ def __init__(self, base_url: Optional[str] = None, api_key: Optional[str] = None
3738
api_key if api_key is not None else os.environ.get("GUARDRAILS_API_KEY", "")
3839
)
3940
self.timeout = 300
41+
42+
_api_key = (
43+
self.api_key
44+
if sys.version_info.minor < 10
45+
else {"ApiKeyAuth": self.api_key}
46+
)
47+
4048
self._api_client = ApiClient(
41-
configuration=Configuration(api_key=self.api_key, host=self.base_url)
49+
configuration=Configuration(api_key=_api_key, host=self.base_url) # type: ignore
4250
)
4351
self._guard_api = GuardApi(self._api_client)
4452
self._validate_api = ValidateApi(self._api_client)

0 commit comments

Comments
 (0)