Skip to main content

Dataset Manager

Library to pre-process CSV files from Research Portal into usable datasets.

Installation

pip install minder.dataset-manager

Example

import logging
import asyncio
import sys
from typing import Optional
from minder.dataset_manager._utils import Dataset
from minder.dataset_manager.datasets import LabelledUtiDataset
from minder.research_portal_client import Configuration, JobManager


logging.basicConfig(level=logging.INFO)

Configuration.set_default(
    Configuration(
        access_token="---REDACTED---",
    )
)


async def example1():
    job_ids = ["c25249e0-82ff-43d1-9676-f3cead0228b9"]
    async with JobManager() as job_manager:
        files = Dataset.download(job_ids, job_manager)
        dataset = LabelledUtiDataset.create(job_ids, files)
        dataset.save("./my-dataset.npz")


async def example2():
    job_ids = ["c25249e0-82ff-43d1-9676-f3cead0228b9"]
    existing_dataset = "./my-dataset.npz"
    async with JobManager() as job_manager:
        download_task = Dataset.download(job_ids, job_manager)
        try:
            previous_dataset: Optional[Dataset] = None
            if existing_dataset.exists():
                previous_dataset = LabelledUtiDataset.load(existing_dataset)
        finally:
            files = await download_task

        new_dataset = LabelledUtiDataset.create(job_ids, files)

        dataset = (
            await previous_dataset.update(new_dataset, job_manager=job_manager)
            if previous_dataset is not None
            else new_dataset
        )
        dataset.save("./my-dataset.npz")


async def main():
    await example1()
    await example2()


if sys.platform == "win32"::
    asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())

asyncio.run(main())

Development

Useful commands

Setup

poetry install

Run tests

poetry run pytest

Code Coverage

This command consists of 2 parts:

  • running tests with coverage collection
  • formatting the report: report (text to stdout), xml (GitLab compatible: cobertura), html (visual)
poetry run coverage run -m pytest && poetry run coverage report -m

Linting

poetry run flake8

Formatting

poetry run black .

Type Checking

poetry run mypy .

Metadata

Release files for minder.dataset-manager 0.1.0

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

Source distribution (sdist)

Source distribution for minder.dataset-manager 0.1.0
File Size Uploaded
minder.dataset_manager-0.1.0.tar.gz 8.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for minder.dataset-manager 0.1.0
File Interpreter ABI Platform
minder.dataset_manager-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 20.1 kB

Release files / minder.dataset_manager-0.1.0.tar.gz

Download URL minder.dataset_manager-0.1.0.tar.gz
Size 8.6 kB
Tags Source
SHA-256 checksum
How to use checksums
599645a22b2a40deae16efa4a1d3a389146b924e83b59d13e009a7715ad9e7e4
BLAKE2b-256 checksum
How to use checksums
d1db0f9dbcd7cdbd9dc0f74b7b74171b26fcf2911b0a4e8e6f74f551fd75e398
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.13 CPython/3.8.8 Windows/10

Release files / minder.dataset_manager-0.1.0-py3-none-any.whl

Download URL minder.dataset_manager-0.1.0-py3-none-any.whl
Size 11.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8f5994ffe5c73ae5aa4764d46ebf6b6db29cb42ef58fe24392d8c851e90aecff
BLAKE2b-256 checksum
How to use checksums
05ca22bec17edddf2f8cb7a00103e0cf881cf9647a4ad42519ebf3ce080d813c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.13 CPython/3.8.8 Windows/10

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

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