Skip to content

Commit

Permalink
[Feat] Drop Python 3.8 and add Python 3.13 support to Vizro (#813)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
antonymilne and pre-commit-ci[bot] authored Oct 17, 2024
1 parent be96e4a commit f2a52c5
Show file tree
Hide file tree
Showing 108 changed files with 500 additions and 459 deletions.
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
29 changes: 20 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,23 @@ 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
"W", # pycodestyle warnings
"F", # pyflakes
"I", # isort
"D", # pydocstyle
"T201", # print
"C4", # flake8-comprehensions
"E", # pycodestyle errors for style conventions of PEP 8
"W", # pycodestyle warnings for style conventions of PEP 8
"F", # pyflakes for Python errors
"I", # isort for sorting imports
"D", # pydocstyle for docstrings
"T201", # flake8-print for detecting print statement
"C4", # flake8-comprehensions for better list/set/dict comprehensions
"RUF", # Ruff-specific rules
"PL" # pylint
"PL", # pylint
"PD", # pandas-vet for linting pandas code
"UP", # pyupgrade for upgrading syntax to new Python versions
"PERF", # perflint for performance anti-patterns
"FURB" # refurb for reburbishing and modernizing
]

[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,43 @@
<!--
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))
-->

<!--
### 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
Loading

0 comments on commit f2a52c5

Please sign in to comment.