Skip to main content

A lightweight Python script to convert PROV-JSON documents to PROV-JSONLD format according to the W3C PROV-JSONLD specification.

Project description

HPCI Lab Logo

prov2ld

A lightweight Python script to convert PROV-JSON documents to PROV-JSONLD format according to the W3C PROV-JSONLD specification.
Report Bug · Request Feature


Contributors Forks Stars Issues GPLv3 License

Requirements

For the ld2viz command, the library requires the GraphViz suite. For everything to correctly work, this module has to be installed. We reference both the installation section on their docs, as well as the main ways to install it.

Linux

sudo apt install graphviz

MacOS

# Installing Homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

brew install graphviz

Windows

Installers are at the Download page of GraphViz.

Installation

pip install prov2ld

Basic Usage

1. Convert a file to Prov-JSONLD

python -m prov2ld input.json output.jsonld
# Basic example from the PROV-PRIMER
python -m prov2ld example/test_comprehensive.json example/test_comprehensive.jsonld

2. Convert Prov-JSONLD to Graph Visualization

python -m ld2viz input.jsonld output.png
# Or: 
python -m prov2ld example/test_comprehensive.jsonld example/test_comprehensive.png

What Gets Converted?

Input (PROV-JSON)

{
  "prefix": {
    "ex": "http://example.org/",
    "prov": "http://www.w3.org/ns/prov#"
  },
  "entity": {
    "ex:e1": {}
  },
  "activity": {
    "ex:a1": {}
  },
  "wasGeneratedBy": {
    "_:gen1": {
      "prov:entity": "ex:e1",
      "prov:activity": "ex:a1"
    }
  }
}

Output (PROV-JSONLD)

{
  "@context": [
    {
      "ex": "http://example.org/",
      "prov": "http://www.w3.org/ns/prov#"
    },
    "https://openprovenance.org/prov-jsonld/context.json"
  ],
  "@graph": [
    {
      "@type": "prov:Entity",
      "@id": "ex:e1"
    },
    {
      "@type": "prov:Activity",
      "@id": "ex:a1"
    },
    {
      "@type": "prov:Generation",
      "@id": "_:gen1",
      "entity": "ex:e1",
      "activity": "ex:a1"
    }
  ]
}

PROV Elements Supported

Core Elements

  • Entities (prov:Entity)
  • Activities (prov:Activity)
  • Agents (prov:Agent)

Relations

  • Generation (prov:Generation) - wasGeneratedBy
  • Usage (prov:Usage) - used
  • Communication (prov:Communication) - wasInformedBy
  • Start (prov:Start) - wasStartedBy
  • End (prov:End) - wasEndedBy
  • Invalidation (prov:Invalidation) - wasInvalidatedBy
  • Derivation (prov:Derivation) - wasDerivedFrom
  • Attribution (prov:Attribution) - wasAttributedTo
  • Association (prov:Association) - wasAssociatedWith
  • Delegation (prov:Delegation) - actedOnBehalfOf
  • Influence (prov:Influence) - wasInfluencedBy
  • Specialization (provext:Specialization) - specializationOf
  • Alternate (provext:Alternate) - alternateOf
  • Membership (provext:Membership) - hadMember

Additional Features

  • Custom attributes with namespaces
  • Typed values
  • Language-tagged strings
  • Time attributes (startTime, endTime, time)
  • PROV bundles
  • Roles, types, labels, and locations

Support

This converter implements the PROV-JSONLD specification from: Moreau, L., & Huynh, T. D. (2021). The PROV-JSONLD Serialization

For questions about PROV itself, see:

Contributing

Contributions are welcome! Please feel free to submit issues or pull requests.

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

prov2ld-0.0.2.tar.gz (21.0 kB view details)

Uploaded Source

Built Distribution

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

prov2ld-0.0.2-py3-none-any.whl (21.9 kB view details)

Uploaded Python 3

File details

Details for the file prov2ld-0.0.2.tar.gz.

File metadata

  • Download URL: prov2ld-0.0.2.tar.gz
  • Upload date:
  • Size: 21.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for prov2ld-0.0.2.tar.gz
Algorithm Hash digest
SHA256 b1e76948ba9c5050756696d1eb5d5a0182f372a7a5878c9b0cc33ce91f5d99ba
MD5 750497a56fa7dcd4d4eb585cd06da95e
BLAKE2b-256 f952c5b8a03251418ff8b5b32ca897ad784a2ca25fd1dc48b1bbd0c95bf66dfc

See more details on using hashes here.

File details

Details for the file prov2ld-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: prov2ld-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 21.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for prov2ld-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9a203ae6a77d192ffb36eca85c3eb8e6946f97392aaf740d40ef9cee6052950f
MD5 12b1cef6e82e2fd0fdb9ff8e84b9911e
BLAKE2b-256 a6d0041d81f250799876b03648e711ac0dd297b4a0f05e4a63cee01d5caf65e7

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