Skip to main content

Add your description here

Project description

pinexq-procon-io

I/O utilities for the pinexq ecosystem. This package provides reader and writer callables for common data formats — JSON (via Pydantic), Apache Parquet, Matplotlib figures, and Plotly JSON — designed to plug directly into pinexq-procon dataslot annotations.

How readers and writers work with dataslots

In pinexq-procon, a processing step declares its inputs and outputs through @dataslot annotations. Each annotation accepts a reader or writer callable that handles serialization:

  • dataslot.input(reader=...) — the reader is called with a file-like object and must return the deserialized data.
  • dataslot.output(writer=...) — the writer is called with a file-like object and the data to serialize.
  • dataslot.returns(writer=...) — same as output, but for the function's return value.

The functions in pinexq.procon.io follow exactly these signatures (Callable[[IO], T] for readers, Callable[[IO, T], None] for writers) so they can be passed directly to a dataslot annotation.

Example

from pinexq.procon.dataslots import dataslot, MediaTypes
from pinexq.procon.io import pydantic_reader, base_model_dump_json
from pinexq.procon.io.parquet import parquet_buffer_reader, parquet_buffer_writer
from pinexq.procon.io.matplotlib import figure_to_png_buffer
from pydantic import BaseModel


class Config(BaseModel):
    threshold: float


@dataslot.input("config", media_type=MediaTypes.JSON, reader=pydantic_reader(Config))
@dataslot.input("data_in", media_type=MediaTypes.OCTETSTREAM, reader=parquet_buffer_reader)
@dataslot.output("data_out", media_type=MediaTypes.OCTETSTREAM, writer=parquet_buffer_writer)
@dataslot.returns(media_type=MediaTypes.PNG, writer=figure_to_png_buffer)
def process(config: Config, data_in, data_out, **kwargs):
    # config is already deserialized into a Config instance by pydantic_reader
    # data_in is already a pandas DataFrame via parquet_buffer_reader
    filtered = data_in[data_in["value"] > config.threshold]
    # data_out will be serialized to Parquet via parquet_buffer_writer
    data_out = filtered
    # the returned figure will be written as PNG via figure_to_png_buffer
    return create_plot(filtered)

Installation

From GitHub

pip install git+https://github.com/data-cybernetics/pinexq-procon-io.git

Or with uv:

uv add git+https://github.com/data-cybernetics/pinexq-procon-io.git

From source

git clone https://github.com/data-cybernetics/pinexq-procon-io.git
cd pinexq-procon-io
pip install .

Optional extras

The core package only depends on Pydantic. Heavier I/O dependencies are available as optional extras so you only install what you need.

Parquet

Adds support for reading and writing Apache Parquet buffers via pandas and PyArrow.

pip install "pinexq-procon-io[parquet] @ git+https://github.com/data-cybernetics/pinexq-procon-io.git"
from pinexq.procon.io.parquet import parquet_buffer_writer, parquet_buffer_reader

Matplotlib

Adds support for serializing Matplotlib figures to PNG buffers.

pip install "pinexq-procon-io[matplotlib] @ git+https://github.com/data-cybernetics/pinexq-procon-io.git"
from pinexq.procon.io.matplotlib import figure_to_png_buffer

Plotly

Adds support for writing pandas DataFrames as Plotly-compatible JSON (uses scipy sparse arrays internally).

pip install "pinexq-procon-io[plotly] @ git+https://github.com/data-cybernetics/pinexq-procon-io.git"
from pinexq.procon.io.plotly import plotly_json_writer

Installing all extras

pip install "pinexq-procon-io[parquet,matplotlib,plotly] @ git+https://github.com/data-cybernetics/pinexq-procon-io.git"

Usage

JSON / Pydantic helpers

The core module provides helpers for reading and writing JSON via Pydantic models and plain dicts:

from pinexq.procon.io import dict_2_json_writer, base_model_dump_json, pydantic_reader

Parquet helpers (requires parquet extra)

from pinexq.procon.io.parquet import parquet_buffer_writer, parquet_buffer_reader

Matplotlib helpers (requires matplotlib extra)

from pinexq.procon.io.matplotlib import figure_to_png_buffer

Plotly helpers (requires plotly extra)

from pinexq.procon.io.plotly import plotly_json_writer, to_plotly_json

Development

This project uses uv for dependency management.

git clone https://github.com/data-cybernetics/pinexq-procon-io.git
cd pinexq-procon-io
uv sync --all-extras

Namespace package

This package uses PEP 420 implicit namespace packages. The pinexq and pinexq.procon namespaces are shared and can be extended by other distributions in the pinexq family.

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

pinexq_procon_io-0.1.1.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

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

pinexq_procon_io-0.1.1-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file pinexq_procon_io-0.1.1.tar.gz.

File metadata

  • Download URL: pinexq_procon_io-0.1.1.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pinexq_procon_io-0.1.1.tar.gz
Algorithm Hash digest
SHA256 248423610387f2a9a7694ec1c472c953dbe5cfae34b554d9d99b8f99fb1a6b35
MD5 fa5066e79b4132d5bdf868d979497ef2
BLAKE2b-256 73382ee5cc0704999ca72a98dad77741b480b63fb727bc6854a76ca9823ddbac

See more details on using hashes here.

Provenance

The following attestation bundles were made for pinexq_procon_io-0.1.1.tar.gz:

Publisher: publish-pypi.yml on data-cybernetics/pinexq-procon-io

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

File details

Details for the file pinexq_procon_io-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for pinexq_procon_io-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 34e5bb021cea47705f4b8a6b5eb6fad31a0ea8500f99b32c9387c1c1eb025c2f
MD5 7a1e9450512357c160c72e43625c4fb8
BLAKE2b-256 96452aa66ca0858c9df98a2731c5f964e6acce914e25f3fae466ad1d26f776dd

See more details on using hashes here.

Provenance

The following attestation bundles were made for pinexq_procon_io-0.1.1-py3-none-any.whl:

Publisher: publish-pypi.yml on data-cybernetics/pinexq-procon-io

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