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

[Feat] Drop Python 3.8 and add Python 3.13 support to Vizro #813

Merged
merged 26 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
8b2d7d1
Vizro to py38 and Vizro-AI to py39
antonymilne Oct 15, 2024
e8f63ba
Vizro to py39
antonymilne Oct 15, 2024
e079822
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 15, 2024
fbbcb7b
Fix preview linting suggestions
antonymilne Oct 15, 2024
a5090df
Fix preview linting suggestions
antonymilne Oct 15, 2024
01cabdb
Fix tests
antonymilne Oct 15, 2024
02094fa
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 15, 2024
b22f3cd
Add 3.13 to CI and elsewhere
antonymilne Oct 16, 2024
cfedf90
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 16, 2024
cab1a8b
Replace List with list and Dict with dict across Python files
antonymilne Oct 16, 2024
ee635d7
Bump to pydantic>=1.10.16
antonymilne Oct 16, 2024
22dca55
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 16, 2024
b99aebe
Drop 3.13 for Vizro-AI
antonymilne Oct 16, 2024
709077a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 16, 2024
892f148
Drop 3.13 for Vizro-AI
antonymilne Oct 16, 2024
be73543
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 16, 2024
a4dbb91
Update docs to remove `from typing import List`
antonymilne Oct 16, 2024
4f38fb9
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 16, 2024
c8ba462
Add changelogs and fix test for Python 3.13
antonymilne Oct 16, 2024
9860dd3
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 16, 2024
c520b80
Fix same test for other Python versions
antonymilne Oct 16, 2024
6ea08e2
Try to fix lower bound environment
antonymilne Oct 16, 2024
8eaa97f
Final pre-merge fixes
antonymilne Oct 16, 2024
ff7a37b
Remove Raises from KPI card docstrings
antonymilne Oct 17, 2024
63d4a28
Fix changelog and add comments to linters
antonymilne Oct 17, 2024
c33ebd5
Urgh
antonymilne Oct 17, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/checks-vizro-ai.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ on:
env:
PYTHONUNBUFFERED: 1
FORCE_COLOR: 1
PYTHON_VERSION: "3.11"
PYTHON_VERSION: "3.12"

jobs:
checks-vizro-ai:
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 @@ -18,7 +18,7 @@ on:
env:
PYTHONUNBUFFERED: 1
FORCE_COLOR: 1
PYTHON_VERSION: "3.11"
PYTHON_VERSION: "3.12"

jobs:
checks-vizro-core:
Expand All @@ -42,7 +42,7 @@ jobs:
run: hatch run pip tree

- name: Check schema is up to date
run: hatch run schema --check
run: hatch run schema-check

- name: Find changed files to see if changelog fragment needed
id: changed-files
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/checks-workflows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
env:
PYTHONUNBUFFERED: 1
FORCE_COLOR: 1
PYTHON_VERSION: "3.11"
PYTHON_VERSION: "3.12"

jobs:
checks-workflows:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint-vizro-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ on:
env:
PYTHONUNBUFFERED: 1
FORCE_COLOR: 1
PYTHON_VERSION: "3.11"
PYTHON_VERSION: "3.12"

jobs:
lint-vizro-all:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-if-needed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- main

env:
PYTHON_VERSION: "3.11"
PYTHON_VERSION: "3.12"

jobs:
check-version:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/secret-scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
- cron: "0 4 * * *" # run once a day at 4 AM UTC

env:
PYTHON_VERSION: "3.11"
PYTHON_VERSION: "3.12"

jobs:
secret-scan:
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/test-integration-vizro-ai.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ jobs:
hatch-env: all.py3.11
- python-version: "3.12"
hatch-env: all.py3.12
- python-version: "3.11"
- python-version: "3.9"
hatch-env: lower-bounds
label: lower bounds

steps:
- uses: actions/checkout@v4

Expand All @@ -60,7 +61,7 @@ jobs:
hatch-env: all.py3.11
- python-version: "3.12"
hatch-env: all.py3.12
- python-version: "3.11"
- python-version: "3.9"
hatch-env: lower-bounds
label: lower bounds

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test-integration-vizro-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ jobs:
fail-fast: false
matrix:
include:
- python-version: "3.8"
hatch-env: all.py3.8
- python-version: "3.9"
hatch-env: all.py3.9
- python-version: "3.10"
Expand All @@ -34,7 +32,9 @@ jobs:
hatch-env: all.py3.11
- python-version: "3.12"
hatch-env: all.py3.12
- python-version: "3.11"
- python-version: "3.13"
hatch-env: all.py3.13
- python-version: "3.9"
hatch-env: lower-bounds
label: lower bounds

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-unit-vizro-ai.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
hatch-env: all.py3.11
- python-version: "3.12"
hatch-env: all.py3.12
- python-version: "3.11"
- python-version: "3.9"
hatch-env: lower-bounds
label: lower bounds

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test-unit-vizro-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ jobs:
fail-fast: false
matrix:
include:
- python-version: "3.8"
hatch-env: all.py3.8
- python-version: "3.9"
hatch-env: all.py3.9
- python-version: "3.10"
Expand All @@ -34,7 +32,9 @@ jobs:
hatch-env: all.py3.11
- python-version: "3.12"
hatch-env: all.py3.12
- python-version: "3.11"
- python-version: "3.13"
hatch-env: all.py3.13
- python-version: "3.9"
hatch-env: lower-bounds
label: lower bounds

Expand Down
1 change: 1 addition & 0 deletions .vale/styles/Microsoft/ignore.txt
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,4 @@ codespace
codespaces
uv
jsDeliver
dash_table
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<div align="center" markdown="1">

[![Python version](https://img.shields.io/badge/python-3.8%20%7C%203.9%20%7C%203.10%20%7C%203.11%20%7C%203.12-blue.svg)](https://pypi.org/project/vizro/)
[![Python version](https://img.shields.io/badge/python-3.9%20%7C%203.10%20%7C%203.11%20%7C%203.12%20%7C%203.13-blue.svg)](https://pypi.org/project/vizro/)
[![PyPI version](https://badge.fury.io/py/vizro.svg)](https://badge.fury.io/py/vizro)
[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/mckinsey/vizro/blob/main/LICENSE.md)
[![Documentation](https://readthedocs.org/projects/vizro/badge/?version=stable)](https://vizro.readthedocs.io/)
Expand Down
15 changes: 13 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ ignore = [
"D104", # undocumented-public-package
"D401", # first-line should be in imperative mood
# D407 needs to be ignored as it otherwise messes up the formatting in our API docs
"D407" # missing dashed underline after section
"D407", # missing dashed underline after section
"PD901" # allow using the generic variable name `df` for DataFrames
]
select = [
"E", # pycodestyle errors
Expand All @@ -67,7 +68,11 @@ select = [
"T201", # print
"C4", # flake8-comprehensions
"RUF", # Ruff-specific rules
"PL" # pylint
"PL", # pylint
"PD", # pandas-vet
"UP", # pyupgrade
"PERF", # perflint
"FURB" # refurb
antonymilne marked this conversation as resolved.
Show resolved Hide resolved
]

[tool.ruff.lint.per-file-ignores]
Expand All @@ -82,3 +87,9 @@ convention = "google"

[tool.ruff.lint.pylint]
max-args = 6

[tool.ruff.lint.pyupgrade]
# Don't do PEP 604 rewrites (e.g. Union[str, int] -> str | int), even in files that import
# `from __future__ import annotations`. This is needed since pydantic relies on the runtime behavior in Python 3.9.
# When we drop Python 3.9 we can remove this setting.
keep-runtime-typing = true
6 changes: 3 additions & 3 deletions tools/extract_release_notes.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
"""Extracts latest release notes from CHANGELOG.md and saves to file."""

import sys
from pathlib import Path

from werkzeug.utils import secure_filename

ARG_NUM = 3


def _extract_section(filename, heading):
with open(filename, "r") as file:
with open(filename) as file:
lines = file.readlines()

start_line, end_line = None, None
Expand Down Expand Up @@ -42,5 +43,4 @@ def _extract_section(filename, heading):

if not section:
raise ValueError(f"Section not found under the {HEADING} heading")
with open("release_body.txt", "w") as text_file:
text_file.write(section)
Path("release_body.txt").write_text(section)
2 changes: 1 addition & 1 deletion vizro-ai/.readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ version: 2
build:
os: ubuntu-22.04
tools:
python: "3.11"
python: "3.12"
commands:
- pip install hatch
- cd vizro-ai/ && hatch run docs:pip tree
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<!--
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

- Drop support for Python 3.8. ([#813](https://github.com/mckinsey/vizro/pull/813))

antonymilne marked this conversation as resolved.
Show resolved Hide resolved
<!--
### 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))

-->
2 changes: 1 addition & 1 deletion vizro-ai/examples/chart_by_vizro_ai.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@
" df = gapminder()\n",
"else:\n",
" for fn in uploaded.keys():\n",
" print('User uploaded file \"{name}\"'.format(name=fn))\n",
" print(f'User uploaded file \"{fn}\"')\n",
"\n",
" df = pd.read_csv(fn)\n",
"print(f\"Dataframe used for plotting: \\n{df.head()}\")"
Expand Down
2 changes: 1 addition & 1 deletion vizro-ai/examples/dashboard_by_vizro_ai.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@
" dfs.append(df)\n",
"else:\n",
" for fn in uploaded.keys():\n",
" print('User uploaded file \"{name}\"'.format(name=fn))\n",
" print(f'User uploaded file \"{fn}\"')\n",
"\n",
" df_uploaded = pd.read_csv(fn)\n",
" dfs.append(df_uploaded)"
Expand Down
12 changes: 6 additions & 6 deletions vizro-ai/examples/dashboard_ui/components.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Contains custom components used within a dashboard."""

from typing import List, Literal
from typing import Literal

import black
import dash_bootstrap_components as dbc
Expand All @@ -21,12 +21,12 @@ class UserPromptTextArea(vm.VizroBaseModel):
type (Literal["user_input"]): Defaults to `"user_text_area"`.
title (str): Title to be displayed. Defaults to `""`.
placeholder (str): Default text to display in input field. Defaults to `""`.
actions (Optional[List[Action]]): Defaults to `[]`.
actions (Optional[list[Action]]): Defaults to `[]`.

"""

type: Literal["user_text_area"] = "user_text_area"
actions: List[Action] = [] # noqa: RUF012
actions: list[Action] = [] # noqa: RUF012

_set_actions = _action_validator_factory("value")

Expand All @@ -50,12 +50,12 @@ class UserUpload(vm.VizroBaseModel):
Args:
type (Literal["upload"]): Defaults to `"upload"`.
title (str): Title to be displayed.
actions (List[Action]): See [`Action`][vizro.models.Action]. Defaults to `[]`.
actions (list[Action]): See [`Action`][vizro.models.Action]. Defaults to `[]`.

"""

type: Literal["upload"] = "upload"
actions: List[Action] = [] # noqa: RUF012
actions: list[Action] = [] # noqa: RUF012

# 'contents' property is input to custom action callback
_input_property: str = PrivateAttr("contents")
Expand Down Expand Up @@ -153,7 +153,7 @@ class OffCanvas(vm.VizroBaseModel):
"""OffCanvas component for settings."""

type: Literal["offcanvas"] = "offcanvas"
options: List[str]
options: list[str]
value: str

def build(self):
Expand Down
4 changes: 2 additions & 2 deletions vizro-ai/hatch.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ dependencies = [
"pre-commit"
]
installer = "uv"
python = "3.11"

[envs.default.env-vars]
VIZRO_AI_LOG_LEVEL = "DEBUG"
Expand Down Expand Up @@ -79,7 +78,8 @@ pip = "'{env:HATCH_UV}' pip {args}"
serve = "mkdocs serve --open"

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

[version]
path = "src/vizro_ai/__init__.py"
4 changes: 3 additions & 1 deletion vizro-ai/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ filterwarnings = [
"ignore:(?s).*Pyarrow will become a required dependency of pandas:DeprecationWarning",
# TODO update all LLMChain class and remove this warning
# Ignore LLMchian deprecation warning:
"ignore:.*The class `LLMChain` was deprecated in LangChain 0.1.17"
"ignore:.*The class `LLMChain` was deprecated in LangChain 0.1.17",
# Ignore warning for Pydantic v1 API and Python 3.13:
"ignore:Failing to pass a value to the 'type_params' parameter of 'typing.ForwardRef._evaluate' is deprecated:DeprecationWarning"
]

[tool.ruff]
Expand Down
11 changes: 0 additions & 11 deletions vizro-ai/snyk/requirements.txt

This file was deleted.

4 changes: 2 additions & 2 deletions vizro-ai/src/vizro_ai/_llm_models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from contextlib import suppress
from typing import Dict, Optional, Union
from typing import Optional, Union

from langchain_core.language_models.chat_models import BaseChatModel
from langchain_openai import ChatOpenAI
Expand Down Expand Up @@ -31,7 +31,7 @@
"Mistral": ["mistral-large-latest", "open-mistral-nemo", "codestral-latest"],
}

DEFAULT_WRAPPER_MAP: Dict[str, BaseChatModel] = {
DEFAULT_WRAPPER_MAP: dict[str, BaseChatModel] = {
"OpenAI": ChatOpenAI,
"Anthropic": ChatAnthropic,
"Mistral": ChatMistralAI,
Expand Down
4 changes: 2 additions & 2 deletions vizro-ai/src/vizro_ai/_vizro_ai.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging
from functools import wraps
from typing import List, Optional, Union
from typing import Optional, Union

import pandas as pd
import plotly.graph_objects as go
Expand Down Expand Up @@ -98,7 +98,7 @@ def plot(

def dashboard(
self,
dfs: List[pd.DataFrame],
dfs: list[pd.DataFrame],
user_input: str,
return_elements: bool = False,
) -> Union[DashboardOutputs, vm.Dashboard]:
Expand Down
Loading
Loading