Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into interactive_tooltip…
Browse files Browse the repository at this point in the history
…_legend
  • Loading branch information
dangotbanned committed Jan 17, 2025
2 parents 479fe27 + 21f5849 commit 3319bab
Show file tree
Hide file tree
Showing 159 changed files with 11,050 additions and 5,960 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug-report.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Bug report
description: Report something that is broken
labels: ["bug"]
labels: ["bug", "needs-triage"]
body:
- type: markdown
attributes:
Expand Down
31 changes: 24 additions & 7 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,28 @@
<!-- Click "Preview" to read this message; then delete it. -->

Thanks for contributing to Altair!
## Thanks for contributing to Altair! 🎉

Please follow these guidelines when submitting your PR:
Please follow these guidelines:

- Describe the purpose of the changes in PR, so that it is easy to understand the implication of the suggested changes.
- Here is a [helpful article about writing effective PR descriptions](https://medium.com/@greenberg/writing-pull-requests-your-coworkers-might-enjoy-reading-9d0307e93da3).
- Include unit tests and documentation for new features
- Ensure that the title is a concise [semantic commit message](https://www.conventionalcommits.org/) (e.g. "feat: Add `embed_options` to charts").
- Append `!` if the change is breaking (e.g. "fix!: Raise error when `embed_options` is `None`")
### 1. **PR Description**
- Briefly describe the changes and their purpose. For help, check this [guide](https://medium.com/@greenberg/writing-pull-requests-your-coworkers-might-enjoy-reading-9d0307e93da3).

### 2. **Tests & Docs**
- Include unit tests and update documentation for new features.

### 3. **Commit Message**
- Use [semantic commit messages](https://www.conventionalcommits.org/), e.g., `"feat: Add embed_options to charts"`.
- Add `!` for breaking changes (e.g., `"fix!: Raise error when embed_options is None"`).

### 4. **PR Title Types**
- **feat**: New feature
- **fix**: Bug fix
- **docs**: Documentation changes
- **style**: Code style changes (no functionality change)
- **refactor**: Code restructuring
- **perf**: Performance improvements
- **test**: Add or fix tests
- **build**: Changes to build system or dependencies
- **ci**: CI configuration changes
- **chore**: Miscellaneous tasks
- **revert**: Reverts a commit
25 changes: 14 additions & 11 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ name: build

on: [push, pull_request]

env:
UV_SYSTEM_PYTHON: 1

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
jsonschema-version: ["3.0", "latest"]
name: py ${{ matrix.python-version }} js ${{ matrix.jsonschema-version }}
steps:
Expand All @@ -16,33 +19,33 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install uv
uses: astral-sh/setup-uv@v5
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install ".[all, dev]"
run: uv pip install -e ".[dev, all]"
- name: Install specific jsonschema
# Only have to execute this if we don't want the latest jsonschema version
if: ${{ matrix.jsonschema-version != 'latest' }}
run: |
pip install jsonschema==${{ matrix.jsonschema-version }}
uv pip install jsonschema==${{ matrix.jsonschema-version }}
- name: Maybe uninstall optional dependencies
# We uninstall pyarrow and vegafusion for one job to test that we have not
# accidentally introduced a hard dependency on these libraries.
# Uninstalling for Python 3.9 is an arbitrary choice.
# Also see https://github.com/vega/altair/pull/3114
if: ${{ matrix.python-version == '3.9' }}
run: |
pip uninstall -y pyarrow vegafusion vegafusion-python-embed vl-convert-python anywidget
uv pip uninstall pyarrow vegafusion vegafusion-python-embed vl-convert-python anywidget
- name: Maybe install lowest supported pandas version
# We install the lowest supported pandas version for one job to test that
# it still works. Downgrade to the oldest versions of pandas and numpy that include
# Python 3.9 wheels, so only run this job for Python 3.9
if: ${{ matrix.python-version == '3.9' }}
run: |
pip install pandas==1.1.3 numpy==1.19.3
uv pip install pandas==1.1.3 numpy==1.19.3
- name: Test that schema generation has no effect
run: |
pip install vl-convert-python
uv pip install vl-convert-python
python tools/generate_schema_wrapper.py
# This gets the paths of all files which were either deleted, modified
# or are not yet tracked by Git
Expand All @@ -66,13 +69,13 @@ jobs:
fi
- name: Test with pytest
run: |
pytest --pyargs --numprocesses=logical --doctest-modules tests
uv run pytest --pyargs --numprocesses=logical --doctest-modules --doctest-ignore-import-errors tests
- name: Validate Vega-Lite schema
run: |
# We install all 'format' dependencies of jsonschema as check-jsonschema
# only does the 'format' checks which are installed.
# We can always use the latest jsonschema version here.
# uri-reference check is disabled as the URIs in the Vega-Lite schema do
# not conform RFC 3986.
pip install 'jsonschema[format]' check-jsonschema --upgrade
check-jsonschema --check-metaschema altair/vegalite/v5/schema/vega-lite-schema.json --disable-formats uri-reference
uv pip install 'jsonschema[format]' check-jsonschema --upgrade
uv run check-jsonschema --check-metaschema altair/vegalite/v5/schema/vega-lite-schema.json --disable-formats uri-reference
20 changes: 13 additions & 7 deletions .github/workflows/docbuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,21 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
cache-dependency-glob: |
**/uv.lock
**/pyproject.toml
- name: Install dependencies
run: uv sync --all-extras
- name: Build docs
run: |
python -m pip install --upgrade pip
pip install hatch
- name: Run doc:build-html
run: |
hatch run doc:build-html
- name: Run doc:doctest
mkdir -p doc/_images
uv run sphinx-build -b html -d doc/_build/doctrees doc doc/_build/html
- name: Run doctests
run: |
hatch run doc:doctest
uv run sphinx-build -b doctest -d doc/_build/doctrees doc doc/_build/doctest
28 changes: 16 additions & 12 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,27 @@ jobs:
runs-on: ubuntu-latest
name: ruff-mypy
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.12
- name: "Set up Python"
uses: actions/setup-python@v5
with:
python-version: "3.12"
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
cache-dependency-glob: |
**/uv.lock
**/pyproject.toml
# Installing all dependencies and not just the linters as mypy needs them for type checking
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install hatch
- name: Lint with ruff
run: uv sync --all-extras
- name: ruff check (lint)
run: |
hatch run ruff check .
- name: Check formatting with ruff
uv run ruff check
- name: ruff format
run: |
hatch run ruff format --diff .
hatch run ruff format --check .
- name: Lint with mypy
uv run ruff format --check --diff
- name: mypy (type check)
run: |
hatch run mypy altair tests
uv run mypy altair tests
94 changes: 62 additions & 32 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,54 @@ git clone https://github.com/YOUR-USERNAME/altair.git
To keep your fork up to date with changes in this repo,
you can [use the fetch upstream button on GitHub](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork).

Now you can install the latest version of Altair locally using `pip`.
The `-e` flag indicates that your local changes will be reflected
every time you open a new Python interpreter
(instead of having to reinstall the package each time).

[Install `uv`](https://docs.astral.sh/uv/getting-started/installation/), or update to the latest version:

```cmd
uv self update
```
Install Python:

```cmd
uv python install 3.12
```

Initialize a new virtual environment:

```cmd
cd altair/
python -m pip install -e ".[all, dev]"
cd altair/
uv venv -p 3.12
```

'[all, dev]' indicates that pip should also install the optional and development requirements
which you can find in `pyproject.toml` (`[project.optional-dependencies]/all` and `[project.optional-dependencies]/dev`)
Activate your environment:

<details><summary>macOS/Linux</summary>
<p>

```bash
source .venv/bin/activate
```

</p>
</details>

<details><summary>Windows</summary>
<p>

```cmd
.venv\Scripts\activate
```

</p>
</details>

Install the project with all development dependencies:
```cmd
uv sync --all-extras
```

> [!TIP]
> If you're new to `uv`, check out their [Getting started](https://docs.astral.sh/uv/getting-started/) guide for help
### Creating a Branch

Expand All @@ -59,7 +95,7 @@ make sure to run the following to see if there are any changes
to the automatically generated files:

```bash
hatch run generate-schema-wrapper
uv run task generate-schema-wrapper
```

For information on how to update the Vega-Lite version that Altair uses,
Expand All @@ -72,7 +108,7 @@ it is recommended that you run the Altair test suite,
which includes a number of tests to validate the correctness of your code:

```bash
hatch test
uv run task test
```


Expand All @@ -83,14 +119,15 @@ Study the output of any failed tests and try to fix the issues
before proceeding to the next section.

#### Failures on specific python version(s)
By default, `hatch test` will run the test suite against the currently active python version.

By default, `uv run task test` will run the test suite against the currently active python version.
Two useful variants for debugging failures that only appear *after* you've submitted your PR:

```bash
# Test against all python version(s) in the matrix
hatch test --all
# Test against a specific python version
hatch test --python 3.8
uv run task test-all
# Test against our minimum required version
uv run task test-min
```

See [hatch test](https://hatch.pypa.io/latest/cli/reference/#hatch-test) docs for other options.
Expand All @@ -99,7 +136,7 @@ See [hatch test](https://hatch.pypa.io/latest/cli/reference/#hatch-test) docs fo
If `test_completeness_of__all__` fails, you may need to run:

```bash
hatch run update-init-file
uv run task update-init-file
```
However, this test usually indicates *unintentional* addition(s) to the top-level `alt.` namespace that will need resolving first.

Expand Down Expand Up @@ -204,27 +241,20 @@ Some additional notes:

The process to build the documentation locally consists of three steps:

1. Clean any previously generated files to ensure a clean build.
2. Generate the documentation in HTML format.
3. View the generated documentation using a local Python testing server.

The specific commands for each step depend on your operating system.
Make sure you execute the following commands from the root dir of altair and have [`hatch`](https://hatch.pypa.io/) installed in your local environment.
1. **Clean** (remove) any previously generated documentation files.
2. **Build** the documentation in HTML format.
3. View the documentation using a *local* Python testing **server**.

- For MacOS and Linux, run the following commands in your terminal:
```bash
hatch run doc:clean-all
hatch run doc:build-html
hatch run doc:serve
```

- For Windows, use these commands instead:
Steps 1 & 2 can be run as a single command, followed by step 3:
```cmd
hatch run doc:clean-all-win
hatch run doc:build-html-win
hatch run doc:serve
uv run task doc-clean-build
uv run task doc-serve
```

> [!TIP]
> If these commands were not available for you, make sure you've [set up your environment](#setting-up-your-environment)

To view the documentation, open your browser and go to `http://localhost:8000`. To stop the server, use `^C` (control+c) in the terminal.

---
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2015-2023, Vega-Altair Developers
Copyright (c) 2015-2025, Vega-Altair Developers
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
Loading

0 comments on commit 3319bab

Please sign in to comment.