-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Creating Detached RO-Crates #206
Comments
Detached crates are a new feature in RO-Crate 1.2, which has not been released (nor finalized) yet. The library does not support them, so I have changed the "bug" label to "enhancement". Moreover, your example is not a valid 1.2 detached RO-Crate because the metadata descriptor must have an After RO-Crate 1.2 is released, we'll need to make changes to the library to support root data entities with an |
@simleo thanks for pointing the Regarding the bug label: I was mainly concerned about the fact that when adding a new It also manifests for example with this snippet:
{"@context": "https://w3id.org/ro/crate/1.1/context",
"@graph": [{"@id": "./",
"@type": "Dataset",
"datePublished": "2024-12-05T14:43:04+00:00"},
{"@id": "ro-crate-metadata.json",
"@type": "CreativeWork",
"about": {"@id": "./"},
"conformsTo": {"@id": "https://w3id.org/ro/crate/1.1"}},
{"@id": "#114399a7-4ce3-4f9a-b46c-9f3328dff365",
"@type": "Dataset",
"author": {"@id": "https://example.com/alice"},
"datePublished": "2024-12-05T14:43:04+00:00"},
{"@id": "https://example.com/alice",
"@type": "Person",
"affiliation": "University of Flatland",
"name": "Alice Doe"}]} As a user, I would expect the library to either handling this correctly especially since the add method has specific code to treat the replacement of |
@dnlbauer your snippet exposed a bug that affected all datasets. I fixed that in #208. Due to that bug, the root dataset that you created had an auto-generated from pprint import pprint
from rocrate.rocrate import ROCrate
from rocrate.model import RootDataset, Person
crate = ROCrate()
root_dataset = crate.add(RootDataset(crate, "folder/"))
crate.metadata["about"] = root_dataset
crate.delete("./")
alice = crate.add(Person(crate, "https://example.com/alice", properties={
"name": "Alice Doe",
"affiliation": "University of Flatland"
}))
root_dataset["author"] = alice
pprint(crate.metadata.generate()) Which results in: {'@context': 'https://w3id.org/ro/crate/1.1/context',
'@graph': [{'@id': 'ro-crate-metadata.json',
'@type': 'CreativeWork',
'about': {'@id': 'folder/'},
'conformsTo': {'@id': 'https://w3id.org/ro/crate/1.1'}},
{'@id': 'folder/',
'@type': 'Dataset',
'author': {'@id': 'https://example.com/alice'},
'datePublished': '2024-12-10T11:26:12+00:00'},
{'@id': 'https://example.com/alice',
'@type': 'Person',
'affiliation': 'University of Flatland',
'name': 'Alice Doe'}]} If data entities are added before creating the new root dataset, however, you also have to take care of the |
I am trying to use the library to create a Detatched RO-Crate. For a minimal example, I tried to create something that contains no files; I assume a minimal jsonld to look similar to this (obviously not valid since it has no license etc, but serves as an example):
When the crate object is created from scratch with
ROCrate()
, theid
of the metadata and root dataset entity are already set to default valuesro-crate-metadata.json
and./
. Because the ids are not mutable, the only way to set appropriate ids that i found was to recreate the entities:However, I noticed some problems with this approach:
Issue 1
The medata entity
about
property does not get updated to the new root dataset entity. this can be fixed by adding anabout
property when creating the Metadata entity, but I think a better approach would be to have the library handle this internally for the two must-have entities RootDataset and Metadata.Issue 2
The original RootDataset and Metadata entity are not actually replaced in the ROCrate. Instead, the new entities are added on top of them. The reason is that the old and new entities do not resolve to the same hash value, leading to the old entities not being evicted from the internal map. The resulting jsonld therefore looks like this even after setting the
about
manually:I consider this as a bug since there is actual code inside the
add
method to work with RootDataset and Metadata, but it fails to override existing entities as intended.Unless I am approaching detached RO-Crates totally wrong, the only way I found to build a valid detached RO-Crate was to delete the remaining additional entities manually. This led to this "hacky" approach:
Fixing the two issues would make it way easier to work with Detached RO-Crates in general.
On a side note: It would be nice to have a way to instantiate the RO-Crate with correct ids directly, but I think its fine the way it is if some documentation is added about how to build a detached crate, so not everyone has to figure all of the above out on his/her own.
The text was updated successfully, but these errors were encountered: