openMINDS Python is a small library to support the creation and use of openMINDS metadata models and schemas in your Python application, with import and export in JSON-LD format.
The package contains all openMINDS schemas as Python classes in addition to schema base classes and utility methods.
Installation
pip install openMINDS<br />
```<br />
<br />
## Usage<br />
```<br />
from datetime import date<br />
from openminds import Collection, IRI<br />
import openminds.latest.core as omcore<br />
<br />
# Create an empty metadata collection<br />
<br />
collection = Collection()<br />
<br />
# Create some metadata<br />
<br />
mgm = omcore.Organization(<br />
full_name="Metro-Goldwyn-Mayer Studios, Inc.",<br />
short_name="MGM",<br />
homepage=IRI("https://www.mgm.com")<br />
)<br />
<br />
stan = omcore.Person(<br />
given_name="Stan",<br />
family_name="Laurel",<br />
affiliations=omcore.Affiliation(member_of=mgm, start_date=date(1942, 1, 1))<br />
)<br />
<br />
ollie = omcore.Person(<br />
given_name="Oliver",<br />
family_name="Hardy",<br />
affiliations=omcore.Affiliation(member_of=mgm, start_date=date(1942, 1, 1))<br />
)<br />
<br />
# Add the metadata to the collection<br />
<br />
collection.add(stan, ollie, mgm)<br />
<br />
# Check the metadata are valid<br />
<br />
failures = collection.validate()<br />
<br />
# Save the collection in a single JSON-LD file<br />
<br />
collection.save("my_collection.jsonld")<br />
<br />
# Save each node in the collection to a separate file<br />
<br />
collection.save("my_collection", individual_files=True) # creates files within the 'my_collection' directory<br />
<br />
# Load a collection from file<br />
new_collection = Collection()<br />
new_collection.load("my_collection.jsonld")<br />