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

Uploaded PyPymanylinux: glibc 2.5+ i686

rocraters-0.3.0-cp312-none-win_amd64.whl (763.5 kB view details)

Uploaded CPython 3.12Windows x86-64

rocraters-0.3.0-cp312-none-win32.whl (723.3 kB view details)

Uploaded CPython 3.12Windows x86

rocraters-0.3.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.3.0-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl (1.0 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.5+ i686

rocraters-0.3.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.3.0-cp311-none-win_amd64.whl (761.5 kB view details)

Uploaded CPython 3.11Windows x86-64

rocraters-0.3.0-cp311-none-win32.whl (722.7 kB view details)

Uploaded CPython 3.11Windows x86

rocraters-0.3.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.3.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.3.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.3.0-cp310-none-win_amd64.whl (761.6 kB view details)

Uploaded CPython 3.10Windows x86-64

rocraters-0.3.0-cp310-none-win32.whl (723.1 kB view details)

Uploaded CPython 3.10Windows x86

rocraters-0.3.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.3.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.3.0-cp310-cp310-macosx_11_0_arm64.whl (847.2 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

rocraters-0.3.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.3.0.tar.gz.

File metadata

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

File hashes

Hashes for rocraters-0.3.0.tar.gz
Algorithm Hash digest
SHA256 315d34bae676e4bbacadf69923ca6215c20eba579113d71eef7df39fa426dbdb
MD5 b0b17180a52d571a92e8138ac7ecf81a
BLAKE2b-256 57216275c2c4947fca15c64f6367c25a437ee25e6aae35ea6beb666bc5fc6b9a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rocraters-0.3.0-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 674b97f4ecbb9338c94c41f02ba0f8eb84f4ab8b436159a8f52d73e42f07a1e4
MD5 beaed3e3f69adedfe57fc338ecf215b4
BLAKE2b-256 45afb8c8940dd953a189341041028db79ef975ffc211a32df4ec8691c9ffc26b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rocraters-0.3.0-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 ca63a26b6fe9abbb9f35cc16ac286895e63ffbd348197639a610de63f68b6602
MD5 2250b77964046bbc872dd10a405cd358
BLAKE2b-256 4034985a1583fb8ac04ac7b03c8814f2523a38bb1732be0a3acab4a8ba88e866

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rocraters-0.3.0-cp312-none-win_amd64.whl
Algorithm Hash digest
SHA256 a0981724042bb4a7e27528e83c1432c733f3fcee296e81ce7a2239949b5a1eb1
MD5 893c9a3ebc1b23f25e012009525fab98
BLAKE2b-256 68b7fe68b3f8599aaeec6a03fe7680c1d2a084576b9afff461b201bfca89716e

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for rocraters-0.3.0-cp312-none-win32.whl
Algorithm Hash digest
SHA256 0e1a09b0726fa480487509eec97d523495709ed5568f095d7773512fe7c3fdcc
MD5 7f1cf926d120b6737f2fb847861a8435
BLAKE2b-256 97b035545a386be5605fe00b56b755021bea0106bed5a22ab86e8b0eb1192ca1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rocraters-0.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b3055225adc9ee981c4672ca3d4f0066d428173d7532cdbf1a18ef5358e22407
MD5 2d9922fd103dc30a5d5a0d75e21ba183
BLAKE2b-256 576d88dda2cb612acc00b23db5e649c8e33bf4befa4037e761fee90f0b158268

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rocraters-0.3.0-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 8cb5afc6fb98cae4c2e64dc4b3d9f7ba04c08b604c112efbd2f9a326f30252ef
MD5 b3499d90ee771bcf519753c6aae86b38
BLAKE2b-256 c2a0f4ef52b9b761f793a17dc602015a6749dbe8658eaeb4d06867a9e7263ded

See more details on using hashes here.

File details

Details for the file rocraters-0.3.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.3.0-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 c2093b5838a29af644d3aec8c639ffedd518e117c0d48ee23a3ce047d826be36
MD5 453242ca9c13e00b610aeb48d5918259
BLAKE2b-256 b12ea85551bc4d9eff315fe20886b1f083ef1f65e0e957d77884ee3445790c30

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rocraters-0.3.0-cp311-none-win_amd64.whl
Algorithm Hash digest
SHA256 f4331df039808b6d05f100849d275d0520cc4e75e647fb55681c7b01211befb9
MD5 ada4dd546773673ae302a269514f70e1
BLAKE2b-256 581a3dae025a950a15b5fc0a85ef39bd5218d034540159ece4ee7b31689300e7

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for rocraters-0.3.0-cp311-none-win32.whl
Algorithm Hash digest
SHA256 9ed83f3e61a0a4010485485099cfe039ebd1791c6d72bd376ade86707044e4e8
MD5 ff1ba807d5d4926fdffaf97790da0f56
BLAKE2b-256 93d6ed89fbeb6ef8bc53c1c829ec408a881f4d1f74234ec4c25960a814e0691f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rocraters-0.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 59c15ffee5d5ff75e5f9a0abfdec08d437afcf4c9cc01f0676085ea73b1549c2
MD5 9b94e2d1ba80ac4ff54c1ab7697a6a58
BLAKE2b-256 1e785844abf85926ae30a250b1899e911fa0ca5213c360a4b2f5e1c3ea35e058

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rocraters-0.3.0-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 2d58fa03c3986d4ae82968c1dc84a46479dde32aeb745880a70a1b0393e5d12e
MD5 b268e1a161732acace8f091ea1cf6bee
BLAKE2b-256 cedae02c6091921dc96cbf9cbb176750c78f636e91091012f4ff6f1167131da7

See more details on using hashes here.

File details

Details for the file rocraters-0.3.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.3.0-cp311-cp311-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 8df1ec685b4568c1ed66947c7dca032d699bad185d3a65e780d6227238a42ca7
MD5 deac125d7590025836175234e4ae88c9
BLAKE2b-256 975921ffb87c9d723e64caa7af4c21a45620e3ef9afea47cb045c5300baeba51

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rocraters-0.3.0-cp310-none-win_amd64.whl
Algorithm Hash digest
SHA256 d8103206aa02a7bcde15022b4de19f6d91a73576d8080327b01f4e6661dd218d
MD5 239ac077dcbe8ebeb168eee17777d0fe
BLAKE2b-256 0b05b43fdf3f254a2e6b527f9f0abac018589aa95d791ae912d43a0fd43c8f57

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for rocraters-0.3.0-cp310-none-win32.whl
Algorithm Hash digest
SHA256 d3583fbbbaa03cf005b9e7f702dc84d1aa7d04d0af35aa2f5fe3b3b2eb002429
MD5 79cf4d66717457d33a10ca19bd0996cd
BLAKE2b-256 5be26ebb7d5b6bcc17fc39467544fe6590c71752e907b8aeff641fe521d15f8f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rocraters-0.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 156113ad6d9d1a0a6812ad37ba65f998f33e3138420a1536e9967af29f85a19e
MD5 87481a224d487f21f9a8a70b0fc81389
BLAKE2b-256 9aad1fdbd9711c8ac197520832caaf280cd9e7f26fcbbfeda586af92bc457d17

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rocraters-0.3.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 fcaa908582e6e661991ce21f6943ea8ef9e0233ac58de86ebf0cf98232a09658
MD5 b30c703635de22c5c2614bfaea86ef33
BLAKE2b-256 690df0ad0e0c1386affaddf5fc0930c8300c0d003f57afa906f9c267cdfa0bcd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rocraters-0.3.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 192c914ae3699bda89f942fba6f3ddb85839358e346c6301a0728419b56646fc
MD5 0f2057f6b1137b5e1a444fe9721575d9
BLAKE2b-256 491038b026d393e3a4db30ab00e09b19142063974069e345f2104f320682d255

See more details on using hashes here.

File details

Details for the file rocraters-0.3.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.3.0-cp310-cp310-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 51ed8ad95401a0f833ee659ed1fb84383dc068131591478662300dc5d6d57992
MD5 9bc61cad68112106cae9c222f672de82
BLAKE2b-256 199689a627adafa2c8cf871134e959d36080caba79675754763995ec63489b23

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