Skip to content

For discussion: A basic python embedded examples #107

@matentzn

Description

@matentzn
# /// script
# requires-python = ">=3.10"
# dependencies = [
#   "linkml-transformer",   # pretend we’re using LinkML tooling
#   "pyyaml"
# ]
# [tool.mapping-metadata]
# id = "https://mapping-commons.github.io/rda-fair-mappings/example/personinfo.transform.yml"
# title = "PersonInfo to Agent example transformation"
# source_schema = "https://mapping-commons.github.io/rda-fair-mappings/example/personinfo.schema.yml"
# target_schema = "https://mapping-commons.github.io/rda-fair-mappings/example/personinfo.transform.yml"
# prefixes.sssom = "https://w3id.org/sssom/"
# prefixes.semapv = "https://w3id.org/semapv/vocab/"
# mapping_method = "semapv:ManualMappingCuration"
# mapping_tool_version = "0.3.8"
# license = "https://creativecommons.org/licenses/by/4.0/"
# creator_id = ["https://orcid.org/0000-0002-7356-1779"]
# author_id = ["https://orcid.org/0000-0002-7356-1779"]
# publication_date = "2025-08-14"
# ///

import json

# Example: input in "PersonInfo" schema style
personinfo = {
    "given_name": "Ada",
    "family_name": "Lovelace",
    "age": 36,
    "height_in_cm": 165
}

# Simple transformation logic (stand-in for LinkML transformer)
agent = {
    "id": "agent:1",
    "type": "Agent",
    "full_name": f"{personinfo['given_name']} {personinfo['family_name']}",
    "age": personinfo["age"],
    "height_in_m": round(personinfo["height_in_cm"] / 100.0, 2)
}

print(json.dumps(agent, indent=2))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions