Skip to main content

No project description provided

Project description

linkml-transformer

Status: pre-alpha code

See these slides

This repo contains both:

  • A data model for a model transformation language
  • A reference python implementation

The transformation language is specified in terms of LinkML schemas. It is intended to be a ployglot transformation language, used for specifying how to map data models independent of underlying representation (TSVs, JSON/YAML, RDF, SQL Database, ...).

Use cases include:

  • ETL and mapping from one data model to another
  • Database migrations (one version of a schema to another)
  • Creating "profiles"
  • Specifying mappings between different serializations of a model (e.g. OO to Relational)
  • Mapping between normalized/non-redundant forms and denormalized/query-optimized forms

Data Model

See generated docs

Running the code

linkml-tr --help
Usage: linkml-tr [OPTIONS] COMMAND [ARGS]...

  CLI for linkml-transformer.

Options:
  -v, --verbose
  -q, --quiet TEXT
  --help            Show this message and exit.

Commands:
  derive-schema  Derive a schema from a source schema and a mapping.
  map-data       Map data in a source schema using a transformation.

map-data

cd tests/input/examples/personinfo_basic
linkml-tr map-data -T transform/personinfo-to-agent.transform.yaml -s source/personinfo.yaml  data/Container-001.yaml

derive-schema

cd tests/input/examples/personinfo_basic
linkml-tr derive-schema -T transform/personinfo-to-agent.transform.yaml source/personinfo.yaml

Examples

See the tests folder for most up to date examples

Mapping between two similar data models

Given a source object

persons:
  - id: P:001
    name: fred bloggs
    primary_email: fred.bloggs@example.com
    age_in_years: 33
    has_familial_relationships:
      - type: SIBLING_OF
        related_to: P:002
    current_address:
      street: 1 oak street
    aliases:
      - a
      - b
    has_medical_history:
      - diagnosis:
          id: C:001
          name: c1
      - diagnosis:
          id: C:002
  - id: P:002
    name: Alison Wu
    has_familial_relationships:
      - type: SIBLING_OF
        related_to: P:001
    has_medical_history:
      - diagnosis:
          id: C:001
          name: c1 (renamed)
organizations:
  - id: ROR:1
    name: Acme

and a corresponding schema, consider the case of mapping to a largely isomorphic schema, with some minor differences:

  • class names are changes (e.g Person to Agent)
  • age is represented as a string, e.g. "33 years"
  • some fields are denormalized

The mapping may look like:

id: my-mappings
title: my mappings
prefixes:
  foo: foo
source_schema: s1
target_schema: s2
class_derivations:
  Container:
    populated_from: Container
    slot_derivations:
      agents:
        populated_from: persons
  Agent:
    populated_from: Person
    slot_derivations:
      
      ## implicitly same name in Agent
      id:

      label:
        populated_from: name

      age:
        expr: "str({age_in_years})+' years'"

      primary_email:

      gender:

      has_familial_relationships:
        populated_from: has_familial_relationships

  FamilialRelationship:
    populated_from: FamilialRelationship
    slot_derivations:
      type:
      related_to:

Deriving Schemas

Formally a mapping consists of a source schema S, a target schema T, and a mapping M.

In practice, any of these can be partially specified and derived from the others.

For example:

  • given S, and T, derive isomorphic mappings based on shared URIs
  • given S and M, derive T by applying M to the schema

See tests/test_mapper/test_schema_mapper.py for examples

Measurements TODO

- id: P:001
  height:
    value: 172.0
    unit: cm

<==>

- id: P:001
  height_in_cm: 172.0

<==>

- id: P:001
  height: "172.0 cm"

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

linkml_transformer-0.1.2.tar.gz (15.3 kB view details)

Uploaded Source

Built Distribution

linkml_transformer-0.1.2-py3-none-any.whl (20.9 kB view details)

Uploaded Python 3

File details

Details for the file linkml_transformer-0.1.2.tar.gz.

File metadata

  • Download URL: linkml_transformer-0.1.2.tar.gz
  • Upload date:
  • Size: 15.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.16

File hashes

Hashes for linkml_transformer-0.1.2.tar.gz
Algorithm Hash digest
SHA256 0ec4159e0bcf425dd75469eea73bbd95b8ca3fd26dd63ef7c2a70680dcf89b38
MD5 00cc2d2e27dce5b8ba4b103c31e0fa75
BLAKE2b-256 1af799e601b7b642d7314f12f7f338c0dc556a3ca9d8d4972dd24d53a77ea491

See more details on using hashes here.

File details

Details for the file linkml_transformer-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for linkml_transformer-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 fb3bedd91f76f0d1dabfb138c3801f2914773ca26ca1ed48c79dc1429d1eaae2
MD5 c14cb05e14592f8b4dae3a9bf905ad94
BLAKE2b-256 e5a0ddc0cf0e0ca09837bce8000b93247df430ad167fc06a6f3729c7b4a5110b

See more details on using hashes here.

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