Skip to main content

Lightweight Python library for RO-Crate manipulation implemented in Rust

Project description

Overview

rocraters is a python library that is built upon a rust backend for interfacing with RO-Crates. This implementation was specifically created to address the challenges of data handling on automated robotic systems within an automated synthetic biology lab, however it's noted that this could have more general applicability to other environments.

It's aim is to provide a robust, portable and scalable solution to dealing with RO-Crates within the varying software environments of a synthetic biology lab stack. It's designed to be maximally flexible with minimal onboarding, allowing you to incorprate it into scrpits/ data pipelines as easily as possible. This also relies on you to have an understanding of the structure of an RO-Crate, but focuses more on the fact that some metadata is better than no metadata.

This is not the go-to python libary for RO-Crate interfacing, please see ro-crate-py for a full python implementation.

Build

Built using PyO3 and maturin. Recommended to setup python venv, then install maturin (and remember maturin[patchelf])

Installation

pip install -i https://test.pypi.org/simple/ rocraters

Basic usage

The RO-Crate specification defines an RO-Crate as a JSON-LD file, consisting of a context and a graph. As such, in python it is a dictionary containing a "context" key, with some form of vocab context (default is the RO-Crate context) and a "graph" key, which contains a list of json objects (dictionaries).

To create an empty RO-Crate, you need to do the following:

from rocraters import PyRoCrateContext, PyRoCrate

# Define context 
context = PyRoCrateContext.from_string(" https://w3id.org/ro/crate/1.1/context")

# Initialise empty crate 
crate = PyRoCrate(context)

# For an easy start, you can make a default crate!
default_crate = PyRoCrate.new_default()

Now, there are 4 primary objects (dictionaries) that can be added to the crate:

  1. Metadata descriptor (only 1 per crate)
  2. Root data entity (only 1 per crate)
  3. Data entity (zero - many)
  4. Contextual entity (zero - many)

These are all based upon the specification.

To populate the basic crate, with the essential keys to conform to specification:

# Continuation of the above examples 
# Metadata descriptor 
descriptor = {
        "type": "CreativeWork",
        "id": "ro-crate-metadata.json",
        "conformsTo": {"id": "https://w3id.org/ro/crate/1.1"},
        "about": {"id": "./"}
}
# Root data entity 
root =  {
    "id": "./",
    "type": "Dataset",
    "datePublished": "2017",
    "license": {"id": "https://creativecommons.org/licenses/by-nc-sa/3.0/au/"}
}
# Data entity 
data = {
    "id": "data_file.txt",
    "type": "Dataset"
}
# Contextual entity 
contextual = {
    "id": "#JohnDoe",
    "type": "Person",
}

# Update the RO-Crate object 
crate.update_descriptor(descriptor)
crate.update_root(root)
crate.update_data(data)
crate.update_contextual(contextual)

To then write the crate to a ro-crate-metadata.json file in the current working directory:

# Continuation of the above examples
# Write crate 
crate.write()

To then read a ro-crate-metadata.json file and load it in as a structured object:

# New example
from rocraters import read

# Read RO-Crate at specified path 
crate = read("ro-crate-metadata.json", True)

To zip the folder and all contained directories within the ro-crate-metadata.json directory:

# new example 
from rocraters import zip

zip("ro-crate-metadata.json", True)

Modifying a RO-Crate

As per the libraries purpose, modification, ie the deletion, update and addition of entites is intended to be as simple as possible, whilst ensuring minimal conformance:

# Example based upon previously made crate
from rocraters import read

crate = read("ro-crate-metadata.json", True) 

# Update the data entity and make modification 
data_target = crate.get_entity("data_file.txt")
data_target["description"] = "A text file dataset containing information"

# Update the contextual entity and make modification
contextual_target = crate.get_entity("#JohnDoe")
contextual_target.update({"id" : "#JaneDoe"})
crate.update_contextual(contextual_target)

# To delete a key:value 
data_target.pop("description")

# To delete an entity - this immediately updates the crate object
contextual_target.delete_entity("#JaneDoe")

# We then update the crate the same way we make it
# The ID will be used to serach the crate and overwrites the object with an indentical "id" key
crate.update_data(data_target)
crate.write()

Custom compilation

PyO3 is used to handle python bindings. Maturin is used as the build tool.

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

rocraters-0.4.2.tar.gz (241.3 kB view details)

Uploaded Source

Built Distributions

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

rocraters-0.4.2-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.0 MB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

rocraters-0.4.2-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.whl (1.1 MB view details)

Uploaded PyPymanylinux: glibc 2.5+ i686

rocraters-0.4.2-cp312-none-win_amd64.whl (771.4 kB view details)

Uploaded CPython 3.12Windows x86-64

rocraters-0.4.2-cp312-none-win32.whl (737.7 kB view details)

Uploaded CPython 3.12Windows x86

rocraters-0.4.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

rocraters-0.4.2-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl (1.1 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.5+ i686

rocraters-0.4.2-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (1.8 MB view details)

Uploaded CPython 3.12macOS 10.12+ universal2 (ARM64, x86-64)macOS 10.12+ x86-64macOS 11.0+ ARM64

rocraters-0.4.2-cp311-none-win_amd64.whl (769.8 kB view details)

Uploaded CPython 3.11Windows x86-64

rocraters-0.4.2-cp311-none-win32.whl (736.8 kB view details)

Uploaded CPython 3.11Windows x86

rocraters-0.4.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

rocraters-0.4.2-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl (1.1 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.5+ i686

rocraters-0.4.2-cp311-cp311-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (1.8 MB view details)

Uploaded CPython 3.11macOS 10.12+ universal2 (ARM64, x86-64)macOS 10.12+ x86-64macOS 11.0+ ARM64

rocraters-0.4.2-cp310-none-win_amd64.whl (769.8 kB view details)

Uploaded CPython 3.10Windows x86-64

rocraters-0.4.2-cp310-none-win32.whl (737.2 kB view details)

Uploaded CPython 3.10Windows x86

rocraters-0.4.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

rocraters-0.4.2-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.whl (1.1 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.5+ i686

rocraters-0.4.2-cp310-cp310-macosx_11_0_arm64.whl (850.4 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

rocraters-0.4.2-cp310-cp310-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (1.8 MB view details)

Uploaded CPython 3.10macOS 10.12+ universal2 (ARM64, x86-64)macOS 10.12+ x86-64macOS 11.0+ ARM64

File details

Details for the file rocraters-0.4.2.tar.gz.

File metadata

  • Download URL: rocraters-0.4.2.tar.gz
  • Upload date:
  • Size: 241.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.7.4

File hashes

Hashes for rocraters-0.4.2.tar.gz
Algorithm Hash digest
SHA256 ded193f621a86e13b8b4e59e9139847d1d83dbfa4a7f481266a79983a37f8665
MD5 844c5a2feef61cd8b7306faf4f68d0bc
BLAKE2b-256 b982bcacd8152191a3d0af8161eeb28198a0a0808a0e0d4377dfb1cf8fb3acc8

See more details on using hashes here.

File details

Details for the file rocraters-0.4.2-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rocraters-0.4.2-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d6b4b1d7564e0948b79ddbd06f05fc20ec3b03158a800200c22fb7bfb4543e73
MD5 1cfb91817fd9eafa7d1e2267c07a1486
BLAKE2b-256 12c11a73fb62b226337cc8437a27e1851052b4bec5fe1eaafff3db8139971402

See more details on using hashes here.

File details

Details for the file rocraters-0.4.2-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.whl.

File metadata

File hashes

Hashes for rocraters-0.4.2-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 e069af06c71b5f61e6a280387b3ac85878ef9bc0f780f915ca1c164ce6c02275
MD5 4ec226f47dfd51f1edb1fb95e2a17488
BLAKE2b-256 b1bc87d028b6c80106c0975a68629201417145c1029a4c41b634f29d4d744f68

See more details on using hashes here.

File details

Details for the file rocraters-0.4.2-cp312-none-win_amd64.whl.

File metadata

File hashes

Hashes for rocraters-0.4.2-cp312-none-win_amd64.whl
Algorithm Hash digest
SHA256 9100eb5f5b0d3958fd3832a8422360fd0954a92e259270da0e57db581f8e87b3
MD5 6eb7ae8aaa5a8d8cb940abd2aa2bc32f
BLAKE2b-256 977bc0c86665e5817e5c62d6ca4201986d63e414a19ccde26edcc9ca7126f548

See more details on using hashes here.

File details

Details for the file rocraters-0.4.2-cp312-none-win32.whl.

File metadata

  • Download URL: rocraters-0.4.2-cp312-none-win32.whl
  • Upload date:
  • Size: 737.7 kB
  • Tags: CPython 3.12, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.7.4

File hashes

Hashes for rocraters-0.4.2-cp312-none-win32.whl
Algorithm Hash digest
SHA256 e121a0a16d4075d31c7c987a141951948775cac0d9bfc4fcc476797e88cfb87a
MD5 1b4a7875f8ef382328cfdca726688a47
BLAKE2b-256 9a1ffe8971847d4564a9dbd91fddc16b1200ea06851dd512e74acb3fca3998b2

See more details on using hashes here.

File details

Details for the file rocraters-0.4.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rocraters-0.4.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f18b2d455237000012d34d04e5f34619009bcfb033b02e29b3e9f9605643be74
MD5 ecfe48c40389290a9d7ca4148f8756af
BLAKE2b-256 52a63e26bdbec2e42dd6f19b219f8a8e4f4ba9c4778f67ec9eab0cc13cd77660

See more details on using hashes here.

File details

Details for the file rocraters-0.4.2-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl.

File metadata

File hashes

Hashes for rocraters-0.4.2-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 b4243d3414bb7f0bb9c113491daa21a8449672c0b066c7dfe22afe6c5b94d263
MD5 72d590d0d113346baf4696a8ba04a09f
BLAKE2b-256 56d3451f207201d7bd0f07b0bbb5f335ae3e13340e14cc17756aea07183b9879

See more details on using hashes here.

File details

Details for the file rocraters-0.4.2-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl.

File metadata

File hashes

Hashes for rocraters-0.4.2-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 b6a301a9b3f7be070a9d52d72d247b09c4a8e59401a943dd3c256a3abfd5177b
MD5 5e0a599e9ad0362b7a10fb09f7c50c93
BLAKE2b-256 049630a066fae34589f63efd31b9f053583aa6d7c456c2c56a9437af3fbe9df2

See more details on using hashes here.

File details

Details for the file rocraters-0.4.2-cp311-none-win_amd64.whl.

File metadata

File hashes

Hashes for rocraters-0.4.2-cp311-none-win_amd64.whl
Algorithm Hash digest
SHA256 66bb23e8e946f998fa10f4e1df77d8018cb7118e818d02b7cb56e1cc9df56504
MD5 4380325ae87ad49fea7f358cb35f34ab
BLAKE2b-256 89a99ba4315ada4085f3f91f7ee47222825e7ea37ab7ea6824c7eafb18c944ec

See more details on using hashes here.

File details

Details for the file rocraters-0.4.2-cp311-none-win32.whl.

File metadata

  • Download URL: rocraters-0.4.2-cp311-none-win32.whl
  • Upload date:
  • Size: 736.8 kB
  • Tags: CPython 3.11, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.7.4

File hashes

Hashes for rocraters-0.4.2-cp311-none-win32.whl
Algorithm Hash digest
SHA256 6c51554e07d1fbe593e2f0bd65fd655bc6d06817b22296a48e6e989c07f172a1
MD5 2c6ed048082a61ea6d9efc1a5855cf4a
BLAKE2b-256 20eac886c4b49e8f4cfbf1075fb6bbba5a77230969502157e3ea6c092247b78e

See more details on using hashes here.

File details

Details for the file rocraters-0.4.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rocraters-0.4.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d13e6e588a1083bdef62fddacb936def39f1a1a81da09abbe1faacfd8799a1d4
MD5 aed3c5772a845b4d0b90a61340ebd2f7
BLAKE2b-256 afff53b00f7305b7a3285784937abebda1ce578e182bb59b75839d082696150f

See more details on using hashes here.

File details

Details for the file rocraters-0.4.2-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl.

File metadata

File hashes

Hashes for rocraters-0.4.2-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 e2b56858074f2853131c4f8294b02ed9abe4fd19e31655549b6142ee7a554ec7
MD5 ffda6154eac3caf252cfe0763c62893d
BLAKE2b-256 2e1ef3d52ee65a601bbc18b60f9a8317c2871bf3cfd609e87bc0c682a5e4f540

See more details on using hashes here.

File details

Details for the file rocraters-0.4.2-cp311-cp311-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl.

File metadata

File hashes

Hashes for rocraters-0.4.2-cp311-cp311-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 100a739d40770b1dbbc6b88dd414c5479d7df35ab203b4286d03584adfae0d5f
MD5 020ce1dac417ad760b90be27ed385886
BLAKE2b-256 84fbccfd40b71cb274be5eb3e596d43445f4547e35e92668bc07711859d86a1d

See more details on using hashes here.

File details

Details for the file rocraters-0.4.2-cp310-none-win_amd64.whl.

File metadata

File hashes

Hashes for rocraters-0.4.2-cp310-none-win_amd64.whl
Algorithm Hash digest
SHA256 4fb04f93a1b2df026bceda9f92f9959e1f2d47cc74c7160d333709a022f9aa27
MD5 3a53bf177e35fba4561edb024075438e
BLAKE2b-256 b891470301fc9f26597d41384004c545756117e95304c01d54b6800c46331847

See more details on using hashes here.

File details

Details for the file rocraters-0.4.2-cp310-none-win32.whl.

File metadata

  • Download URL: rocraters-0.4.2-cp310-none-win32.whl
  • Upload date:
  • Size: 737.2 kB
  • Tags: CPython 3.10, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.7.4

File hashes

Hashes for rocraters-0.4.2-cp310-none-win32.whl
Algorithm Hash digest
SHA256 26dcbb8608a590458f2d4c1b560b11fe182efb98ea43da4cc5c4c564a4638362
MD5 7ac93010fd1d3fc534c6d17f08610178
BLAKE2b-256 844f6db30cf65d08e5c499062b76d342f007bee01f614f62161900d283f5b2ce

See more details on using hashes here.

File details

Details for the file rocraters-0.4.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rocraters-0.4.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 627764429d98daf77a32d431f3209a7671c6df4b685cc368a0a8b154de78ca93
MD5 df78c8f3bc7e769fd71bb476354c2047
BLAKE2b-256 a9f1028b179b9c614ca7e089cf87380e43783558d400ad079c7d800131b0650c

See more details on using hashes here.

File details

Details for the file rocraters-0.4.2-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.whl.

File metadata

File hashes

Hashes for rocraters-0.4.2-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 c7ed253143ef74b38ebf41beb61b86e530eb195d7995c6c0e8ed91566491a73f
MD5 a907349ba393972cc619e48fa4d8d207
BLAKE2b-256 a86095ffb386b636bfa5ecb96cb8deb97cefab1055e6ea962b1dd8640b3cb27c

See more details on using hashes here.

File details

Details for the file rocraters-0.4.2-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rocraters-0.4.2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 28b1f854fad872bafd0a0462a21cdcc22fefae386964edbd7475876ae23fcdad
MD5 10890660e55eea8d81dc56df26869ae0
BLAKE2b-256 13353fbd65a0b4b77e49d91e50f023aacaf0eda67e50489dabef51bb35e2e263

See more details on using hashes here.

File details

Details for the file rocraters-0.4.2-cp310-cp310-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl.

File metadata

File hashes

Hashes for rocraters-0.4.2-cp310-cp310-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 21bb79f47ed281c889c29c8a451287d6b9af35a9464c9bfe62f876d7b582bef0
MD5 f88b7e6bd6fd66c648b68ddd24c910bc
BLAKE2b-256 b6353df41f3c9754917526fb92fca4a0abde704ba3a327f26642832cf8713f2c

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