Skip to main content

A library for managing DCAT metadata using Apache Atlas

Project description

atlasdcat

Tests codecov PyPI Read the Docs

A Python library for mapping Apache Atlas Glossary terms to DCAT metadata and vice versa.

Specification the Norwegian Application Profile of the DCAT standard.

Notice This library is part of the DCAT for Apache Atlas lifecycle and not a complete solution. The complete lifecycle contains the following actions:

  • Create glossary
  • Add dataset descriptions by using atlasdcat mapper (this library)
  • Assign dataset description glossary terms to entities (actual datasets)
  • Fetch glossary terms as DCAT catalog in RDF format (this library)

Usage

Install

% pip install atlasdcat

Getting started

Setup mapper

# Example...
from atlasdcat import AtlasDcatMapper, AtlasGlossaryClient
from pyapacheatlas.auth import BasicAuthentication

atlas_auth = BasicAuthentication(username="dummy", password="dummy")
atlas_client = AtlasGlossaryClient(
    endpoint_url="http://atlas", authentication=atlas_auth
)

mapper = AtlasDcatMapper(
    glossary_client=atlas_client,
    glossary_id="myglossary",
    catalog_uri="https://domain/catalog",
    catalog_language="http://publications.europa.eu/resource/authority/language/NOB",
    catalog_title="Catalog",
    catalog_publisher="https://domain/publisher",
    dataset_uri_template="http://domain/datasets/{guid}",
    distribution_uri_template="http://domain/distributions/{guid}",
    language="nb",
)

Map glossary terms to DCAT Catalog RDF resource

try:
    mapper.fetch_glossary()
    catalog = mapper.map_glossary_terms_to_dataset_catalog()
    print(catalog.to_rdf())
except Exception as e:
    print(f"An exception occurred: {e}")

Map DCAT Catalog RDF resource to glossary terms

catalog = Catalog()
catalog.identifier = "http://catalog-uri"
catalog.title = {"nb": "mytitle"}
catalog.publisher = "http://publisher"
catalog.language = ["nb"]
catalog.license = ""

dataset = Dataset()
dataset.title = {"nb": "Dataset"}
dataset.description = {"nb": "Dataset description"}
catalog.datasets = [dataset]

try:
    mapper.fetch_glossary()
    mapper.map_dataset_catalog_to_glossary_terms(catalog)
    mapper.save_glossary_terms()
except Exception as e:
    print(f"An exception occurred: {e}")

For an example of usage of this library in a simple server, see example.

Development

Requirements

% pip install poetry==1.1.13
% pip install nox==2022.1.7
% pip inject nox nox-poetry==1.0.0

Install developer tools

% git clone https://github.com/Informasjonsforvaltning/atlasdcat.git
% cd atlasdcat
% pyenv install 3.8.12
% pyenv install 3.9.10
% pyenv install 3.10.
% pyenv local 3.8.12 3.9.10 3.10.
% poetry install

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

atlasdcat-1.2.0.tar.gz (15.6 kB view details)

Uploaded Source

Built Distribution

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

atlasdcat-1.2.0-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

File details

Details for the file atlasdcat-1.2.0.tar.gz.

File metadata

  • Download URL: atlasdcat-1.2.0.tar.gz
  • Upload date:
  • Size: 15.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.3 CPython/3.12.13 Linux/6.17.0-1008-azure

File hashes

Hashes for atlasdcat-1.2.0.tar.gz
Algorithm Hash digest
SHA256 2fdd8a1403d22ea909844ad884979b752ebd5ffeda93b4513c107e74beca37fb
MD5 9033dfc9b30af5273f1726cf60c070aa
BLAKE2b-256 fd304a46d9c0a0b10e8d51ce691ba9080b742bf17bcddfcb2baf4f5f4b078804

See more details on using hashes here.

File details

Details for the file atlasdcat-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: atlasdcat-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 15.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.3 CPython/3.12.13 Linux/6.17.0-1008-azure

File hashes

Hashes for atlasdcat-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 53677f73c06405abb2b7bba27fbd559cc85713f7d55a31bc05fa46ae8637cc1e
MD5 4af640957ede1747e077041bb92b21e9
BLAKE2b-256 db3602b33c9809ea2c98533256def79ef137271724f1303e439a8ecbeac8bd2c

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