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

Add ro-crate instantiation from a dictionary #183

Merged
merged 2 commits into from
May 10, 2024

Conversation

simleo
Copy link
Collaborator

@simleo simleo commented May 10, 2024

Fixes #178.

from rocrate.rocrate import ROCrate

metadata = {
    "@context": "https://w3id.org/ro/crate/1.1/context",
    "@graph": [
        {
            "@id": "ro-crate-metadata.json",
            "@type": "CreativeWork",
            "about": {"@id": "./"},
            "conformsTo": {"@id": "https://w3id.org/ro/crate/1.1"}
        },
        {
            "@id": "./",
            "@type": "Dataset",
            "creator": {"@id": "#josiah"},
            "hasPart": {"@id": "http://example.org/foo"}
        },
        {
            "@id": "http://example.org/foo",
            "@type": "File"
        },
        {
            "@id": "#josiah",
            "@type": "Person",
            'name': 'Josiah Carberry'
        },
    ]
}

crate = ROCrate(metadata)
crate.write("crate")

If the metadata points to nonexistent local files or directories, the behavior when writing the crate is as described in #136 (see also the unit test added in this PR).

@simleo simleo merged commit a70891b into ResearchObject:master May 10, 2024
12 checks passed
@simleo simleo deleted the crate_from_dict branch May 10, 2024 10:28
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 this pull request may close these issues.

FEATURE: Load a crate from a (json) Object
1 participant