Skip to content
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
94 changes: 68 additions & 26 deletions .github/workflows/build_and_publish.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,76 @@
name: Publish Python 🐍 distributions 📦 to PyPI
name: Publish to PyPI

on:
push:
tags:
- '*'
- '[0-9]+.[0-9]+.[0-9]+'

permissions: {}

jobs:
build-n-publish:
name: Build and publish Python 🐍 distributions 📦 to PyPI
build:
name: Build and test distributions
runs-on: ubuntu-latest
permissions:
contents: read
env:
MPLBACKEND: Agg
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
with:
python-version: '3.12'
- name: Build the wheel and source distribution
run: |
python -m pip install build twine
python -m build
- name: Check package metadata and release version
run: |
python -m twine check --strict dist/*
python - <<'PY'
import os
from pathlib import Path
from packaging.utils import parse_sdist_filename, parse_wheel_filename

tag = os.environ['GITHUB_REF_NAME']
wheel, = Path('dist').glob('*.whl')
sdist, = Path('dist').glob('*.tar.gz')
for file, parse in [(wheel, parse_wheel_filename), (sdist, parse_sdist_filename)]:
if str(parse(file.name)[1]) != tag:
raise SystemExit(f'{file.name} does not match release tag {tag!r}')
PY
- name: Install the built wheel
run: python -m pip install dist/*.whl
- name: Test the installed wheel
working-directory: ${{ runner.temp }}
run: python -m unittest discover -s "$GITHUB_WORKSPACE/tests" -v
- name: Upload distributions for the publish job
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: distributions
path: dist/
if-no-files-found: error

publish:
name: Publish distributions with attestations
if: github.repository == 'Infinitode/PyAutoPlot'
needs: build
runs-on: ubuntu-latest
permissions:
id-token: write
# No environment: the PyPI Trusted Publisher must also leave it blank.
steps:
- uses: actions/checkout@master
- name: Set up Python 3.12
uses: actions/setup-python@v3
with:
python-version: '3.12'
- name: Install pypa/setuptools
run: >-
python -m
pip install setuptools wheel
- name: Extract tag name
id: tag
run: echo ::set-output name=TAG_NAME::$(echo $GITHUB_REF | cut -d / -f 3)
- name: Update version in setup.py
run: >-
sed -i "s/{{VERSION_PLACEHOLDER}}/${{ steps.tag.outputs.TAG_NAME }}/g" setup.py
- name: Build a binary wheel
run: >-
python setup.py sdist bdist_wheel
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.PYPI_API_TOKEN }}
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: distributions
path: dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3
with:
attestations: true
- name: Link to release provenance
run: |
printf '[View release provenance on PyPI](https://pypi.org/project/pyautoplot/%s/#security)\n' \
"$GITHUB_REF_NAME" >> "$GITHUB_STEP_SUMMARY"
27 changes: 27 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Tests

on:
pull_request:
push:
branches: [main]

permissions:
contents: read

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.10', '3.14']
env:
MPLBACKEND: Agg
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
with:
python-version: ${{ matrix.python-version }}
- run: python -m pip install .
- run: python -m unittest discover -s tests -v
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
__pycache__
*.pyc
*.egg-info/
dist/
build/
test_output/
venv/
.venv/
.venv/
33 changes: 30 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,14 @@ Thank you for considering contributing to **PyAutoPlot**! Contributions, whether
Ensure you have Python 3.6+ installed. You should also install compatible versions of the necessary dependencies for the project.

3. **Run Tests**
Before making changes, run tests to confirm that everything works.
Install the package and run the headless regression suite:

> [!TIP]
> We sometimes include testing scripts in our projects for easy testing.
```bash
python -m pip install .
python -m unittest discover -s tests -v
```

`python test.py` is a separate smoke example using the included energy dataset.

## How to Contribute

Expand All @@ -33,6 +37,29 @@ Thank you for considering contributing to **PyAutoPlot**! Contributions, whether
- Submit a pull request with a detailed explanation of what you've changed or added.
- Ensure your PR passes all automated tests and adheres to the contribution guidelines.

## Publishing a release

In the [`pyautoplot` project's publishing settings](https://pypi.org/manage/project/pyautoplot/settings/publishing/), add a **GitHub** Trusted Publisher with these values:

| PyPI field | Value |
| --- | --- |
| Owner | `Infinitode` |
| Repository name | `PyAutoPlot` |
| Workflow name | `build_and_publish.yml` |
| Environment name | Leave blank |

The workflow does not use a GitHub environment or a PyPI API token. Because there is no environment approval step, limit GitHub write access to trusted maintainers and restrict who can create or modify release tags.

1. Update the version in `setup.py` and the release notes in `README.md`. Merge the release changes into `main` after CI passes.
2. On the merged release commit, create and push a matching numeric tag (no `v` prefix). For 1.1.1:

```bash
git tag 1.1.1
git push origin refs/tags/1.1.1
```

3. The **Publish to PyPI** workflow checks the tag against the built version and runs the regression suite against the wheel before publishing the wheel and source distribution. After publishing, follow the link in the workflow summary or the README's **PyPI provenance** badge to the **Security** tab on PyPI. Check that both files have a PyPI Publish attestation. Prior releases without attestations will not gain them retroactively.

## Community Guidelines

To maintain a positive and collaborative community, we ask that all contributors adhere to the following principles:
Expand Down
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,16 @@
![Downloads](https://pepy.tech/badge/pyautoplot)
![License Compliance](https://img.shields.io/badge/license-compliance-brightgreen.svg)
![PyPI Version](https://img.shields.io/pypi/v/pyautoplot)
[![PyPI provenance](https://img.shields.io/badge/PyPI%20provenance-view-blue?logo=pypi)](https://pypi.org/project/pyautoplot/#security)

PyAutoPlot is an open-source Python library designed to make dataset analysis much easier by generating helpful detailed plots using `matplotlib`. It automatically generates appropriate plots based on the dataset you feed it.

### Changes in version 1.1.1:
- Fixed date detection and reports for sparse or mixed-format timestamps. Time plots use sorted timestamps as the x-axis for numeric measurements.
- Fixed analysis and plotting for empty columns and header-only CSVs, and made JSON exports handle non-finite numbers.
- Fixed partial themes and `dpi`/`bins` handling. Plots and reports no longer close figures they didn't create, and `show=False` supports file-only plotting.
- Added regression tests and prepared releases for PyPI Trusted Publishing with per-file attestations. The provenance badge links to the latest release's provenance status on PyPI.

### Changes in version 1.1.0:
1. **New Visualizations**: Added Correlation Heatmaps and Violin Plots.
2. **Data Cleanup**: New `cleanup()` method allows filling or dropping missing values with multiple strategies.
Expand Down Expand Up @@ -89,10 +96,15 @@ from pyautoplot import AutoPlot
# Initialize with a CSV file
plotter = AutoPlot("path/to/dataset.csv")

# Automatically analyze and plot
plotter.auto_plot(output_file='test', theme="dark", color='orange', excludes=['detailed_analysis'])
# Save charts without opening plot windows
plotter.auto_plot(
output_file="charts.png", theme="dark", color="orange",
excludes=["pairwise_scatter"], show=False, dpi=150, bins=20,
)
```

Date-like text columns are converted only if all their non-missing values parse. Offset-aware timestamps are normalized to UTC. When numeric measurements are present, line charts use the sorted timestamps as the x-axis; the area chart uses the first plottable date column and switches to an unstacked chart if a series has both positive and negative values.

> [!NOTE]
> PyAutoPlot may not work well with certain datasets. If you find any issues please open an issue.

Expand Down
Loading
Loading