Skip to main content

Interact with Data Type Registries and Create Machine Actionable Data

Project description

dtreg

PyPI version Coverage Status

Python

The goal of dtreg is to help users interact with various data type registries (DTRs) and create machine-readable data. Currently, we support the ePIC and ORKG DTRs.

  • First, load a DTR schema (an ePIC datatype or an ORKG template) as a Python object.
  • Then, create a new instance of the schema by filling in the relevant fields.
  • Finally, write the instance as a machine-readable JSON-LD file.

Installation

## install from PyPi:
pip install dtreg

Example

This example shows you how to work with a DTR schema. You need to know the schema identifier; see the help page. For instance, the schema “data item” requires the ePIC datatype with the DOI https://doi.org/21.T11969/aff130c76e68ead3862e. For the ORKG, please use the ORKG template URL, such as https://orkg.org/template/R758316.

## import functions from the dtreg
from dtreg.load_datatype import load_datatype
from dtreg.to_jsonld import to_jsonld
## import pandas for a dataframe
import pandas as pd
## load the schema with the known identifier
dt = load_datatype("https://doi.org/21.T11969/aff130c76e68ead3862e")
## look at the schemata you might need to use
dt.__dict__.keys() 
## check available fields for your schema
dt.data_item.prop_list 
## create your instance by filling the fields of your choice
## see the help page to know more about the fields
my_label = "my results"
my_df = pd.DataFrame({'A': [1], 'B': [2]})
my_df.name = "dataframe_name"
url_1 = dt.url(label = "URL_1")
url_2 = dt.url(label = "URL_2")
my_inst = dt.data_item(label=my_label,
                       has_expression=[url_1, url_2],
                       source_table=my_df)
## write the instance in JSON-LD format as a string
my_json = to_jsonld(my_inst) 

## the result can be saved as a JSON file
with open('my_file.json', 'w') as f:
    f.write(my_json)

For more information, please see the help page.

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

dtreg-1.1.0.tar.gz (18.7 kB view details)

Uploaded Source

Built Distribution

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

dtreg-1.1.0-py3-none-any.whl (32.2 kB view details)

Uploaded Python 3

File details

Details for the file dtreg-1.1.0.tar.gz.

File metadata

  • Download URL: dtreg-1.1.0.tar.gz
  • Upload date:
  • Size: 18.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for dtreg-1.1.0.tar.gz
Algorithm Hash digest
SHA256 a96533b369e0940a51920ad12e0c9b57c04889161ca228935c3477a8bba73855
MD5 14fcd5e50021fad055fb3506d8e080d3
BLAKE2b-256 88e62e7127100b94ae16efc477dbc411afcb69106550d72ec0eb82b0519c3cbb

See more details on using hashes here.

Provenance

The following attestation bundles were made for dtreg-1.1.0.tar.gz:

Publisher: publish.yml on OlgaLezhnina/dtreg_py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dtreg-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: dtreg-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 32.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for dtreg-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 baede0d1aec26afcc0ccc695cc024303c0410239b0a4759e9592e75caae8e42c
MD5 0ab68c280fd90932032123d4916fc791
BLAKE2b-256 382afab1f5abfabea18d6b5fd92cfa1e685a4c11e39dbfd24164852cc52112aa

See more details on using hashes here.

Provenance

The following attestation bundles were made for dtreg-1.1.0-py3-none-any.whl:

Publisher: publish.yml on OlgaLezhnina/dtreg_py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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