ManGO metadata schemas on iRODS
Project description
Apply ManGO metadata schemas in Python
Small application to apply metadata from a metadata schema using iRODS PRC.
Requirements
python-irodsclientvalidators
Installation
You can install the package and its dependencies with pip:
pip install mango-mdschema
Usage
# authentication to iRODS
import os, os.path
from irods.session import iRODSSession
from mango_mdschema import Schema
env_file = os.getenv('IRODS_ENVIRONMENT_FILE', os.path.expanduser('~/.irods/irods_environment.json'))
# load a schema from file
my_schema = Schema('/path/to/schema') # this also validates it as a schema
with iRODSSession(irods_env_file=env_file) as session:
obj = session.data_objects.get('path/to/my/object')
my_metadata = {
'text' : 'Some text',
'a_date' : '2023-04-26',
'author' : {
'name' : 'Mariana',
'email' : 'mariana.montes@kuleuven.be'
}
}
my_schema.apply(obj, my_metadata)
The apply function will first validate the provided metadata dictionary
before applying it on the iRODS object. See the tutorial for
more details.
To only validate your metadata, without applying it, you can use the validate
function of the schema.
try:
validated = my_schema.validate(metadata)
except (ConversionError, ValidationError) as err:
print("Oops my metadata was not valid: {err}")
You can check the fields in a schema with:
print(my_schema)
The list of required fields and default values is found as the required_fields attribute.
You can also check all the characteristics of a specific field such as 'name' with:
my_schema.print_requirements('name') # same as print(my_schema.fields['name'])
You can test the list of AVUs that would be sent by providing a given metadata dictonary like so:
avus = my_schema.to_avus(metadata)
The schema class can also read the metadata from ManGO and return it as
nested dictionary with all values converted to their Python representation (
i.e. integer fields result in int values, datetime fields in datetime
objects, etc.).
with iRODSSession(irods_env_file=env_file) as session:
obj = session.data_objects.get('path/to/my/object')
my_metadata = my_schema.extract(obj)
Check the tutorial notebook for more details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mango_mdschema-1.0.3.tar.gz.
File metadata
- Download URL: mango_mdschema-1.0.3.tar.gz
- Upload date:
- Size: 23.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
674bd2926826b4e4c11465f4814ded521baa4eb2ed45dfbc566400afd1edd74f
|
|
| MD5 |
4eacf213194049d662d4875891069c82
|
|
| BLAKE2b-256 |
033c320715abd0096495a5e9d47822ec75af4b21b38a1a769a7accba23bfdbf4
|
Provenance
The following attestation bundles were made for mango_mdschema-1.0.3.tar.gz:
Publisher:
python-publish.yml on kuleuven/mango-mdschema
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mango_mdschema-1.0.3.tar.gz -
Subject digest:
674bd2926826b4e4c11465f4814ded521baa4eb2ed45dfbc566400afd1edd74f - Sigstore transparency entry: 163813553
- Sigstore integration time:
-
Permalink:
kuleuven/mango-mdschema@4ca2b670239f79bdacb5f805d3490f6ae0d16195 -
Branch / Tag:
refs/tags/v1.0.3 - Owner: https://github.com/kuleuven
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@4ca2b670239f79bdacb5f805d3490f6ae0d16195 -
Trigger Event:
release
-
Statement type:
File details
Details for the file mango_mdschema-1.0.3-py3-none-any.whl.
File metadata
- Download URL: mango_mdschema-1.0.3-py3-none-any.whl
- Upload date:
- Size: 18.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6e0c4a9cf46756740632b717582541edbeae25783f5b265d9eaac3c54b243594
|
|
| MD5 |
8cb071351245932c79dcc5ab406706ff
|
|
| BLAKE2b-256 |
4218613d483798e64e7d042b904b4bc5d533c1ee2d8110ae9ec1846feebfe967
|
Provenance
The following attestation bundles were made for mango_mdschema-1.0.3-py3-none-any.whl:
Publisher:
python-publish.yml on kuleuven/mango-mdschema
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mango_mdschema-1.0.3-py3-none-any.whl -
Subject digest:
6e0c4a9cf46756740632b717582541edbeae25783f5b265d9eaac3c54b243594 - Sigstore transparency entry: 163813554
- Sigstore integration time:
-
Permalink:
kuleuven/mango-mdschema@4ca2b670239f79bdacb5f805d3490f6ae0d16195 -
Branch / Tag:
refs/tags/v1.0.3 - Owner: https://github.com/kuleuven
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@4ca2b670239f79bdacb5f805d3490f6ae0d16195 -
Trigger Event:
release
-
Statement type: