Skip to main content

Easiest-possible IO for basic file types.

Project description

dummio

IO for dummies! A unified save/load interface using the most common and recommendable default options for IO between various object types and file types. For example, instead of

with open(file_path, 'r', encoding='utf-8') as file:
    data = json.load(file)

you can simply

data = dummio.json.load(file_path)

Users may pass additional keyword arguments to the underlying IO methods.

Direct IO vs cloud paths

Most dummio IO calls "just work" against cloud paths like s3://bucket/key, gs://bucket/key, or az://container/key. For example, dummio.json.load("s3://bucket/key") will read a json file from an S3 bucket. Notes:

  • Shout-out: universal-pathlib powers much of the cloud-iteroperability on our backend.
  • Warning: Although we manually run demo/cloud.py to ensure basic functionality, current CI unit testing does not cover cloud interactions.

Standardized IO interface

In some coding applications it is desirable to pass an IO module as an argument to a function. Here it is convenient to pass a dummio submodule, since all dummio submodules have the same save and load interface, having equivalent signatures (except for differences hidden in **kwargs).

Supported object and file types

So far we support:

  • text, pickle, and dill
  • simple dictionaries:
    • json
    • yaml
  • pandas dataframes:
    • csv
    • feather
    • parquet
  • onnx.ModelProto instances
  • pydantic models (relying on the built-in json serialization methods)

Filepaths passed to save and load methods can be of type str, pathlib.Path, or universal_pathlib.UPath.

Dependencies

universal-pathlib is our only required dependency.

For other dependencies, such as pandas, calling from dummio.pandas import df_parquet will raise a helpful message to install pandas if you have not already done so.

Examples

Basic IO methods can be accessed directly as dummio.text, dummio.json, etc:.

import dummio

text = "hello world"
data = {"key": text}
path = "io_example_file"

# Text
dummio.text.save(text, path=path)
assert text == dummio.text.load(path)

# YAML
dummio.yaml.save(data)
assert data == dummio.yaml.load(path)

See demo/cloud.py for more many other examples.

Installation

We're on pypi, so pip install dummio.

If working directly on this repo, consider using the simplest-possible virtual environment.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dummio-1.6.3.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

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

dummio-1.6.3-py3-none-any.whl (12.9 kB view details)

Uploaded Python 3

File details

Details for the file dummio-1.6.3.tar.gz.

File metadata

  • Download URL: dummio-1.6.3.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.11

File hashes

Hashes for dummio-1.6.3.tar.gz
Algorithm Hash digest
SHA256 5b6304f5a1f9f98d99b36a9ffd36c20fe2684dea7aef8623ffec1e2dac0066a5
MD5 7d93023583999a4122fc6eaface2e943
BLAKE2b-256 c2a94e279ead3cecdb3d233254b2261f6f8d63abd5e0385f79b56e6fa5e02e74

See more details on using hashes here.

File details

Details for the file dummio-1.6.3-py3-none-any.whl.

File metadata

  • Download URL: dummio-1.6.3-py3-none-any.whl
  • Upload date:
  • Size: 12.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.11

File hashes

Hashes for dummio-1.6.3-py3-none-any.whl
Algorithm Hash digest
SHA256 9b9551128584a178ee505ed7bcdadc984870db33a29460ff530f18923b743d08
MD5 3c2042f93ecf03e0e8dba210ad4e5c7b
BLAKE2b-256 d1642907e18f48f522463831f3d38ed6c99b1b2de32a35ff765a31b1bb5f1456

See more details on using hashes here.

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