Skip to content

Commit

Permalink
build: docs and CI
Browse files Browse the repository at this point in the history
  • Loading branch information
lmmx committed Jul 16, 2024
1 parent 81097d9 commit 9b8facb
Show file tree
Hide file tree
Showing 9 changed files with 260 additions and 2 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: CI

on: [push, pull_request]

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.12]

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .[dev]
- name: Run tests
run: pytest
- name: Run type checking
run: mypy src/pypdown

lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .[dev]
- name: Run linters
run: |
black --check .
isort --check .
flake8 .
47 changes: 47 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,51 @@

A Pydantic model-based approach to data pipelining with file I/O linting.

[![PyPI version](https://badge.fury.io/py/pypdown.svg)](https://badge.fury.io/py/pypdown)
[![Python Versions](https://img.shields.io/pypi/pyversions/pypdown.svg)](https://pypi.org/project/pypdown/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Documentation Status](https://readthedocs.org/projects/pypdown/badge/?version=latest)](https://pypdown.readthedocs.io/en/latest/?badge=latest)
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/lmmx/pypdown/master.svg)](https://results.pre-commit.ci/latest/github/lmmx/pypdown/master)

## Features

- Pydantic model-based approach to data pipelining
- File I/O linting for robust pipeline execution
- Easy-to-use API for defining and running pipeline steps

## Installation

```bash
pip install pypdown
```

## Quick Start

```python
from pypdown import run_step
from pypdown.models import Step

# Define your pipeline tasks
tasks = [
(["input.txt"], ["output.txt"]),
(["output.txt"], ["final.txt"]),
]

# Create a Step
step = Step(name="My Pipeline", tasks=[{"src": s, "dst": d} for s, d in tasks])

# Run the step
run_step(step)
```

## Documentation

For full documentation, please visit [pypdown.readthedocs.io](https://pypdown.readthedocs.io).

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
36 changes: 36 additions & 0 deletions docs/api_reference.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# API Reference

## `pypdown.models`

### `Task`

```python
class Task(BaseModel):
src: list[Path]
dst: list[Path]
```

Represents a task with input (`src`) and output (`dst`) files.

### `Step`

```python
class Step(BaseModel):
name: str
tasks: list[Task]
```

Represents a named step in a data pipeline, consisting of multiple tasks.

## `pypdown.run`

### `run_step`

```python
def run_step(step: Step):
...
```

Executes a pipeline step, checking for file existence and running tasks accordingly.

For more detailed information on each component, please refer to the source code and inline documentation.
11 changes: 11 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Welcome to pypdown

pypdown is a Pydantic model-based approach to data pipelining with file I/O linting.

## Features

- Pydantic model-based approach to data pipelining
- File I/O linting for robust pipeline execution
- Easy-to-use API for defining and running pipeline steps

Check out the [Usage](usage.md) section to get started with pypdown.
34 changes: 34 additions & 0 deletions docs/usage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Usage

## Basic Example

Here's a simple example of how to use pypdown:

```python
from pypdown import run_step
from pypdown.models import Step

# Define your pipeline tasks
tasks = [
(["input.txt"], ["output.txt"]),
(["output.txt"], ["final.txt"]),
]

# Create a Step
step = Step(name="My Pipeline", tasks=[{"src": s, "dst": d} for s, d in tasks])

# Run the step
run_step(step)
```

This will create a pipeline that reads from `input.txt`, processes it to create `output.txt`, and then processes `output.txt` to create `final.txt`.

## Defining Tasks

Tasks are defined as tuples of input and output files. The first element of the tuple is a list of input files, and the second element is a list of output files.

## Running Steps

Use the `run_step` function to execute a pipeline step. This function will check for the existence of input files and the non-existence of output files before running each task.

For more advanced usage, please refer to the [API Reference](api_reference.md).
66 changes: 64 additions & 2 deletions pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,8 @@ license = {text = "MIT"}

[tool.pdm]
distribution = true

[tool.pdm.dev-dependencies]
tests = [
"pytest>=8.2.2",
]
2 changes: 2 additions & 0 deletions tests/package_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def test_package():
import pypdown
18 changes: 18 additions & 0 deletions vercel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
site_name: pypdown
theme:
name: material
palette:
primary: blue
accent: light blue
repo_name: lmmx/pypdown
repo_url: https://github.com/lmmx/pypdown
nav:
- Home: index.md
- Usage: usage.md
- API Reference: api_reference.md
markdown_extensions:
- pymdownx.highlight:
anchor_linenums: true
- pymdownx.inlinehilite
- pymdownx.snippets
- pymdownx.superfences

0 comments on commit 9b8facb

Please sign in to comment.