Skip to main content

No project description provided

Project description

KGDD

KG Test Driven Design development. Write queries with expected results. CONSTRUCT KG. Run tests and see if queries return correct bindings.

screen-gif

Run tests

To run a testbed on a KG run:

kgdd -f "/path/to/KG.{ttl,nt,...}" -t "/path/to/tests.json"

Testbed

To create a testbed write a .json file like the following:

{
    "tests" : [
        {
            "description" : "Extract all the triples from a KG",
            "query" : "SELECT * WHERE {?s ?p ?o } ",
            "results" : 3,
            "rows": [{
                "s" : "artist_1"
            }            ],

            "bindings": {
                "o" : "music_1"
            },
            "skip": false
        }
        ...
    ]
}

Every item in the tests array will be used to run a test. Let's see fields:

  • query: The query to be run to extract data from KG.
  • results: The number of expected rows. With 0 or a value greater than 0 then the test will pass if the numbers match. With -1 the test will pass if you get a number greater than 0.
  • rows: Every item in the array is an expected row. For the test to pass you need at least a row matching all the expected ones. In this example we want at least a row with "artist_1" as "s".
  • bindings: At least a binding in at least a results row for all the specified variable in the bindings object should match for the test to pass. In this example At least in a "o" in one of the row should match "music_1".
  • skip: The test will be skipped.

In every field you can set null as default value if you don't want the results, rows, or bindings step to run. E.g. following testbed will run only results step.

{
    "tests" : [
        {
            "description" : "Extract all the triples from a KG",
            "query" : "SELECT * WHERE {?s ?p ?o } ",
            "results" : 3,
            "rows": null,
            "bindings": null,
            "skip": false
        }
        ...
    ]
}

Usage

usage: kgdd [-h] -t TEST -f FILE [-v {0,1,2}]

A cli program to automate TDD KG development. Define some basic query and expected outputs in a test. Kgdd will take
care of run queries and see if they match expedted results.

options:
  -h, --help            show this help message and exit
  -t TEST, --test TEST  Path to testbed file. File should be in Json format
  -f FILE, --file FILE  Path to KG file
  -v {0,1,2}, --verbose {0,1,2}
                        Verbose output. Verbosity level = 0,1,2 . Default 0 no verbose. 2 is really verbose

Installation

kgdd is a python package to install it you need python 3.X installed. You can install it globally in your local machine running:

pip install kgdd

or on Windows:

py -m pip install kgdd

Alternatively if you prefere a local installation you can create a virtualenv and install the package there. The package is distributed as a cli tool, and available everywhere if the environment where is installed is activated.

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

kgdd-0.1.1.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kgdd-0.1.1-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file kgdd-0.1.1.tar.gz.

File metadata

  • Download URL: kgdd-0.1.1.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

File hashes

Hashes for kgdd-0.1.1.tar.gz
Algorithm Hash digest
SHA256 fbede5a4b54b45466e89b9aa85edfbad72753c06db967d5524b5145bc1d263f4
MD5 784e77b42209dc979e9e568b79a77ad4
BLAKE2b-256 1e2ab02c6ce8b7233f7f1c17dc67dfd852615feb9b3f948a896d7b035f9cb28f

See more details on using hashes here.

File details

Details for the file kgdd-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: kgdd-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

File hashes

Hashes for kgdd-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 92b623f9ea7ac1cc034e56b35be18d5cc460a1bf84712fc5ab0d78eca230b0de
MD5 b9c12de91d35ee5c29e9c8bd82f52715
BLAKE2b-256 6bb1e6b7b5c1295d48ed032405fa263b6753539013853e5956b2816de4e37e3f

See more details on using hashes here.

Supported by

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