Skip to main content

Knockoff Factory

codecov Test PyPi Release Docker Build License Python Versions Docker Image Size Python Wheel

A library for generating mock data and creating database fixtures that can be used for unit testing.

Table of content

Installation

From PyPi:

pip install knockoff

# to install with PyMySQL 
pip install knockoff[mysql]
# Note: Other MySql DBAPI's can be used if installed and dialect provided in connection url

From GitHub:

pip install git+https://github.com/Nike-Inc/knockoff-factory#egg=knockoff

# to install with PyMySQL 
pip install git+https://github.com/Nike-Inc/knockoff-factory#egg=knockoff[mysql]
# Note: Other MySql DBAPI's can be used if installed and dialect provided in connection url

Changelog

See the changelog for a history of notable changes to knockoff.

Documentation

We are working on adding more documentation and examples!

Unit Tests

Prerequisites

  • docker
  • poetry (curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python)

Some of the unit tests depend on a database instance. Knockoff will create ephemeral databases within that instance and clean them up when tests have completed. By default it will attempt to connect to an existing instance at postgresql://postgres@localhost:5432/postgres and will create and destroy databases per test. This postgres location can be overridden with the KNOCKOFF_TEST_DB_URI environment variable.

If no external postgres instance is available for testing, but postgresql is installed, the TEST_USE_EXTERNAL_DB environment variable can be set to 0. The fixtures will then rely on the testing.postgresql library to create ephemeral postgres instances per fixture.

If postgres is not available, dependent tests can be disabled with the following: export TEST_POSTGRES_ENABLED=0.

Some tests also depend on a MySql database instance. These tests can be disabled with the following: export TEST_MYSQL_ENABLED=0.

Create the database instance using docker:

# Run postgres instance 
docker run --rm  --name pg-docker -e POSTGRES_HOST_AUTH_METHOD=trust -d -p 5432:5432  postgres:11.9

# Run mysql instance
docker run --name mysql-docker -e MYSQL_ALLOW_EMPTY_PASSWORD=yes -p 3306:3306 -d mysql:8.0.26

Install poetry:

# the -E flag is so we can run the mysql unit tests with the PyMySql DBAPI
poetry install -E mysql

Run unit test:

poetry run pytest

Future work

  • Further documentation and examples for SDK
  • Add yaml based configuration for SDK
  • Make extensible generic output for KnockffDB.insert (csv, parquet, etc)
  • Enable append option for KnockoffDB.insert
  • Autodiscover and populate all tables by using reflection and building dependency graph with foreign key relationships
  • Parallelize execution of dag. (e.g. https://ipython.org/ipython-doc/stable/parallel/dag_dependencies.html)

Metadata

Release files for knockoff 4.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for knockoff 4.4.1
File Size Uploaded
knockoff-4.4.1.tar.gz 36.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for knockoff 4.4.1
File Interpreter ABI Platform
knockoff-4.4.1-py3-none-any.whl Python 3 none any Details

Total release size: 93.4 kB

Release files / knockoff-4.4.1.tar.gz

Download URL knockoff-4.4.1.tar.gz
Size 36.2 kB
Tags Source
SHA-256 checksum
How to use checksums
ab361cf3c4025498dfc977cb365f15a049787e59ca0ec720da84745008866dac
BLAKE2b-256 checksum
How to use checksums
a204f377418fe3d8591f1c27b49eb21652eb5574e7a717cd89d3d2d6a946e157
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.4.1 CPython/3.10.13 Linux/6.2.0-1019-azure

Release files / knockoff-4.4.1-py3-none-any.whl

Download URL knockoff-4.4.1-py3-none-any.whl
Size 57.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ff1b147db22165dfebc52c29646c06fc23f898ea1da947ef1671d7fa5ae638fc
BLAKE2b-256 checksum
How to use checksums
b40469343595c40925bacdb9dc08367921fb82e8ba403857c8aacb87bf8d550a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.4.1 CPython/3.10.13 Linux/6.2.0-1019-azure

Release history Release notifications | RSS feed

This release

4.4.1 This release

2 release files

4.4.0

2 release files

4.3.2

2 release files

4.3.1

2 release files

4.3.0

2 release files

4.2.1

2 release files

4.1.1

2 release files

4.1.0

2 release files

4.0.0

2 release files

3.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page