Skip to main content

A library with utils for performing Skolemization on blank nodes (RDF)

Project description

Tests codecov PyPI Read the Docs

skolemizer

A library with utils for performing Skolemization on blank nodes (RDF)

W3C has a short intro to skolemization here: https://www.w3.org/2011/rdf-wg/wiki/Skolemisation

Development

Requirements

% pipx install poetry==1.1.6
% pipx install nox==2020.12.31
% pipx inject nox nox-poetry

Install

% git clone https://github.com/Informasjonsforvaltning/skolemizer.git
% cd skolemizer
% pyenv install 3.9.4
% pyenv local 3.9.4
% poetry install

Getting started

Remember before starting to always set the baseurl for skolemization, according to your organization url. This can be done by setting the environment variable skolemizer_baseurl on your operating system. It can also e.g. be done run time through Python's os package:

os.environ[Skolemizer.baseurl_key] = "https://www.someorganiztion.somedomain/"

If not set Skolemizer will use "http://example.com/" as base url. In order to invoke the skolemizer for ensuring identifier of rdf-nodes simply add

from skolemizer import Skolemizer

and then before rdf-serialization of a class:

        if not getattr(self, "identifier", None):
            self.identifier = Skolemizer.add_skolemization()

There should also be a skolemization check performed when serializing object properties. When creating unit tests of skolemized rdf nodes an uuid will be applied as a substring of the complete skolemization. Therefore, in order to create stable unit tests one can use the tests utils in order to mock a stable skolemization.

E.g. pytest-mocks MockFixture permits mocking of the skolemizer:

    from pytest_mock import MockFixture
    from skolemizer.testutils import skolemization

    catalog = Catalog()

    mocker.patch(
        "skolemizer.Skolemizer.add_skolemization",
        return_value=skolemization
    )

which outputs e.g:

        @prefix dct: <http://purl.org/dc/terms/> .
        @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
        @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
        @prefix dcat: <http://www.w3.org/ns/dcat#> .

        <http://wwww.digdir.no/.well-known/skolem/284db4d2-80c2-11eb-82c3-83e80baa2f94>
         a dcat:Catalog  .

Run all sessions

% nox

Run all tests with coverage reporting

% nox -rs tests

Debugging

You can enter into Pdb by passing --pdb to pytest:

nox -rs tests -- --pdb

You can set breakpoints directly in code by using the function breakpoint().

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

skolemizer-2.1.3.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

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

skolemizer-2.1.3-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file skolemizer-2.1.3.tar.gz.

File metadata

  • Download URL: skolemizer-2.1.3.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.12.13 Linux/6.17.0-1018-azure

File hashes

Hashes for skolemizer-2.1.3.tar.gz
Algorithm Hash digest
SHA256 bbebcc442383c40c9652424a1048de3b4733e009f5d5ce15c9d5561c0ca01b52
MD5 83a36057466d005022ff77394dc50f0a
BLAKE2b-256 13b23b65e69ce8c1c2340a3d67956c16936aa0e69b61bdfa7ddc223b7c244f31

See more details on using hashes here.

File details

Details for the file skolemizer-2.1.3-py3-none-any.whl.

File metadata

  • Download URL: skolemizer-2.1.3-py3-none-any.whl
  • Upload date:
  • Size: 8.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.12.13 Linux/6.17.0-1018-azure

File hashes

Hashes for skolemizer-2.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 e863de3132453207627a423284e79cc8d0b8a1f12730c6cc34e203e68cc2e7fa
MD5 77a5e9f7ff8692afbcfac47f9e22eff5
BLAKE2b-256 4c4b1cc385904baff34f20ad4fe0ce9fda9908596447a4e9ae67564fbea23a7c

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