Skip to content

Commit

Permalink
parent bcc4bb3
Browse files Browse the repository at this point in the history
author zsimjee <[email protected]> 1699036706 -0700
committer Caleb Courier <[email protected]> 1700668933 -0600

Setup passed password (guardrails-ai#429)

* use pypi pass from env

* upgrade pip before installing deps

* pass pypi pass explicitly

* use environ competently

Cron nb (guardrails-ai#425)

* install deps + pkg for nb runs

* lock nb runner to 3.11.x

* use cohere api key from environ

* ref env vars for cohere + openai

fix bad merge in code originally from validators.py (guardrails-ai#427)

* fix bad merge in code originally from validators.py

* lint fixes

bump version (guardrails-ai#428)

Setup passed password (guardrails-ai#429)

* use pypi pass from env

* upgrade pip before installing deps

* pass pypi pass explicitly

* use environ competently

list -> List

Lock openai version (guardrails-ai#435)

* temporarily lock openai version

* bump version to be ready for release

Poetry for dependency management (guardrails-ai#436)

* Replace setup.py/requirements.txt/version.py with pyproject.toml/poetry.lock

* add dateutil to core dependencies

* convert dependency groups to extras

* Makefile/CI: Change to poetry

* poetry run

* replace make dev with make full

* poetry: include guardrails console script

* release_version: Set pypi token in poetry

pyproject.toml: version 0.2.7 => 0.2.8

from_element => from_xml

rail: load_schema => load_schema_from_xml

pydantic_utils.attach_validators_to_element: Fix typehint

Pass validator arguments through for string guard

Remove XML from pydantic guard instantiation

python_rail.compiled_prompt_1: Fix test (wrongly not annotated as optional)

Remove conversion-to-XML code

Move integration test to where it belongs

schema: Remove commented out method

load_string_schema_from_pydantic -> load_json_schema_from_pydantic

datatypes: Fix datatype deprecation

Remove deprecated datatypes from pydantic

test_run: Fix `from_element` => `from_xml` call

datatypes: Raise deprecation warning on datatype init

Move pydantic_utils to split package

logs_utils: Move ArbitraryModel to pydantic_utils

Move DataType.from_pydantic_field to pydantic_utils

add --build option to poetry build

release_version: specify token differently

fix project name (guardrails => guardrails-ai)

Fix reask prompt/instructions (guardrails-ai#432)

* schema: Always use reask prompt/instructions setter

* guard/run: Remove reask prompt/instructions plumbing

* guard: Allow passing reask prompt/instructions to pydantic constructor

* guard: Link reask prompt/instructions properties to schema

* format

index similarToList notebook (guardrails-ai#426)

Fix custom onfail handler (guardrails-ai#421)

* formatattr: Pass through custom on_fail methods

* validator_service: Pass all FailResults to custom fail handler instead of only first

* test_validators: Add custom on_fail handler test

Init pydantic_utils v2

Adjust tests for pydantic2

pydantic: Allow Dict/List field types (fix guardrails-ai#319)

test_validators: Fix SimilarToList validator test

CI: handle pydantic v1 and v2 separately

list => List

parsing_utils: Type ignore

pydantic_utils/v2: safe BareModel

fix Makefile for poetry

fix ci cache for pydantic versions

lint and test fixes

autoformat

Create PII Filter validator (guardrails-ai#395)

* Add PII filter: v0

* Update PII filter

* Update class docstring, add more entities to filter, bugfix and update some comments

* Move logic to helper function, update DEV_REQUIREMENTS, add integration tests

* Fix linting

* Write code according to Python 3.9

* Add mocks for AnalyzerEngine and AnonymizerEngine

* Change | to Union

* Add notebook example demo for PIIFilter

* Add package imports

* Init pydantic_utils v2

* Adjust tests for pydantic2

* pydantic: Allow Dict/List field types (fix guardrails-ai#319)

* test_validators: Fix SimilarToList validator test

* CI: handle pydantic v1 and v2 separately

* list => List

* parsing_utils: Type ignore

* pydantic_utils/v2: safe BareModel

* fix Makefile for poetry

* fix ci cache for pydantic versions

* Remove setup.py

* Update pyproject and poetry

* Linting fixes

* Remove types remain intact changes

* Strong type results to covaraiant Sequence, as suggested by Pyright

* Fix linting issues

* Change casting

* Add else condition for pii_entities to avoid unbound errors for entities_to_filter

---------

Co-authored-by: zsimjee <[email protected]>
Co-authored-by: Rafael Irgolic <[email protected]>

OpenAI v1 support (guardrails-ai#441)

* Support both openai v0 and v1

* Adjust CI for openai v0/v1

* Move LLMResponse object to its own file

* Add usage to provenance test mock

* Comment out ArbitraryCallable test suite for openai errors

* Adjust tests for openai v0/v1

* remove unused imports

* OpenAIv1: Don't instantiate openai.completions.create if key isn't present in environ

lint and type fix

fix test

' -> "

Rail XML: Rename "format" attr to "validators" (guardrails-ai#439)

* Rail XML: Rename "format" attr to "validators"

* added note that `format` will be removed in 0.4.x

* test_rail: Check format deprecation resolves properly

Allow OpenAI v1

pyproject.toml: Clamp pydantic to ">=1.10.9, <2.5"

pyproject.toml: Clamp pyright to 1.1.334

update poetry.lock
  • Loading branch information
zsimjee authored and CalebCourier committed Nov 22, 2023
1 parent bcc4bb3 commit dd8bc98
Show file tree
Hide file tree
Showing 73 changed files with 9,048 additions and 1,889 deletions.
74 changes: 54 additions & 20 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,26 @@ jobs:
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- uses: actions/cache@v2
- name: Poetry cache
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip
path: ~/.cache/pypoetry
key: poetry-cache-${{ runner.os }}-${{ steps.setup_python.outputs.python-version }}-${{ env.POETRY_VERSION }}

- name: Install Poetry
uses: snok/install-poetry@v1

- name: Install Dependencies
# TODO: fix errors so that we can run `make dev` instead
run: |
python -m pip install --upgrade pip
make dev
make full
- name: Lint with isort, black, docformatter, flake8
run: |
Expand All @@ -47,51 +50,82 @@ jobs:
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']

pydantic-version: ['1.10.9', '2.4.2']
openai-version: ['0.28.1', '1.2.4']
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- uses: actions/cache@v2
- name: Poetry cache
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip
path: ~/.cache/pypoetry
key: poetry-cache-${{ runner.os }}-${{ steps.setup_python.outputs.python-version }}-${{ env.POETRY_VERSION }}-${{ matrix.pydantic-version }}

- name: Install Poetry
uses: snok/install-poetry@v1

- name: Install Dependencies
# TODO: fix errors so that we can run `make dev` instead
run: |
python -m pip install --upgrade pip
make dev
make full
poetry run pip install pydantic==${{ matrix.pydantic-version }}
poetry run pip install openai==${{ matrix.openai-version }}
- name: Static analysis with pyright
- if: matrix.pydantic-version == '2.4.2' && matrix.openai-version == '0.28.1'
name: Static analysis with pyright (ignoring pydantic v1 and openai v1)
run: |
make type
make type-pydantic-v2-openai-v0
- if: matrix.pydantic-version == '1.10.9' && matrix.openai-version == '0.28.1'
name: Static analysis with mypy (ignoring pydantic v2 and openai v1)
run: |
make type-pydantic-v1-openai-v0
- if: matrix.pydantic-version == '2.4.2' && matrix.openai-version == '1.2.4'
name: Static analysis with pyright (ignoring pydantic v1 and openai v0)
run: |
make type-pydantic-v2-openai-v1
- if: matrix.pydantic-version == '1.10.9' && matrix.openai-version == '1.2.4'
name: Static analysis with mypy (ignoring pydantic v2 and openai v0)
run: |
make type-pydantic-v1-openai-v1
Pytests:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']
dependencies: ['dev', 'full']

# TODO: fix errors so that we can run both `make dev` and `make full`
# dependencies: ['dev', 'full']
dependencies: ['full']
pydantic-version: ['1.10.9', '2.4.2']
openai-version: ['0.28.1', '1.2.4']
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- uses: actions/cache@v2
- name: Poetry cache
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip
path: ~/.cache/pypoetry
key: poetry-cache-${{ runner.os }}-${{ steps.setup_python.outputs.python-version }}-${{ env.POETRY_VERSION }}-${{ matrix.pydantic-version }}-${{ matrix.openai-version }}

- name: Install Poetry
uses: snok/install-poetry@v1

- name: Install Dependencies
run: |
python -m pip install --upgrade pip
make ${{ matrix.dependencies }}
poetry run pip install pydantic==${{ matrix.pydantic-version }}
poetry run pip install openai==${{ matrix.openai-version }}
- name: Run Pytests
run: |
Expand Down
13 changes: 9 additions & 4 deletions .github/workflows/deploy_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,15 @@ jobs:
uses: actions/checkout@v3
- name: Setup Pages
uses: actions/configure-pages@v3
- name: Install
run: |
python -m pip install --upgrade pip
pip install -r docs/requirements.txt
- name: Poetry cache
uses: actions/cache@v3
with:
path: ~/.cache/pypoetry
key: poetry-cache-${{ runner.os }}-${{ steps.setup_python.outputs.python-version }}-${{ env.POETRY_VERSION }
- name: Install Poetry
uses: snok/install-poetry@v1
- name: Install dependencies
run: poetry install --with docs
- name: Build
run: mkdocs build
- name: Upload artifact
Expand Down
12 changes: 10 additions & 2 deletions .github/workflows/examples_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,17 @@ jobs:
with:
python-version: 3.11.x

- name: Poetry cache
uses: actions/cache@v3
with:
path: ~/.cache/pypoetry
key: poetry-cache-${{ runner.os }}-${{ steps.setup_python.outputs.python-version }}-${{ env.POETRY_VERSION }}

- name: Install Poetry
uses: snok/install-poetry@v1

- name: Install dependencies
run: |
make full; pip install jupyter nbconvert; pip install .
run: make full; pip install jupyter nbconvert; pip install .

- name: Execute notebooks and check for errors
run: |
Expand Down
18 changes: 13 additions & 5 deletions .github/workflows/release_version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,21 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: 3.x
python-version: 3.11.x

- name: Install twine and wheel
run: pip install twine wheel
- name: Poetry cache
uses: actions/cache@v3
with:
path: ~/.cache/pypoetry
key: poetry-cache-${{ runner.os }}-${{ steps.setup_python.outputs.python-version }}-${{ env.POETRY_VERSION }}

- name: Install Poetry
uses: snok/install-poetry@v1

- name: Make Full
- name: Install dependencies
run: make full

- name: Upload to PyPI
run: python3 setup.py upload
env:
PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: poetry publish --build -u __token__ -p $PYPI_PASSWORD
50 changes: 35 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,47 +1,67 @@
MKDOCS_SERVE_ADDR ?= localhost:8000 # Default address for mkdocs serve, format: <host>:<port>, override with `make docs-serve MKDOCS_SERVE_ADDR=<host>:<port>`

autoformat:
black guardrails/ tests/
isort --atomic guardrails/ tests/
docformatter --in-place --recursive guardrails tests
poetry run black guardrails/ tests/
poetry run isort --atomic guardrails/ tests/
poetry run docformatter --in-place --recursive guardrails tests

type:
pyright guardrails/
poetry run pyright guardrails/

type-pydantic-v1-openai-v0:
echo '{"exclude": ["guardrails/utils/pydantic_utils/v2.py", "guardrails/utils/openai_utils/v1.py"]}' > pyrightconfig.json
poetry run pyright guardrails/
rm pyrightconfig.json

type-pydantic-v1-openai-v1:
echo '{"exclude": ["guardrails/utils/pydantic_utils/v2.py", "guardrails/utils/openai_utils/v0.py"]}' > pyrightconfig.json
poetry run pyright guardrails/
rm pyrightconfig.json

type-pydantic-v2-openai-v0:
echo '{"exclude": ["guardrails/utils/pydantic_utils/v1.py", "guardrails/utils/openai_utils/v1.py"]}' > pyrightconfig.json
poetry run pyright guardrails/
rm pyrightconfig.json

type-pydantic-v2-openai-v1:
echo '{"exclude": ["guardrails/utils/pydantic_utils/v1.py", "guardrails/utils/openai_utils/v0.py"]}' > pyrightconfig.json
poetry run pyright guardrails/
rm pyrightconfig.json

lint:
isort -c guardrails/ tests/
black guardrails/ tests/ --check
flake8 guardrails/ tests/
poetry run isort -c guardrails/ tests/
poetry run black guardrails/ tests/ --check
poetry run flake8 guardrails/ tests/

test:
pytest tests/
poetry run pytest tests/

test-basic:
set -e
python -c "import guardrails as gd"
python -c "import guardrails.version as mversion"

test-cov:
pytest tests/ --cov=./guardrails/ --cov-report=xml
poetry run pytest tests/ --cov=./guardrails/ --cov-report=xml

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

docs-serve:
mkdocs serve -a $(MKDOCS_SERVE_ADDR)
poetry run mkdocs serve -a $(MKDOCS_SERVE_ADDR)

docs-deploy:
mkdocs gh-deploy
poetry run mkdocs gh-deploy

dev:
pip install -e ".[dev]"
poetry install

full:
pip install -e ".[all]"
poetry install --all-extras

all: autoformat type lint docs test

precommit:
# pytest -x -q --no-summary
pyright guardrails/
make lint
make lint
Loading

0 comments on commit dd8bc98

Please sign in to comment.