Skip to content
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

BUG: If Root Data Entity has an arcp:// ID the arcp:// part gets stripped off it #167

Closed
ptsefton opened this issue Dec 20, 2023 · 1 comment · Fixed by #168
Closed

BUG: If Root Data Entity has an arcp:// ID the arcp:// part gets stripped off it #167

ptsefton opened this issue Dec 20, 2023 · 1 comment · Fixed by #168

Comments

@ptsefton
Copy link

ptsefton commented Dec 20, 2023

Here's some code to reproduce the error:

from rocrate.rocrate import ROCrate
import json
import os
test_crate = {
  "@context": [
    "https://w3id.org/ro/crate/1.1/context",
    {
      "@vocab": "http://schema.org/"
    }
  ],
  "@graph": [
    {
      "@id": "ro-crate-metadata.json",
      "@type": "CreativeWork",
      "conformsTo": [
        {
          "@id": "https://w3id.org/ro/crate/1.2"
        }
      ],
      "about": {
        "@id": "arcp://name,corpus-of-oz-early-english"
      }
     
      
    },
    {"@id": "arcp://name,corpus-of-oz-early-english", "@type": "Dataset"}
  ]}
os.makedirs("test_crate", exist_ok=True)
f = open("test_crate/ro-crate-metadata.json","w")
f.write(json.dumps(test_crate, indent=2))
f.close()
crate = ROCrate("test_crate")
print("ID of root dataset", crate.root_dataset.id) # name,corpus-of-oz-early-english 

print("ID of original", test_crate["@graph"][1]["@id"]) # arcp://name,corpus-of-oz-early-english
print("same?", crate.root_dataset.id == test_crate["@graph"][1]["@id"])
@simleo simleo mentioned this issue Dec 21, 2023
@simleo
Copy link
Collaborator

simleo commented Dec 21, 2023

Fixed in #168. A workaround for earlier versions is to add a trailing slash to the URL, e.g. arcp://name,corpus-of-oz-early-english/. This was affecting all URLs, not just arcp ones.

Note that the comparison in the code above would still fail, because a trailing slash is automatically added to Dataset ids (to comply with RO-Crate's "SHOULD end with /" recommendation).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants