Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove pydantic upper bound #189

Merged
merged 26 commits into from
Dec 7, 2023
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
4 changes: 2 additions & 2 deletions .github/workflows/checks-vizro-ai.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ concurrency:
group: checks-ai-${{ github.head_ref }}

env:
PYTHONUNBUFFERED: "1"
FORCE_COLOR: "1"
PYTHONUNBUFFERED: 1
FORCE_COLOR: 1
PYTHON_VERSION: "3.11"

jobs:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/checks-vizro-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ concurrency:
group: checks-core-${{ github.head_ref }}

env:
PYTHONUNBUFFERED: "1"
FORCE_COLOR: "1"
PYTHONUNBUFFERED: 1
FORCE_COLOR: 1
PYTHON_VERSION: "3.11"

jobs:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/lint-vizro-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ on:
branches: [main]
pull_request:
branches:
- "main"
- main

concurrency:
group: lint-${{ github.head_ref }}

env:
PYTHONUNBUFFERED: "1"
FORCE_COLOR: "1"
PYTHONUNBUFFERED: 1
FORCE_COLOR: 1
PYTHON_VERSION: "3.11"

jobs:
Expand Down
30 changes: 22 additions & 8 deletions .github/workflows/test-integration-vizro-ai.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,33 @@ on:
branches: [main]
pull_request:
branches:
- "main"
- main

concurrency:
group: test-integration-${{ github.head_ref }}

env:
PYTHONUNBUFFERED: "1"
FORCE_COLOR: "1"
PYTHONUNBUFFERED: 1
FORCE_COLOR: 1

jobs:
test-integration-vizro-ai:
name: test-integration-vizro-ai on Py${{ matrix.python-version }}
name: test-integration-vizro-ai on Py${{ matrix.python-version }} ${{ matrix.label }}

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11"]
include:
- python-version: "3.9"
hatch-env: all.py3.9
- python-version: "3.10"
hatch-env: all.py3.10
- python-version: "3.11"
hatch-env: all.py3.11
- python-version: "3.11"
hatch-env: lower-bounds
label: lower bounds

steps:
- uses: actions/checkout@v4
Expand All @@ -39,11 +50,14 @@ jobs:
- name: Install Hatch
run: pip install --upgrade hatch

- name: List dependencies
run: hatch run ${{ matrix.hatch-env }}:pip freeze

- name: Run vizro-ai integration tests with pypi vizro
run: |
export OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }}
export OPENAI_API_BASE=${{ secrets.OPENAI_API_BASE }}
hatch run all.py${{ matrix.python-version }}:test-integration
hatch run ${{ matrix.hatch-env }}:test-integration

- name: Run vizro-ai integration tests with local vizro
run: |
Expand All @@ -52,5 +66,5 @@ jobs:
cd ../vizro-core
hatch build
cd ../vizro-ai
hatch run all.py${{ matrix.python-version }}:pip install ../vizro-core/dist/vizro*.tar.gz
hatch run all.py${{ matrix.python-version }}:test-integration
hatch run ${{ matrix.hatch-env }}:pip install ../vizro-core/dist/vizro*.tar.gz
hatch run ${{ matrix.hatch-env }}:test-integration
26 changes: 19 additions & 7 deletions .github/workflows/test-integration-vizro-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,35 @@ on:
branches: [main]
pull_request:
branches:
- "main"
- main

concurrency:
group: test-integration-${{ github.head_ref }}

env:
PYTHONUNBUFFERED: "1"
FORCE_COLOR: "1"
PYTHONUNBUFFERED: 1
FORCE_COLOR: 1

jobs:
test-integration-vizro-core:
name: test-integration-vizro-core on Py${{ matrix.python-version }}
name: test-integration-vizro-core on Py${{ matrix.python-version }} ${{ matrix.label }}

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
include:
- python-version: "3.8"
hatch-env: all.py3.8
- python-version: "3.9"
hatch-env: all.py3.9
- python-version: "3.10"
hatch-env: all.py3.10
- python-version: "3.11"
hatch-env: all.py3.11
- python-version: "3.11"
hatch-env: lower-bounds
label: lower bounds

steps:
- uses: actions/checkout@v4
Expand All @@ -39,7 +51,7 @@ jobs:
run: pip install --upgrade hatch

- name: List dependencies
run: hatch run all.py${{ matrix.python-version }}:pip freeze
run: hatch run ${{ matrix.hatch-env }}:pip freeze

- name: Run integration tests
run: hatch run all.py${{ matrix.python-version }}:test-integration
run: hatch run ${{ matrix.hatch-env }}:test-integration
25 changes: 17 additions & 8 deletions .github/workflows/test-unit-vizro-ai.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,33 @@ on:
branches: [main]
pull_request:
branches:
- "main"
- main

concurrency:
group: test-unit-${{ github.head_ref }}

env:
PYTHONUNBUFFERED: "1"
FORCE_COLOR: "1"
PYTHONUNBUFFERED: 1
FORCE_COLOR: 1

jobs:
test-unit-vizro-ai:
name: test-unit-vizro-ai on Py${{ matrix.python-version }}
name: test-unit-vizro-ai on Py${{ matrix.python-version }} ${{ matrix.label }}

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11"]
include:
- python-version: "3.9"
hatch-env: all.py3.9
- python-version: "3.10"
hatch-env: all.py3.10
- python-version: "3.11"
hatch-env: all.py3.11
- python-version: "3.11"
hatch-env: lower-bounds
label: lower bounds

steps:
- uses: actions/checkout@v4
Expand All @@ -39,8 +49,7 @@ jobs:
run: pip install --upgrade hatch

- name: List dependencies
run: hatch run all.py${{ matrix.python-version }}:pip freeze
run: hatch run ${{ matrix.hatch-env }}:pip freeze

- name: Run unit tests
run: |
hatch run all.py${{ matrix.python-version }}:test-unit-coverage
run: hatch run ${{ matrix.hatch-env }}:test-unit-coverage
26 changes: 19 additions & 7 deletions .github/workflows/test-unit-vizro-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,35 @@ on:
branches: [main]
pull_request:
branches:
- "main"
- main

concurrency:
group: test-unit-${{ github.head_ref }}

env:
PYTHONUNBUFFERED: "1"
FORCE_COLOR: "1"
PYTHONUNBUFFERED: 1
FORCE_COLOR: 1

jobs:
test-unit-vizro-core:
name: test-unit-vizro-core on Py${{ matrix.python-version }}
name: test-unit-vizro-core on Py${{ matrix.python-version }} ${{ matrix.label }}

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
include:
- python-version: "3.8"
hatch-env: all.py3.8
- python-version: "3.9"
hatch-env: all.py3.9
- python-version: "3.10"
hatch-env: all.py3.10
- python-version: "3.11"
hatch-env: all.py3.11
- python-version: "3.11"
hatch-env: lower-bounds
label: lower bounds

steps:
- uses: actions/checkout@v4
Expand All @@ -39,7 +51,7 @@ jobs:
run: pip install --upgrade hatch

- name: List dependencies
run: hatch run all.py${{ matrix.python-version }}:pip freeze
run: hatch run ${{ matrix.hatch-env }}:pip freeze

- name: Run unit tests
run: hatch run all.py${{ matrix.python-version }}:test-unit-coverage
run: hatch run ${{ matrix.hatch-env }}:test-unit-coverage
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ repos:
- id: mypy
files: ^vizro-core/src/
additional_dependencies:
- pydantic>=1.10.13, <2
- pydantic>=1.10.13, <2 # deliberately pinned to <2 until we bump our pydantic requirement to strictly >=2

- repo: https://github.com/gitleaks/gitleaks
rev: v8.16.4
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<!--
A new scriv changelog fragment.

Uncomment the section that is right (remove the HTML comment wrapper).
-->

<!--
### Highlights ✨

- A bullet item for the Highlights ✨ category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX ([#1](https://github.com/mckinsey/vizro/pull/1))

-->
<!--
### Removed

- A bullet item for the Removed category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX ([#1](https://github.com/mckinsey/vizro/pull/1))

-->
<!--
### Added

- A bullet item for the Added category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX ([#1](https://github.com/mckinsey/vizro/pull/1))

-->
<!--
### Changed

- A bullet item for the Changed category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX ([#1](https://github.com/mckinsey/vizro/pull/1))

-->
<!--
### Deprecated

- A bullet item for the Deprecated category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX ([#1](https://github.com/mckinsey/vizro/pull/1))

-->
<!--
### Fixed

- A bullet item for the Fixed category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX ([#1](https://github.com/mckinsey/vizro/pull/1))

-->
<!--
### Security

- A bullet item for the Security category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX ([#1](https://github.com/mckinsey/vizro/pull/1))

-->
3 changes: 3 additions & 0 deletions vizro-ai/hatch.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,8 @@ dependencies = [
detached = true
scripts = {lint = "SKIP=gitleaks pre-commit run {args:--all-files}"}

[envs.lower-bounds]
extra-dependencies = ["pydantic==1.10.13"]

[version]
path = "src/vizro_ai/__init__.py"
6 changes: 5 additions & 1 deletion vizro-ai/src/vizro_ai/chains/_llm_models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
from typing import Callable, Dict, List, Union

from langchain.chat_models import ChatOpenAI
from pydantic import BaseModel, Field

try:
from pydantic.v1 import BaseModel, Field
except ImportError: # pragma: no cov
from pydantic import BaseModel, Field

# TODO add new wrappers in if new model support is added
LLM_MODELS = Union[ChatOpenAI]
Expand Down
6 changes: 5 additions & 1 deletion vizro-ai/src/vizro_ai/components/chart_selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
from typing import Dict, Tuple

import pandas as pd
from pydantic import BaseModel, Field

try:
from pydantic.v1 import BaseModel, Field
except ImportError: # pragma: no cov
from pydantic import BaseModel, Field

from vizro_ai.chains._chain_utils import _log_time
from vizro_ai.chains._llm_models import LLM_MODELS
Expand Down
5 changes: 4 additions & 1 deletion vizro-ai/src/vizro_ai/components/code_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
import traceback
from typing import Dict, Tuple

from pydantic import BaseModel, Field
try:
from pydantic.v1 import BaseModel, Field
except ImportError: # pragma: no cov
from pydantic import BaseModel, Field

from vizro_ai.chains._chain_utils import _log_time
from vizro_ai.chains._llm_models import LLM_MODELS
Expand Down
5 changes: 4 additions & 1 deletion vizro-ai/src/vizro_ai/components/custom_chart_wrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
import logging
from typing import Dict, Tuple

from pydantic import BaseModel, Field
try:
from pydantic.v1 import BaseModel, Field
except ImportError: # pragma: no cov
from pydantic import BaseModel, Field

from vizro_ai.chains._chain_utils import _log_time
from vizro_ai.chains._llm_models import LLM_MODELS
Expand Down
6 changes: 5 additions & 1 deletion vizro-ai/src/vizro_ai/components/dataframe_craft.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
from typing import Dict, Tuple

import pandas as pd
from pydantic import BaseModel, Field

try:
from pydantic.v1 import BaseModel, Field
except ImportError: # pragma: no cov
from pydantic import BaseModel, Field

from vizro_ai.chains._chain_utils import _log_time
from vizro_ai.chains._llm_models import LLM_MODELS
Expand Down
5 changes: 4 additions & 1 deletion vizro-ai/src/vizro_ai/components/explanation.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
"""Chart Type Selection Component."""
from typing import Dict, Tuple

from pydantic import BaseModel, Field
try:
from pydantic.v1 import BaseModel, Field
except ImportError: # pragma: no cov
from pydantic import BaseModel, Field

from vizro_ai.chains._chain_utils import _log_time
from vizro_ai.chains._llm_models import LLM_MODELS
Expand Down
Loading
Loading