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
40 changes: 21 additions & 19 deletions .github/workflows/pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,38 @@ jobs:
python-version: ["3.8", "3.13"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
python-version: ${{ matrix.python-version }}

- name: Install Requirements
run: pip install -r requirements/dev.txt
enable-cache: true
cache-dependency-glob: "uv.lock"
- name: Set up Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}
- name: Install dependencies
run: uv sync --extra dev
- name: Pylint
run: pylint dune_client/
run: uv run pylint dune_client/
- name: Black
run: black --check ./
run: uv run black --check ./
- name: Type Check (mypy)
run: mypy dune_client --strict
run: uv run mypy dune_client --strict
- name: Unit Tests
run: python -m pytest tests/unit
run: uv run python -m pytest tests/unit

e2e-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
python-version: 3.12

- name: Install Requirements
run:
pip install -r requirements/dev.txt
enable-cache: true
cache-dependency-glob: "uv.lock"
- name: Set up Python 3.13
run: uv python install 3.13
- name: Install dependencies
run: uv sync --extra dev
- name: End to End Tests
env:
DUNE_API_KEY: ${{ secrets.DUNE_API_KEY }}
run:
python -m pytest tests/e2e
run: uv run python -m pytest tests/e2e
15 changes: 7 additions & 8 deletions .github/workflows/py-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,14 @@ jobs:

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
enable-cache: true
cache-dependency-glob: "uv.lock"
- name: Set up Python
run: uv python install 3.13
- name: Build package
run: python -m build
run: uv build
- name: Publish a Python distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ dist
_version.py
.idea/
venv/
.venv/
tmp/
.vscode/
build/
Expand Down
24 changes: 11 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,34 +1,32 @@
VENV = .venv
PYTHON = $(VENV)/bin/python3
PIP = $(VENV)/bin/pip

# Install dependencies using uv
install:
uv sync

$(VENV)/bin/activate: requirements/dev.txt
python3 -m venv $(VENV)
$(PIP) install --upgrade pip
$(PIP) install -r requirements/dev.txt


install: $(VENV)/bin/activate
# Install with dev dependencies
install-dev:
uv sync --extra dev

clean:
rm -rf __pycache__

fmt:
black ./
uv run black ./

lint:
pylint dune_client/
uv run pylint dune_client/

types:
mypy dune_client/ --strict
uv run mypy dune_client/ --strict

check: fmt lint types

test-unit:
python -m pytest tests/unit
uv run python -m pytest tests/unit

test-e2e:
python -m pytest tests/e2e
uv run python -m pytest tests/e2e

test-all: test-unit test-e2e
65 changes: 59 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Python 3.11](https://img.shields.io/badge/python-3.11-blue.svg)](https://www.python.org/downloads/release/python-3102/)
[![Python 3.8+](https://img.shields.io/badge/python-3.8%2B-blue.svg)](https://www.python.org/downloads/)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![Build](https://github.com/duneanalytics/dune-client/actions/workflows/pull-request.yaml/badge.svg)](https://github.com/duneanalytics/dune-client/actions/workflows/pull-request.yaml)
Expand All @@ -10,19 +10,44 @@ service](https://docs.dune.com/api-reference/overview/introduction).

## Installation

Import as a project dependency
### Using pip

```shell
pip install dune-client
```

### Using uv (recommended)

[uv](https://docs.astral.sh/uv/) is a fast Python package and project manager written in Rust. It provides:
- ⚡ 10-100x faster dependency resolution
- 🔒 Reproducible builds with lockfiles
- 🐍 Automatic Python version management
- 📦 Zero-configuration virtual environments

Install uv first, then:

```shell
# Add to an existing project
uv add dune-client

# Or create a new project
uv init my-dune-project
cd my-dune-project
uv add dune-client
```

# Example Usage

## Quickstart: run_query

Export your `DUNE_API_KEY` (or place it in a `.env` file - as in
here [.env.sample](./.env.sample) and `source .env`).

> 💡 **Tip**: If using uv, you can run examples directly without activating a virtual environment:
> ```shell
> uv run python your_script.py
> ```

```python
from dune_client.types import QueryParameter
from dune_client.client import DuneClient
Expand Down Expand Up @@ -115,13 +140,41 @@ dune.make_public(query_id)

# Developer Usage & Deployment

## Makefile
This project's makefile comes equipped with sufficient commands for local development.
This project uses [uv](https://docs.astral.sh/uv/) for dependency management and development workflows.

### Installation
## Setup
```shell
# Clone the repository
git clone https://github.com/duneanalytics/dune-client.git
cd dune-client

# Install dependencies
uv sync --extra dev
```

## Development Commands
```shell
# Format code
uv run black ./

# Lint code
uv run pylint dune_client/

# Type checking
uv run mypy dune_client/ --strict

# Run tests
uv run python -m pytest tests/unit # Unit tests
uv run python -m pytest tests/e2e # E2E tests (requires DUNE_API_KEY)
```

## Makefile Shortcuts

### Installation
```shell
make install
make install # Uses uv sync
# or
make install-dev # Uses uv sync --extra dev
````

### Format, Lint & Types
Expand Down
68 changes: 59 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,62 @@
[build-system]
requires = [
"setuptools >= 48",
"setuptools_scm[toml] >= 6.2",
"setuptools_scm_git_archive",
"wheel >= 0.29.0",
requires = ["hatchling", "hatch-vcs"]
build-backend = "hatchling.build"

[project]
name = "dune_client"
description = "A simple framework for interacting with Dune Analytics official API service."
readme = "README.md"
requires-python = ">=3.8"
license = {text = "Apache License Version 2.0"}
authors = [
{name = "Benjamin H. Smith & Dune Analytics", email = "[email protected]"},
]
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
]
dependencies = [
"aiohttp~=3.10.0",
"dataclasses-json~=0.6.4",
"types-python-dateutil>=2.8.19.14",
"types-PyYAML>=6.0.12.11",
"types-requests>=2.28.0",
"types-setuptools>=68.2.0.0",
"python-dateutil~=2.8.2",
"requests~=2.31.0",
"ndjson~=0.3.1",
"Deprecated~=1.2.14",
"types-Deprecated>=1.2.9.3",
]
build-backend = 'setuptools.build_meta'
dynamic = ["version"]

[tool.setuptools_scm]
write_to = "_version.py"
git_describe_command = "git describe --dirty --tags --long --match v* --first-parent"
[project.urls]
Homepage = "https://github.com/duneanalytics/dune-client"
Repository = "https://github.com/duneanalytics/dune-client"
Issues = "https://github.com/duneanalytics/dune-client/issues"

[project.optional-dependencies]
dev = [
"black>=23.7.0",
"pandas>=1.0.0",
"pandas-stubs>=1.0.0",
"pylint>=2.17.5",
"pytest>=7.4.1",
"python-dotenv>=1.0.0",
"mypy>=1.5.1",
"aiounittest>=1.4.2",
"colorlover>=0.3.0",
"plotly>=5.9.0",
]

[tool.hatch.version]
source = "vcs"

[tool.hatch.build.targets.wheel]
packages = ["dune_client"]

[dependency-groups]
dev = [
"pyyaml>=6.0.2",
]
11 changes: 0 additions & 11 deletions requirements/dev.txt

This file was deleted.

11 changes: 0 additions & 11 deletions requirements/prod.txt

This file was deleted.

46 changes: 0 additions & 46 deletions setup.cfg

This file was deleted.

2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Legacy setup.py for backward compatibility
# All configuration is now in pyproject.toml
import setuptools

if __name__ == "__main__":
Expand Down
Loading