Skip to content

Commit

Permalink
Merge branch '0.5.0-dev' into validator_versioning_hack
Browse files Browse the repository at this point in the history
  • Loading branch information
wylansford authored Jul 2, 2024
2 parents 96264ae + 8668971 commit b2f0a15
Show file tree
Hide file tree
Showing 332 changed files with 18,892 additions and 24,409 deletions.
62 changes: 30 additions & 32 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:
- main
- dev
- feat/*
- 0.*.*

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
Expand All @@ -19,106 +20,103 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

# - name: Poetry cache
# uses: actions/cache@v3
# with:
# path: ~/.cache/pypoetry
# key: poetry-cache-${{ runner.os }}-${{ matrix.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: |
# Setup Virtual Environment
python3 -m venv ./.venv
source .venv/bin/activate
make full
- name: Lint with ruff
run: |
source .venv/bin/activate
make lint
Typing:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
pydantic-version: ["==1.10.9", ">=2.x"]
openai-version: [">=1.x"]
python-version: ["3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

# - name: Poetry cache
# uses: actions/cache@v3
# with:
# path: ~/.cache/pypoetry
# key: poetry-cache-${{ runner.os }}-${{ matrix.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: |
# Setup Virtual Environment
python3 -m venv ./.venv
source .venv/bin/activate
make full
poetry run pip install "pydantic${{ matrix.pydantic-version }}"
poetry run pip install "openai${{ matrix.openai-version }}"
- name: Static analysis with pyright
run: |
source .venv/bin/activate
make type
Pytests:
runs-on: LargeBois
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.9", "3.10", "3.11", "3.12"]
# 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.x"]
openai-version: [">=1.x"]
# dependencies: ["full"]
steps:
- uses: actions/checkout@v4

- name: Create .guardrailsrc
run: |
echo 'id="SYSTEM TESTING"' > ~/.guardrailsrc
echo 'no_metrics=false' >> ~/.guardrailsrc
echo 'enable_metrics=false' >> ~/.guardrailsrc
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

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

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

- name: Install Dependencies
run: |
make ${{ matrix.dependencies }}
poetry run pip install "pydantic${{ matrix.pydantic-version }}"
poetry run pip install "openai${{ matrix.openai-version }}"
# Setup Virtual Environment
python3 -m venv ./.venv
source .venv/bin/activate
make full
if [ "${{ matrix.python-version }}" == "3.12" ]; then
echo "Installing latest langchain-core and langsmith from PyPI"
pip install "langchain-core>=0.2" "langsmith<0.2.0,>=0.1.75"
fi
- name: Run Pytests
run: |
source .venv/bin/activate
echo "langchain-core version:"
pip show langchain-core
echo "langsmith version:"
pip show langsmith
make test-cov
- name: Upload to codecov.io
Expand Down
39 changes: 12 additions & 27 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,40 +1,13 @@
MKDOCS_SERVE_ADDR ?= localhost:8000 # Default address for mkdocs serve, format: <host>:<port>, override with `make docs-serve MKDOCS_SERVE_ADDR=<host>:<port>`

# Extract major package versions for OpenAI and Pydantic
OPENAI_VERSION_MAJOR := $(shell poetry run python -c 'import openai; print(openai.__version__.split(".")[0])')
PYDANTIC_VERSION_MAJOR := $(shell poetry run python -c 'import pydantic; print(pydantic.__version__.split(".")[0])')

# Construct the typing command using only major versions
TYPING_CMD := type-pydantic-v$(PYDANTIC_VERSION_MAJOR)-openai-v$(OPENAI_VERSION_MAJOR)

autoformat:
poetry run ruff check guardrails/ tests/ --fix
poetry run ruff format guardrails/ tests/
poetry run docformatter --in-place --recursive guardrails tests

.PHONY: type
type:
@make $(TYPING_CMD)

type-pydantic-v1-openai-v0:
echo '{"reportDeprecated": true, "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 '{"reportDeprecated": true, "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 '{"reportDeprecated": true, "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 '{"reportDeprecated": true, "exclude": ["guardrails/utils/pydantic_utils/v1.py", "guardrails/utils/openai_utils/v0.py"]}' > pyrightconfig.json
poetry run pyright guardrails/
rm pyrightconfig.json

lint:
poetry run ruff check guardrails/ tests/
Expand Down Expand Up @@ -85,3 +58,15 @@ precommit:
pyright guardrails/
make lint
./.github/workflows/scripts/update_notebook_matrix.sh

refresh:
echo "Removing old virtual environment"
rm -rf ./.venv;
echo "Creating new virtual environment"
python3 -m venv ./.venv;
echo "Sourcing and installing"
source ./.venv/bin/activate && make full;

update-lock:
poetry lock --no-update

13 changes: 1 addition & 12 deletions docs/api_reference/data_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,5 @@
::: guardrails.datatypes
options:
filters:
- "!get_validators"
- "!registry"
- "!DataType"
- "!register_type"
- "!Scalar"
- "!set_children"
- "!validate"
- "!from_str"
- "!from_xml"
- "!model"
- "!validators"
- "!to_object_element"
- "!types_registry"
show_bases: true
8 changes: 7 additions & 1 deletion docs/api_reference/guard.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,17 @@
::: guardrails.guard.Guard
options:
members:
- "__init__"
- "from_rail"
- "from_rail_string"
- "from_pydantic"
- "from_string"
- "use"
- "use_many"
- "to_runnable"
- "configure"
- "__call__"
- "parse"
- "state"
- "validate"
- "history"
- "error_spans_in_output"
13 changes: 0 additions & 13 deletions docs/api_reference/rail.md

This file was deleted.

1 change: 0 additions & 1 deletion docs/api_reference/schema.md

This file was deleted.

Loading

0 comments on commit b2f0a15

Please sign in to comment.