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.0.tar.gz (291.7 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.0-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.0-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.whl (1.0 MB view details)

Uploaded PyPymanylinux: glibc 2.5+ i686

rocraters-0.4.0-cp312-none-win_amd64.whl (766.6 kB view details)

Uploaded CPython 3.12Windows x86-64

rocraters-0.4.0-cp312-none-win32.whl (725.7 kB view details)

Uploaded CPython 3.12Windows x86

rocraters-0.4.0-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.0-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.0-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.0-cp311-none-win_amd64.whl (764.8 kB view details)

Uploaded CPython 3.11Windows x86-64

rocraters-0.4.0-cp311-none-win32.whl (724.8 kB view details)

Uploaded CPython 3.11Windows x86

rocraters-0.4.0-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.0-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl (1.0 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.5+ i686

rocraters-0.4.0-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.0-cp310-none-win_amd64.whl (765.0 kB view details)

Uploaded CPython 3.10Windows x86-64

rocraters-0.4.0-cp310-none-win32.whl (725.4 kB view details)

Uploaded CPython 3.10Windows x86

rocraters-0.4.0-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.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.whl (1.0 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.5+ i686

rocraters-0.4.0-cp310-cp310-macosx_11_0_arm64.whl (848.0 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

rocraters-0.4.0-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.0.tar.gz.

File metadata

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

File hashes

Hashes for rocraters-0.4.0.tar.gz
Algorithm Hash digest
SHA256 9966ce8166c3d3e1e45dac8fff0402dd77152004ddc81e8bce6c4d7c84b2f291
MD5 8fbd8ac7d97bdf9f150fbc9446675164
BLAKE2b-256 04b2581a1f40cd4feba49cd82ff22f7ceeb0d7a5efbedad37c565d5bea8cede4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rocraters-0.4.0-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6f0f638dd6a28c25917dfc3d07b4c7d93bb675041e7f48395d9c399e1be579e9
MD5 caada54a024f72d1a06d74a238e9409e
BLAKE2b-256 86940e21fe3451a2dbbd8cf651dd6666560c069b19dd5fb352f03dd5d04b81c3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rocraters-0.4.0-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 e51aa5b48a021ae38d7bec80169e4405722a1ad852cd2919a202728e37efb487
MD5 46b61338d1c443464a35ac0c52183e7c
BLAKE2b-256 f88033f4487f24d0c3e051abe463265e3d327d36832793eb339073bac529befe

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rocraters-0.4.0-cp312-none-win_amd64.whl
Algorithm Hash digest
SHA256 ab620f6f919ea8e6503bd13577709a00bde8e19bd2c705ae9c33fa4c262baeae
MD5 8d48e3c723669db05c48611a1f8b58f2
BLAKE2b-256 f64c1d155202f65b6cd2f1d3906ba615d2428cabea04c6da00ef9b5e9a30eab0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rocraters-0.4.0-cp312-none-win32.whl
  • Upload date:
  • Size: 725.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.0-cp312-none-win32.whl
Algorithm Hash digest
SHA256 6363771a74b672ea00b933a66b181990af3f62467532e940880e3eb10403ca7b
MD5 fc810863c78636c5c317d398fd4bed1a
BLAKE2b-256 0bc8465438e16e0390b28a08c40d996724fd9e4c34a3c306284960d3c1d8847f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rocraters-0.4.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 44a811db1d2d771660599338bfa7f405b7c664b4483570d8659677be0126abab
MD5 d0604e227929d48cb0a731665112710e
BLAKE2b-256 1dd27ddb2c355484166ac4d3502b8dc3597c65a226f9d0519640dceb756ac85c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rocraters-0.4.0-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 7ae679561f84443c6be99279ceaa6b49ccdedf74c8155449037b4fe2aa1183ca
MD5 120f2a592a98d7b9ab24241b34387ff1
BLAKE2b-256 b4c18eb8f766223fec1097da37613c212eb5588c53f8dacdccd44f8537d1a29d

See more details on using hashes here.

File details

Details for the file rocraters-0.4.0-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.0-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 dfdc01586af441655e0e7cce1539f6a8b0ed5b723f13bf504f6eebbb2bbe49b7
MD5 cb11153e223b77c44b780be9b9c0a4a2
BLAKE2b-256 2695c631216a1e7e3f4b441faedddd688b8f8f5271e53d1e40af2c8e428c8e22

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rocraters-0.4.0-cp311-none-win_amd64.whl
Algorithm Hash digest
SHA256 8893e147a877965f242474516ea38a2dbfe8b0020f2b0b9baf09c0200e0996c8
MD5 d223fd357745fb763f0b1f4089d20f5b
BLAKE2b-256 edd2e6e799c3be3044c6d8e4fdc2c9ba61ac9431e5f7d470e38a9e983fcbcd75

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rocraters-0.4.0-cp311-none-win32.whl
  • Upload date:
  • Size: 724.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.0-cp311-none-win32.whl
Algorithm Hash digest
SHA256 8754de7f2ef810b4be4d7ddda445c1c5bee7fdaf74384a26e765de76b8c69374
MD5 2d1dd418612aa3ec23a5dae1f2ae2ce4
BLAKE2b-256 077a66ec9d51dfc829e972813d7176cf50505d4535f6db9139be0f99978b73c2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rocraters-0.4.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e188b91540449a4b12e59004c8f032cec72b46c04de521806aaa8f216bab25a0
MD5 bcbf6a4fbc05237df479251a729b2465
BLAKE2b-256 57702b1de3b56ca45a7aadefd5fda5d9310f68b58933f60367ef556e0c554f47

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rocraters-0.4.0-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 36d9b2a7636d70b55e6a84393e3bd7e35efbd5abe01115b1a1f1878ca8ab7a6e
MD5 d46dc68f5a1a5a7463884c0e290047b8
BLAKE2b-256 9e5217e708bd241b3f1f70207438d371f5f7d9388ef87e439d8d0a06c741948c

See more details on using hashes here.

File details

Details for the file rocraters-0.4.0-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.0-cp311-cp311-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 2ab5f12e476a54f3b152408384d83220d9a0ac58915e67d99ba2a61fd618e4c9
MD5 1b9f4e4a2151b43368cf8fd83fbf9525
BLAKE2b-256 c9497349cd0a545a50262ad3570c5e52c82ad23c3e0f0bdfa6b1a9014a6f5be7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rocraters-0.4.0-cp310-none-win_amd64.whl
Algorithm Hash digest
SHA256 423465f98bd3d2bd0c5c4f5404e001adda313646fe13f52c00fcb6b336a421d7
MD5 22a07a8348df82b11241a3537ff8e89d
BLAKE2b-256 76b94772584a9892e280125be49bfdd6ce78644e3ea2c77b7e53c39a4ca409f8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rocraters-0.4.0-cp310-none-win32.whl
  • Upload date:
  • Size: 725.4 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.0-cp310-none-win32.whl
Algorithm Hash digest
SHA256 170564d469895335561cab506e1797f1415899ad129569acc025c8af37175bc6
MD5 6a8fbcc623261f223fd07d36ebaa8548
BLAKE2b-256 8c6dbb6849ea06bd17416bc7556d6f751b130a25f67287bc5598169dbc6dbe14

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rocraters-0.4.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 499aaa9dc0519404f29139ffe10877ef05e032aa714b370b05336ad62c943df1
MD5 6db8193e0d77d70ba776e74d86ea2db6
BLAKE2b-256 056e0f8362dfeaf6b246b82014da0b763b86952b896dbbdce85cb17313256551

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rocraters-0.4.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 1df4e1c3190ad117d8268627cdcbc37e945a67b163ac1c4fa89f9bf0d5cce21c
MD5 670e9d39fe9cdb44feafbfcddc27d9b0
BLAKE2b-256 e3970e56084f0fc8858bf4e8e6a5660a10f323a1931d46f875c8eb01b132c226

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rocraters-0.4.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f8dcd3fca10c7fd1f37cbb6e7594391b4afbaa1a7285621ef3e5b4a8c85bd8fd
MD5 93bdf8557a21d5d1448bb080ab6df6fb
BLAKE2b-256 fd8f7f5fdafdfeb2795b0830fb62c44daebd3d557056d72b9b5c953ddfc6b650

See more details on using hashes here.

File details

Details for the file rocraters-0.4.0-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.0-cp310-cp310-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 6a0eccc014644a78aa1825cca7392ea171e73aa4308c40062994e7f53a773d13
MD5 6655fb4013f3c0ee10dc11803e7dcd3d
BLAKE2b-256 9ba9cd43ba6de8807f391c45eb61721c9f55bbc25560b025b0da4a5f5dfb490f

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