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
39 changes: 24 additions & 15 deletions .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,28 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'

- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[test]"
pip install flake8
uv sync --extra test --extra dev

- name: Lint with flake8
run: |
# Stop the build if there are Python syntax errors or undefined names
flake8 plotsense --count --select=E9,F63,F7,F82 --show-source --statistics
uv run flake8 plotsense --count --select=E9,F63,F7,F82 --show-source --statistics
# Exit-zero treats all errors as warnings
flake8 plotsense --count --exit-zero --max-complexity=10 --max-line-length=150 --statistics
uv run flake8 plotsense --count --exit-zero --max-complexity=10 --max-line-length=150 --statistics

- name: Run tests with coverage
env:
GROQ_API_KEY: ${{ secrets.GROQ_API_KEY }}
run: |
pytest test/ -v --cov=plotsense --cov-report=xml --cov-report=term-missing
uv run pytest test/ -v --cov=plotsense --cov-report=xml --cov-report=term-missing

- name: Upload coverage to Codecov
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11'
Expand All @@ -63,16 +65,19 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip'

- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[test]"
uv sync --extra test

- name: Run unit tests only (fast)
run: |
pytest test/ -v -m "not slow" --tb=short
uv run pytest test/ -v -m "not slow" --tb=short

lint:
name: Code Quality
Expand All @@ -85,15 +90,19 @@ jobs:
with:
python-version: '3.11'

- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true

- name: Install linting tools
run: |
python -m pip install --upgrade pip
pip install flake8 autopep8
uv sync --extra dev

- name: Check code formatting
run: |
flake8 plotsense --count --max-line-length=150 --statistics
uv run flake8 plotsense --count --max-line-length=150 --statistics

- name: Check test code quality
run: |
flake8 test --count --max-line-length=150 --statistics --extend-ignore=F401,F811
uv run flake8 test --count --max-line-length=150 --statistics --extend-ignore=F401,F811
137 changes: 125 additions & 12 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ Be respectful and inclusive. We're all here to learn and build something great t

## Getting Started

> **💡 Tip**: We recommend using [uv](https://docs.astral.sh/uv/) for dependency management. It's 10-100x faster than pip and provides better dependency resolution. All commands below show both uv and pip options.

### 1. Fork and Clone

```bash
Expand All @@ -33,6 +35,28 @@ cd PlotSenseAI

**Python Backend:**

**Using uv (Recommended - 10-100x faster):**

```bash
# Install uv if not already installed
# Visit https://docs.astral.sh/uv/getting-started/installation/
# Or run: curl -LsSf https://astral.sh/uv/install.sh | sh

# Sync all dependencies including dev extras
uv sync --all-extras

# Activate the virtual environment
# Windows:
.venv\Scripts\activate
# macOS/Linux:
source .venv/bin/activate

# Install pre-commit hooks
uv run pre-commit install
```

**Using pip (Traditional):**

```bash
# Create virtual environment
python -m venv venv
Expand All @@ -46,6 +70,9 @@ source venv/bin/activate
# Install in editable mode with dev dependencies
pip install -e .
pip install pytest pytest-cov pytest-mock flake8 autopep8 pre-commit bandit

# Install pre-commit hooks
pre-commit install
```

**Frontend (Optional):**
Expand All @@ -55,16 +82,7 @@ cd web
npm install
```

### 3. Install Pre-commit Hooks

```bash
pip install pre-commit
pre-commit install
```

This will automatically run linting and formatting checks before each commit.

### 4. Set Up API Keys
### 3. Set Up API Keys

```bash
# Create a .env file
Expand Down Expand Up @@ -185,6 +203,28 @@ export function Component({ title, onAction }: Props) {

#### Running Tests

**Using uv:**

```bash
# Run all tests
uv run pytest

# Run with coverage
uv run pytest --cov=plotsense --cov-report=html

# Run specific test file
uv run pytest test/test_plotgen.py

# Run specific test
uv run pytest test/test_plotgen.py::TestPlotFunctions::test_create_scatter

# Run by marker
uv run pytest -m unit # Unit tests only
uv run pytest -m "not slow" # Skip slow tests
```

**Using pip/pytest directly:**

```bash
# Run all tests
pytest
Expand Down Expand Up @@ -286,6 +326,30 @@ describe('YourComponent', () => {

Before committing, ensure:

**Using uv:**

```bash
# Pre-commit hooks pass
uv run pre-commit run --all-files

# Python linting
uv run flake8 plotsense

# Python security
uv run bandit -r plotsense

# Tests pass
uv run pytest -v

# Frontend (if applicable)
cd web
npm run lint
npx tsc --noEmit
npm test
```

**Using pip:**

```bash
# Pre-commit hooks pass
pre-commit run --all-files
Expand Down Expand Up @@ -429,10 +493,22 @@ Use the question template for:

### Running Specific Tests During Development

**Using uv:**

```bash
# Watch mode - reruns on file changes
pytest --watch
# Stop on first failure
uv run pytest -x

# Show print statements
uv run pytest -s

# Verbose output
uv run pytest -vv
```

**Using pip:**

```bash
# Stop on first failure
pytest -x

Expand All @@ -445,6 +521,18 @@ pytest -vv

### Debugging Tests

**Using uv:**

```bash
# Drop into debugger on failure
uv run pytest --pdb

# Show local variables
uv run pytest -l
```

**Using pip:**

```bash
# Drop into debugger on failure
pytest --pdb
Expand All @@ -455,6 +543,19 @@ pytest -l

### Code Coverage

**Using uv:**

```bash
# Generate HTML coverage report
uv run pytest --cov=plotsense --cov-report=html
# Open htmlcov/index.html in browser

# Show missing lines
uv run pytest --cov=plotsense --cov-report=term-missing
```

**Using pip:**

```bash
# Generate HTML coverage report
pytest --cov=plotsense --cov-report=html
Expand All @@ -466,6 +567,18 @@ pytest --cov=plotsense --cov-report=term-missing

### Linting Auto-fix

**Using uv:**

```bash
# Auto-fix Python formatting issues
uv run autopep8 --in-place --recursive plotsense/

# Auto-fix frontend issues
cd web && npm run lint -- --fix
```

**Using pip:**

```bash
# Auto-fix Python formatting issues
autopep8 --in-place --recursive plotsense/
Expand Down
46 changes: 45 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,16 @@ Let AI supercharge your EDA (Exploratory Data Analysis).

### 🔧 Install the package

Using pip:
```bash
pip install plotsense
```

Using uv (recommended for faster installation):
```bash
uv pip install plotsense
```

### 🧠 Import PlotSense:

```bash
Expand Down Expand Up @@ -185,6 +191,28 @@ For detailed testing documentation, see [TESTING.md](TESTING.md).

### Setting Up Development Environment

Using uv (recommended):
```bash
# Install uv if not already installed
# Visit https://docs.astral.sh/uv/getting-started/installation/

# Sync all dependencies including dev extras
uv sync --all-extras

# Activate the virtual environment
# On Windows:
.venv\Scripts\activate
# On Unix or macOS:
source .venv/bin/activate

# Install frontend dependencies
cd web && npm install

# Install pre-commit hooks (optional but recommended)
uv run pre-commit install
```

Using pip (traditional):
```bash
# Install Python dependencies
pip install -e .
Expand All @@ -206,14 +234,24 @@ We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) f

1. **Fork and clone** the repository
2. **Set up development environment:**

Using uv (recommended):
```bash
# Install uv: https://docs.astral.sh/uv/getting-started/installation/
uv sync --all-extras
source .venv/bin/activate # On Windows: .venv\Scripts\activate
uv run pre-commit install
```

Using pip:
```bash
pip install -e .
pip install pytest pytest-cov pytest-mock pre-commit
pre-commit install
```
3. **Create a feature branch:** `git checkout -b feature/your-feature`
4. **Make changes and add tests**
5. **Run tests:** `pytest` and `cd web && npm test`
5. **Run tests:** `uv run pytest` (or `pytest`) and `cd web && npm test`
6. **Submit a Pull Request**

### Branching Strategy
Expand All @@ -238,10 +276,16 @@ We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) f
- PlotSense customised notebook template

### 📥 Install or Update
Using pip:
``` bash
pip install --upgrade plotsense # Get the latest features!
```

Using uv:
``` bash
uv pip install --upgrade plotsense # Get the latest features faster!
```

## 👥 Maintainers

PlotSense is maintained by a dedicated team of developers and data scientists:
Expand Down
Binary file modified plotsense/__pycache__/__init__.cpython-313.pyc
Binary file not shown.
2 changes: 1 addition & 1 deletion plotsense/explanations/explanations.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def __init__(
def _validate_keys(self):
"""Validate that required API keys are present"""
service_links = {
'groq': '👉 https://console.groq.com/keys 👈'
'groq': 'https://console.groq.com/keys'
}

for service in ['groq']:
Expand Down
2 changes: 1 addition & 1 deletion plotsense/visual_suggestion/suggestions.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def __init__(self,
def _validate_keys(self):
"""Validate that required API keys are present"""
service_links = {
'groq': 'https://console.groq.com/keys '
'groq': 'https://console.groq.com/keys'
}

for service in ['groq']:
Expand Down
Loading