Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

orderflow

A minimal Python package demonstrating the six-file structure described in
"Your Python Script Is Not a Package. Here's the Six-File Fix."

This package processes orders from CSV: validates schema, filters by minimum
value, optionally normalizes currency, and writes results.


Package structure

orderflow/
    __init__.py     # public API
    models.py       # Order dataclass
    io.py           # CSV read / write
    transform.py    # pure filter and normalize functions
    validate.py     # schema validation, raises ValidationError
    cli.py          # click CLI entry point
tests/
    conftest.py
    test_io.py
    test_transform.py
    test_validate.py
pyproject.toml
README.md

Installation

# install in editable mode for development
pip install -e ".[dev]"
C:\Users\sainathudata\Git\orderflow>pip install -e ".[dev]"
Obtaining file:///C:/Users/saina/Documents/DataScience/Git/orderflow
  Installing build dependencies ... done
  Checking if build backend supports build_editable ... done
  Getting requirements to build editable ... done
  Installing backend dependencies ... done
  Preparing editable metadata (pyproject.toml) ... done
Requirement already satisfied: click>=8.0 in c:\users\saina\miniconda3\lib\site-packages (from orderflow==0.1.0) (8.3.1)
Requirement already satisfied: pandas>=2.0 in c:\users\saina\miniconda3\lib\site-packages (from orderflow==0.1.0) (2.3.2)
Collecting pytest-cov>=4.0 (from orderflow==0.1.0)
  Downloading pytest_cov-7.1.0-py3-none-any.whl.metadata (32 kB)
Collecting pytest>=7.0 (from orderflow==0.1.0)
  Downloading pytest-9.0.3-py3-none-any.whl.metadata (7.6 kB)
Requirement already satisfied: colorama in c:\users\saina\miniconda3\lib\site-packages (from click>=8.0->orderflow==0.1.0) (0.4.6)
Requirement already satisfied: numpy>=1.26.0 in c:\users\saina\miniconda3\lib\site-packages (from pandas>=2.0->orderflow==0.1.0) (2.2.6)
Requirement already satisfied: python-dateutil>=2.8.2 in c:\users\saina\miniconda3\lib\site-packages (from pandas>=2.0->orderflow==0.1.0) (2.9.0.post0)
Requirement already satisfied: pytz>=2020.1 in c:\users\saina\miniconda3\lib\site-packages (from pandas>=2.0->orderflow==0.1.0) (2025.2)
Requirement already satisfied: tzdata>=2022.7 in c:\users\saina\miniconda3\lib\site-packages (from pandas>=2.0->orderflow==0.1.0) (2025.2)
Collecting iniconfig>=1.0.1 (from pytest>=7.0->orderflow==0.1.0)
  Downloading iniconfig-2.3.0-py3-none-any.whl.metadata (2.5 kB)
Requirement already satisfied: packaging>=22 in c:\users\saina\miniconda3\lib\site-packages (from pytest>=7.0->orderflow==0.1.0) (25.0)
Requirement already satisfied: pluggy<2,>=1.5 in c:\users\saina\miniconda3\lib\site-packages (from pytest>=7.0->orderflow==0.1.0) (1.5.0)
Requirement already satisfied: pygments>=2.7.2 in c:\users\saina\miniconda3\lib\site-packages (from pytest>=7.0->orderflow==0.1.0) (2.19.1)
Collecting coverage>=7.10.6 (from coverage[toml]>=7.10.6->pytest-cov>=4.0->orderflow==0.1.0)
  Downloading coverage-7.13.5-cp313-cp313-win_amd64.whl.metadata (8.7 kB)
Requirement already satisfied: six>=1.5 in c:\users\saina\miniconda3\lib\site-packages (from python-dateutil>=2.8.2->pandas>=2.0->orderflow==0.1.0) (1.17.0)
Downloading pytest-9.0.3-py3-none-any.whl (375 kB)
Downloading iniconfig-2.3.0-py3-none-any.whl (7.5 kB)
Downloading pytest_cov-7.1.0-py3-none-any.whl (22 kB)
Downloading coverage-7.13.5-cp313-cp313-win_amd64.whl (222 kB)
Building wheels for collected packages: orderflow
  Building editable for orderflow (pyproject.toml) ... done
  Created wheel for orderflow: filename=orderflow-0.1.0-py3-none-any.whl size=2311 sha256=5a430b698123e0582731d9dd050dcc64a56aca3032b1de80e136222804afd578
  Stored in directory: C:\Users\saina\AppData\Local\Temp\pip-ephem-wheel-cache-emsz0co7\wheels\4f\9f\0e\a1c68e048aba53a5be6b7e11e21361063edf1e0eea1abb953c
Successfully built orderflow
Installing collected packages: iniconfig, coverage, pytest, pytest-cov, orderflow
Successfully installed coverage-7.13.5 iniconfig-2.3.0 orderflow-0.1.0 pytest-9.0.3 pytest-cov-7.1.0

[notice] A new release of pip is available: 25.2 -> 26.1
[notice] To update, run: python.exe -m pip install --upgrade pip

C:\Users\sainathudata\Git\orderflow>

CLI usage

# basic: filter and write
orderflow sample_orders.csv --min-value 10.0 --output filtered.csv

# with currency normalization
orderflow sample_orders.csv --min-value 10.0 --normalize-to USD --output normalized.csv

# help
orderflow --help

Expected input CSV columns: order_id, customer_id, amount, currency,
created_at (ISO-8601: YYYY-MM-DDTHH:MM:SS), region (optional).

Supported currencies: USD, GBP, EUR, CAD.

C:\Users\sainathudata\Git\orderflow>orderflow --help
Usage: orderflow [OPTIONS] FILEPATH

  Process an orders CSV file: validate, filter, optionally normalize, and
  write results.

  FILEPATH is the path to the input CSV file.

Options:
  --min-value FLOAT               Exclude orders below this amount (in source
                                  currency).  [default: 0.0]
  --normalize-to [USD|GBP|EUR|CAD]
                                  Convert all amounts to this currency before
                                  writing output.
  --output TEXT                   Path for the output CSV file.  [default:
                                  out.csv]
  --help                          Show this message and exit.


C:\Users\sainathudata\Git\orderflow>orderflow sample_orders.csv --min-value 10.0 --output filtered.csv          
Loading orders from sample_orders.csv ...
  Loaded 5 orders.
  After filter (>= 10.0): 3 orders.
Done. Wrote 3 orders to filtered.csv.

C:\Users\sainathudata\Git\orderflow>orderflow sample_orders.csv --min-value 10.0 --normalize-to USD --output normalized.csv
Loading orders from sample_orders.csv ...
  Loaded 5 orders.
  After filter (>= 10.0): 3 orders.
  Normalized to USD.
Done. Wrote 3 orders to normalized.csv.

Python API

from orderflow import load_orders, validate_schema, filter_by_min_value, normalize_currency, write_orders

orders = load_orders("orders.csv")
validate_schema(orders)                                    # raises ValidationError on failure
filtered = filter_by_min_value(orders, min_value=10.0)
normalized = normalize_currency(filtered, target_currency="USD")
write_orders(normalized, "out.csv")

Running tests

pytest
# with coverage
pytest --cov=orderflow --cov-report=term-missing
C:\Users\sainathudata\Git\orderflow>pytest --cov=orderflow --cov-report=term-missing
================================================================================================ test session starts ================================================================================================
platform win32 -- Python 3.13.0, pytest-9.0.3, pluggy-1.5.0
rootdir: C:\Users\saina\Documents\DataScience\Git\orderflow
configfile: pyproject.toml
testpaths: tests
plugins: anyio-4.12.0, cov-7.1.0
collected 30 items                                                                                                                                                                                                   

tests\test_io.py ..........                                                                                                                                                                                    [ 33%]
tests\test_transform.py ............                                                                                                                                                                           [ 73%]
tests\test_validate.py ........                                                                                                                                                                                [100%]

================================================================================================== tests coverage ===================================================================================================
__________________________________________________________________________________ coverage: platform win32, python 3.13.0-final-0 __________________________________________________________________________________

Name                     Stmts   Miss  Cover   Missing
------------------------------------------------------
orderflow\__init__.py        5      0   100%
orderflow\cli.py            27     27     0%   2-56
orderflow\io.py             24      0   100%
orderflow\models.py         11      0   100%
orderflow\transform.py      13      0   100%
orderflow\validate.py       18      1    94%   25
------------------------------------------------------
TOTAL                       98     28    71%
================================================================================================ 30 passed in 0.57s =================================================================================================

C:\Users\sainathudata\Git\orderflow>

Sample input CSV

order_id,customer_id,amount,currency,created_at,region
ORD-001,C-100,49.99,USD,2024-01-15T09:00:00,NA
ORD-002,C-101,5.00,USD,2024-01-15T10:00:00,
ORD-003,C-102,120.00,GBP,2024-01-15T11:00:00,EU

About

Your Python Script Is Not a Package.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages