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 “inferential test output” requires the ePIC datatype with the DOI https://doi.org/21.T11969/74bc7748b8cd520908bc. For the ORKG, please use the ORKG template URL, such as https://incubating.orkg.org/template/R855534.

## 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/74bc7748b8cd520908bc")
## look at the schemata you might need to use
dt.__dict__.keys() 
## check available fields for your schema
dt.inferential_test_output.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.inferential_test_output(label = my_label,
                                     has_description = [url_1, url_2],
                                     has_format = 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.0.0.tar.gz (17.3 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.0.0-py3-none-any.whl (22.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for dtreg-1.0.0.tar.gz
Algorithm Hash digest
SHA256 e9ef13ab43a624d7326fe8f984b439c808fd4692477698dbafe82944c5f6f15e
MD5 cbfca4c99f2a657c901e56161c91ab75
BLAKE2b-256 39f376f93c92824860fd63bca0c20fbc30102508c5e8e0b390932ea8165b4721

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for dtreg-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e9e97fe633c627d54569939cf5659884451f54cc08da4d16194695c9e43b3f2b
MD5 fbb254e5b48a32ef22409dab23cb3529
BLAKE2b-256 37362a25773aebfb392e04a50566880280a267fb680aa8a5b6cc19d70a553b78

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