Skip to main content

inveniordm-py

https://github.com/inveniosoftware/inveniordm-py/workflows/CI/badge.svg https://img.shields.io/github/tag/inveniosoftware/inveniordm-py.svg https://img.shields.io/pypi/dm/inveniordm-py.svg https://img.shields.io/github/license/inveniosoftware/inveniordm-py.svg

inveniordm-py is a Python client designed to interact with the InvenioRDM API.

Usage

Here’s a basic example of how to use inveniordm-py:

from inveniordm_py.client import InvenioAPI

# Initialize client
client = InvenioAPI('https://your-invenio-instance.com', 'your-token')

# Get a list of all records
records = client.records.search()

The client supports creating and updating drafts:

from inveniordm_py.records.metadata import DraftMetadata

# Create a draft with metadata
data = {
    "metadata": {
        "title": "Test",
        "resource_type": {
            "id": "publication-article",
        },
        "publication_date": "2024",
        "creators": [
            {
                "person_or_org": {
                    "family_name": "Brown",
                    "given_name": "Troy",
                    "type": "personal",
                }
            },
        ],
        "publisher": "Zenodo"
    }
}
draft = client.records.create(data=DraftMetadata(data))

# Update metadata and draft
data.update({
    "metadata": {
        "title": "Test 2",
    }
})
draft.update(data=DraftMetadata(data))

Files can be added to the draft:

from inveniordm_py.files.metadata import FileMetadata, OutgoingStream, FileMetadata

# Define files metadata
fname = "test.txt"
fpath = "/path/to/test.txt"
file_data = FileMetadata({"key": fname})

# Create the file and add it to the draft using a stream
draft.files.create(file_data)
stream = open(fpath, "rb")
f.set_contents(OutgoingStream(data=stream))
f.commit()

# It also supports the addition of multiple files from disk
_dir = "/path/to/dir"
file_data = FilesListMetadata([{"key": fname} for fname in os.listdir(_dir)])
draft.files.create(file_data)
for f in draft.files:
    file_path = os.path.join(_dir, f.data['key'])
    stream = open(file_path, "rb")
    f.set_contents(OutgoingStream(data=stream))
    f.commit()

Finally, the draft can be published:

# Publish the draft and check the status
record = draft.publish()
print(record.data["status"])

Changes

Version 0.1.1 (released 2024-07-14)

  • installation: remove invenio-i18n dependency

Version 0.1.0 (released 2024-05-13)

  • Initial public alpha release.

Metadata

Release files for inveniordm-py 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for inveniordm-py 0.1.1
File Size Uploaded Provenance Actions
inveniordm-py-0.1.1.tar.gz 22.9 kB Without provenance Details for inveniordm-py-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for inveniordm-py 0.1.1
File Interpreter ABI Platform Actions
inveniordm_py-0.1.1-py2.py3-none-any.whl Python 2, Python 3 none any Details for inveniordm_py-0.1.1-py2.py3-none-any.whl

Total release size: 42.8 kB

Release files / inveniordm-py-0.1.1.tar.gz

Download URL inveniordm-py-0.1.1.tar.gz
Size 22.9 kB
Tags Source
SHA-256 checksum
How to use checksums
f1b61834c6a2236a6079bbc17926645b924ba493279d901ceb8bcf6d53091c95
BLAKE2b-256 checksum
How to use checksums
3601bf0787c40c62d64d32d3b484572d42f218c06417109629a00f930325e351
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.8.19

Release files / inveniordm_py-0.1.1-py2.py3-none-any.whl

Download URL inveniordm_py-0.1.1-py2.py3-none-any.whl
Size 20.0 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
c9c0ebc6dc65953ca326e2162ed452abd1c4def57ef45d93b47205a45b2f0e91
BLAKE2b-256 checksum
How to use checksums
38774fd894baeaf59795f8a79723098b9199d5007a35eeb6099953ebf22c51f7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.8.19

Security for inveniordm-py 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page