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.3.tar.gz (275.2 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.3-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

rocraters-0.4.3-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.whl (1.3 MB view details)

Uploaded PyPymanylinux: glibc 2.5+ i686

rocraters-0.4.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

rocraters-0.4.3-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.whl (1.3 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.5+ i686

rocraters-0.4.3-cp313-cp313-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (2.2 MB view details)

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

rocraters-0.4.3-cp312-cp312-win_amd64.whl (913.2 kB view details)

Uploaded CPython 3.12Windows x86-64

rocraters-0.4.3-cp312-cp312-win32.whl (870.7 kB view details)

Uploaded CPython 3.12Windows x86

rocraters-0.4.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

rocraters-0.4.3-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl (1.3 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.5+ i686

rocraters-0.4.3-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (2.2 MB view details)

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

rocraters-0.4.3-cp311-cp311-win_amd64.whl (913.1 kB view details)

Uploaded CPython 3.11Windows x86-64

rocraters-0.4.3-cp311-cp311-win32.whl (870.8 kB view details)

Uploaded CPython 3.11Windows x86

rocraters-0.4.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

rocraters-0.4.3-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl (1.3 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.5+ i686

rocraters-0.4.3-cp311-cp311-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (2.2 MB view details)

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

rocraters-0.4.3-cp310-cp310-win_amd64.whl (913.2 kB view details)

Uploaded CPython 3.10Windows x86-64

rocraters-0.4.3-cp310-cp310-win32.whl (870.7 kB view details)

Uploaded CPython 3.10Windows x86

rocraters-0.4.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

rocraters-0.4.3-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.whl (1.3 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.5+ i686

rocraters-0.4.3-cp310-cp310-macosx_11_0_arm64.whl (1.0 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

rocraters-0.4.3-cp310-cp310-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (2.2 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.3.tar.gz.

File metadata

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

File hashes

Hashes for rocraters-0.4.3.tar.gz
Algorithm Hash digest
SHA256 f7246dd0edeb66c3fdac37bfb42f38d2b42b58cfd0b6377bec9a7c591daf2a49
MD5 7264b19c487aa4dd9c28b96624930876
BLAKE2b-256 b93f9850fe594723e41841a642eda981b7463f8cd1fdd131e58da7e47cbd5db8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rocraters-0.4.3-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e25825de9383c1e7ed2a1e576b1a3c4bc3d7ab957f621140115a4c83fcf99407
MD5 887b5ca53386f4128a93c90afae16892
BLAKE2b-256 2ab40b79b9d67c0679555e4e0be804b4b70c5cd1ae318c16cb8d898978576f8f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rocraters-0.4.3-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 ac1ffa26448792641c48e44a26d89c24813e521f5f4536148373f448d3643509
MD5 8b4b5373d01fe38992436981db3d1402
BLAKE2b-256 b64f145364b978943d0cfbe3882fac8556b2d08a9f0c52812a11d7e6bef4369f

See more details on using hashes here.

File details

Details for the file rocraters-0.4.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rocraters-0.4.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0501546d6f74da4cee73ecc0f1f49227756bf54b006a9bcbd99e826e3ec07059
MD5 3a0d70008bd18b901ced0ffc66d784cc
BLAKE2b-256 025de04690c349498982cbe5b8b7a0f9e233f2cc9dc5fc30c2f99f276d935d5d

See more details on using hashes here.

File details

Details for the file rocraters-0.4.3-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.whl.

File metadata

File hashes

Hashes for rocraters-0.4.3-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 8eba6df8dc67af53ab17134ca116a5c58ae9e98124f22b63e3ae08f56634f510
MD5 38c153ced4827564872e994edb77e881
BLAKE2b-256 a73ae37322232977c19918f7fa120eef38296f30193393f9671f8119dda8a711

See more details on using hashes here.

File details

Details for the file rocraters-0.4.3-cp313-cp313-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl.

File metadata

File hashes

Hashes for rocraters-0.4.3-cp313-cp313-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 2da52c710bfffdf16705d3e55bad239f52deff35ef0bc5dbcd710b88dde4843d
MD5 aeba7512639e41d2061310d8e930942a
BLAKE2b-256 48f00d3be296fd9689dae63d48180c3892fad9c45239fc65b406ec669b8b8682

See more details on using hashes here.

File details

Details for the file rocraters-0.4.3-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for rocraters-0.4.3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 535d888fe036d6e73b3a008b0c2339264b646889df0e72874ff58ce509aeed66
MD5 e902192cca4636d71bb4e1e6d49d3009
BLAKE2b-256 df0233d7f31a936c8df280d253fb52aa649b909e6ff54460592083f646cbf2d5

See more details on using hashes here.

File details

Details for the file rocraters-0.4.3-cp312-cp312-win32.whl.

File metadata

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

File hashes

Hashes for rocraters-0.4.3-cp312-cp312-win32.whl
Algorithm Hash digest
SHA256 ce905f231cfced97e244c91b839d89576741c8e48ae6887493833527ad77a860
MD5 53306b2f40927e64ef02588190598292
BLAKE2b-256 44ae8e68c2be623e6bdad3bddc7e93fa0005f5e7d22b27029141bd427c66786f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rocraters-0.4.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0ebb66ea9ea9ff9231f801824049604240c22c5a169811274f461723d4af6aad
MD5 adbe93993eca5848733db362157495e9
BLAKE2b-256 68d8c05c9d32f94b573d5c97b6648b3060bf776f0d36f609cd780562eefa4f69

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rocraters-0.4.3-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 09ce811c7778032330ac4c80c7e424627cf9a1e003f2854edde722840beb0a5a
MD5 3d416fe23e770b1ccda8fca934495d9d
BLAKE2b-256 cf0ce3f33abf76b34594de34dd8b849fea037498825341cec8eb8c1eb2476e7b

See more details on using hashes here.

File details

Details for the file rocraters-0.4.3-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.3-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 bc1917bd392ae5b4ec52f42162df49b31c2e70d1b129973c45b25c1931a5c5fd
MD5 260d9ddbadcff3716cf7c71e4cd17273
BLAKE2b-256 1ea6c89737fee08d3c578aa39750d5fe06d8672cccfa6b25e9d0ae2a5dc5da6c

See more details on using hashes here.

File details

Details for the file rocraters-0.4.3-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for rocraters-0.4.3-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 500ac9e4b69f937cd7c271f7e2d88e6d9a10b0dc35c8a4a625918d76d7be2c3a
MD5 9993a1967ac69ac29104fc58f0170c76
BLAKE2b-256 b2cd8bc87678484a4189c29f52a808596a4e57574549c491b365317b991b4cdf

See more details on using hashes here.

File details

Details for the file rocraters-0.4.3-cp311-cp311-win32.whl.

File metadata

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

File hashes

Hashes for rocraters-0.4.3-cp311-cp311-win32.whl
Algorithm Hash digest
SHA256 80aeb96f41819f2dcece31055cea59a992cf799df8e847d4b15a4f7fbb99da1c
MD5 484501843ead25ffe21512bf44eb1a70
BLAKE2b-256 2c167e5b841f18152ea22b936b432d95a535989220b12e4ac55055257b8527c2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rocraters-0.4.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 33c1b46db5b6061f678e614f4619d54246bf3999940c3860224f0f6700225914
MD5 0068cd4b28c176b58f66293b5e609f1b
BLAKE2b-256 b7e60c65e60ddca2beca20f08129b3896c6a1e1663963a0e89f1068d9b69fae0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rocraters-0.4.3-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 383ca37669f38240fb25aa6690bbecec25db98a28ef6ee6d1531f1c995c5aaa3
MD5 c4e622ccf2b866c98f30b459e73bee6c
BLAKE2b-256 d8f4b410939d5882ac15f37a58b801041193cdd72c7ee11e5796a5886f35d8d7

See more details on using hashes here.

File details

Details for the file rocraters-0.4.3-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.3-cp311-cp311-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 f66080c18740530da0ea3b1ccef50e922fadf55d3257e27fd5d6488cf3832ba1
MD5 eed5ace2093cb5b910d0885e8dd3eae2
BLAKE2b-256 d87f2474dd9e8d7a6f178efbad411ea964271b132f00eb837737a315161df156

See more details on using hashes here.

File details

Details for the file rocraters-0.4.3-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for rocraters-0.4.3-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 499313434050e9de2cd5875ff9e49705586f8e4aa84536b2ccd6f244a19bad14
MD5 aab0c91d01df6719d20ea55b0a6683f6
BLAKE2b-256 e47413fdc3491109298ae46543e2c9cc147ecb30bc8b622460160feba6af67ae

See more details on using hashes here.

File details

Details for the file rocraters-0.4.3-cp310-cp310-win32.whl.

File metadata

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

File hashes

Hashes for rocraters-0.4.3-cp310-cp310-win32.whl
Algorithm Hash digest
SHA256 41d733dc643ca933ffb3584a426e21652c3a9cbdd77b30ad683f7cd86085264a
MD5 84b9855974c492f2a04fb1ddbeea2233
BLAKE2b-256 bde2137ba8a43abd744cf792d3d27018c0cdf058212d0ad058867b002ec0d501

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rocraters-0.4.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2a046ce9de6f852953ed76f56aa54f60d2004459cbdd6d5a00aa42447d8a192c
MD5 3d0ccb5fa12fac5e4f6aaea236e710e0
BLAKE2b-256 139d4f31232644b6ea1892a53bbf003d4bcd8cfafdc55dfe6ed4105d9341a4cc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rocraters-0.4.3-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 4d0afea62650533d3b06d4a81298e1e4df375bb30aa936aaf6abbea4bd05e5df
MD5 27fee9602ab9a74cfef254323a2f88a2
BLAKE2b-256 1a5916d9aaeed14cdb8558b561996ce5812d6984cba90d7c8b7288edd1785125

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rocraters-0.4.3-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ce77195857023f41ab0c9845298bc9d8adf2b252527a1b4fe4b4ab926651d8db
MD5 25f1fddd1836f629763d9623962dd12a
BLAKE2b-256 7acc5d2ee5c038aaa44a5fb4f72fa0171aff1c035e1b0110dea7dee0dc7ab01f

See more details on using hashes here.

File details

Details for the file rocraters-0.4.3-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.3-cp310-cp310-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 409b33f395e97fe92fa58ba8a3eaa19d60128cc48977aaae3dd09c067eac2ac0
MD5 dc1baf53e11e53644841fce89223c3ac
BLAKE2b-256 1b23bae5d5f905ad2a34a177cf49663ec568ce73976323563bb37cabc60eb005

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