The ro-crate-py library provides tools for generating, parsing, and manipulating RO-Crate (Research Object Crate) metadata. RO-Crate is a community effort to package research data with their metadata, using schema.org types serialized as JSON-LD, and is designed to be human- and machine-readable. The library is actively maintained with frequent releases, currently at version 0.15.0.
pip install rocrateVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to create a basic RO-Crate, add a file (with content), add a contextual entity (a Person), link the file to the person, and then write the complete RO-Crate to a local directory.
Entity IDs must be set during instantiation. If you need a different ID, create a new `Entity` instance with the desired ID and update references accordingly.
Review how contextual entity IDs are generated and referenced in your application. Ensure that IDs are consistent with the new explicit handling, or update your code to prepend the hash manually if required for specific uses.
Upgrade your Python environment to 3.9 or newer. If upgrading Python is not an option, you must pin `rocrate` to a version older than `0.12.0` (e.g., `rocrate<0.12.0`).
When consuming RO-Crates, especially those conforming to RO-Crate 1.2, ensure your parsing logic is robust. Test with your specific RO-Crate structures to confirm compatibility, and refer to the `RO-Crate version selector` if encountering issues.
The `id` attribute is read-only. Create a new `Entity` instance with the desired ID and update any references to it.
Ensure you are importing these classes directly from `rocrate.model`, e.g., `from rocrate.model import File`.
Review the traceback for specific field errors. Consult the latest documentation for `ROCrate` and entity constructors to ensure all arguments and properties conform to the expected schema and types for your `rocrate` version.
Check the `ROCrate` constructor signature in the documentation for your `rocrate` version. For example, to read an existing RO-Crate, use `ROCrate('/path/to/crate')` or `ROCrate(source=zip_file_object)` (if applicable) instead of `source` as a keyword argument.