Skip to main content

A library for interacting with the Datamint API, designed for efficient data management, processing and Deep Learning workflows.

Project description

Datamint Python API

Build Status Python 3.10+

A comprehensive Python SDK for interacting with the Datamint platform, providing seamless integration for medical imaging workflows, dataset management, and machine learning experiments.

📋 Table of Contents

🚀 Features

  • Dataset Management: Download, upload, and manage medical imaging datasets using intuitive object-based APIs or CLI tools
  • Annotation Tools: Create, upload, and manage annotations (segmentations, labels, measurements) with ease
  • Experiment Tracking: Seamless support for experiment management via MLflow integration
  • PyTorch Lightning Integration: Streamlined machine learning workflows featuring specialized LightningDataModules, built-in trainers (SegmentationTrainer), and automated MLflow checkpoint logging
  • DICOM Support: Native handling of DICOM files, including powerful anonymization capabilities during upload to protect patient privacy
  • Multi-format Support: Robust support for a wide range of medical imaging formats: PNG, JPEG, NIfTI (NIfTI/NRRD), DICOMs and more

See the full documentation at https://sonanceai.github.io/datamint-python-api/

📦 Installation

[!NOTE] We recommend using a virtual environment to avoid package conflicts.

From PyPI

pip install -U datamint

Virtual Environment Setup

Click to expand virtual environment setup instructions

We recommend that you install Datamint in a dedicated virtual environment, to avoid conflicting with your system packages. For instance, create the enviroment once with python3 -m venv datamint-env and then activate it whenever you need it with:

  1. Create the environment (one-time setup):

    python3 -m venv datamint-env
    
  2. Activate the environment (run whenever you need it):

    Platform Command
    Linux/macOS source datamint-env/bin/activate
    Windows CMD datamint-env\Scripts\activate.bat
    Windows PowerShell datamint-env\Scripts\Activate.ps1
  3. Install the package:

    pip install datamint
    

⚙ Setup API key

To use the Datamint API, you need to setup your API key (ask your administrator if you don't have one). Use one of the following methods to setup your API key:

Method 1: Command-line tool (recommended)

Run datamint-config (or python -m datamint config if that doesn't work) in the terminal and follow the instructions. See command_line_tools for more details.

Method 2: Environment variable

Specify the API key as an environment variable.

Bash:

export DATAMINT_API_KEY="my_api_key"
# run your commands (e.g., `datamint-upload`, `python script.py`)

Python:

import os
os.environ["DATAMINT_API_KEY"] = "my_api_key"

📚 Documentation

Resource Description
🚀 Getting Started Step-by-step setup and basic usage
📖 API Reference Complete API documentation
🔥 PyTorch Integration ML workflow integration
🧠 Trainer Guide Built-in trainers, trainer lifecycle, and custom model integration
💡 Examples Practical usage examples

🛠️ Command Line Tools

Full documentation at command_line_tools.

Upload Resources

Upload DICOM files with anonymization:

datamint-upload /path/to/dicoms --recursive --channel "training-data" --publish --tag "my_data_tag"

It anonymizes by default.

Upload resources with segmentations and associate them with a deployed model:

datamint-upload /path/to/dicoms \
   --recursive \
   --segmentation_path /path/to/segmentations \
   --segmentation_names /path/to/segmentation_names.yaml \
   --ai-model "knee-segmentation-v2" \
   --publish

Use --ai-model when uploaded segmentation files should be linked to an existing deployed model by name. --segmentation_names accepts YAML mappings and ITK-SNAP label export CSV/TXT files.

Configuration Management

# Interactive setup
datamint-config

# Set API key
datamint-config --api-key "your-key"

🔒 SSL Certificate Troubleshooting

If you encounter SSL certificate verification errors like:

SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate

Quick Fix

1. Upgrade certifi:

pip install --upgrade certifi

2. Set environment variables:

export SSL_CERT_FILE=$(python -m certifi)
export REQUESTS_CA_BUNDLE=$(python -m certifi)

3. Run your script:

python your_script.py

Alternative Solutions

Option 1: Use Custom CA Bundle

from datamint import Api

api = Api(verify_ssl="/path/to/your/ca-bundle.crt")

Option 2: Disable SSL Verification (Development Only)

from datamint import Api

# ⚠️ WARNING: Only use in development with self-signed certificates
api = Api(verify_ssl=False)

🆘 Support

Full Documentation
GitHub Issues

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

datamint-2.17.1.tar.gz (213.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

datamint-2.17.1-py3-none-any.whl (279.2 kB view details)

Uploaded Python 3

File details

Details for the file datamint-2.17.1.tar.gz.

File metadata

  • Download URL: datamint-2.17.1.tar.gz
  • Upload date:
  • Size: 213.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for datamint-2.17.1.tar.gz
Algorithm Hash digest
SHA256 ded31b9b990e33fe92fc4180ce40f981429f7ba3a1f46ad2745614a2bf04fac7
MD5 6628d45a9a064c8f6ea932e4db379007
BLAKE2b-256 975255c3fb9d3366f8d1acc33308326d756e52e2d4e43420b4eeba1767e038c0

See more details on using hashes here.

Provenance

The following attestation bundles were made for datamint-2.17.1.tar.gz:

Publisher: release_pypi.yaml on SonanceAI/datamint-python-api

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file datamint-2.17.1-py3-none-any.whl.

File metadata

  • Download URL: datamint-2.17.1-py3-none-any.whl
  • Upload date:
  • Size: 279.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for datamint-2.17.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2291d0c2191c3639c41a7864cb8fa3bfd0151a93037e25937eefd23f6a1da063
MD5 91dff149ca3052279c0fe0ce3a038014
BLAKE2b-256 5897f7309c94ca04711eb108aec8b573706ab1d83c6a01f53f6f563a7618cd3e

See more details on using hashes here.

Provenance

The following attestation bundles were made for datamint-2.17.1-py3-none-any.whl:

Publisher: release_pypi.yaml on SonanceAI/datamint-python-api

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page