Skip to main content

Data-quality framework

Project description

Contessa

|docs-badge| |build-badge| |pypi-badge| |license-badge|

.. |docs-badge| image:: https://readthedocs.org/projects/contessa/badge/?version=latest :target: https://contessa.readthedocs.io/en/latest/ .. |pypi-badge| image:: https://badge.fury.io/py/contessa.svg :target: https://pypi.org/project/contessa/ .. |build-badge| image:: https://travis-ci.org/kiwicom/contessa.svg?branch=master :target: https://travis-ci.org/kiwicom/contessa .. |license-badge| image:: https://img.shields.io/pypi/l/schemathesis.svg :target: https://opensource.org/licenses/MIT

Data Quality Framework

Quick Example

.. code-block:: python

from contessa import ContessaRunner, NOT_NULL, GT, SQL
no_bags_sql = """
    SELECT CASE WHEN is_no_bags_booking = 'T' AND bags > 0 THEN false ELSE true END
    FROM {{table_fullname}};
"""
contessa = ContessaRunner("postgres://:@localhost:5432")

RULES = [
    {
        "name": NOT_NULL,
        "columns": ["status", "market", "src", "dst"], 
    },
    {
        "name": GT,
        "value": 0,
        "columns": ["initial_price", "turnover_before_refunds", ],
    },
    {
        "name": SQL,
        "sql": no_bags_sql,
        "description": "No bags booking should have bags = 0",
    },
]
contessa.run(
    raw_rules=RULES,
    check_table={"schema_name": "public", "table_name": "bookings"},
    result_table={"schema_name": "dq", "table_name": "my_table"},
)

How to run tests

.. code-block:: bash

$ make test-up  # run postgres + app
$ make test args="/app/test -s"  # args for pytest
$ make test-down  # delete containers + volumes

In case of unit tests (you do not need db):

.. code-block:: bash

$ pytest test/unit/test_operator.py

How to add docs

.. code-block:: bash

$ pip3 install -r requirements-docs.txt
$ python3 watchdogs.py

It will make html files with sphinx and serve a local webserver so that you can check it out. It should also reload it :)

NOTE: If it doesn't work, build html manually. cd docs && make html

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

contessa-0.1.4.tar.gz (17.6 kB view hashes)

Uploaded Source

Built Distribution

contessa-0.1.4-py3-none-any.whl (24.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page