Skip to main content

Build Status

Minimal key-value byte storage with appendable values

Partd stores key-value pairs. The values are raw bytes. We append onto existing values.

Partd is useful for shuffling operations.

API

  1. Create a Partd:

    >>> import partd
    >>> p = partd.File('/path/to/new/dataset/'')
  2. Append key-byte pairs to dataset:

    >>> p.append({'x': b'Hello ', 'y': b'123'})
    >>> p.append({'x': b'world!', 'y': b'456'})
  3. Get all bytes associated to a set of keys:

    >>> p.get(['y', 'x'])
    [b'123456', b'Hello world!']
  4. Idempotently set single key-value pair (no append, no update):

    >>> p.iset('z', b'metadata'])
  1. Destroy partd dataset:

    >>> p.drop()

That’s it.

There is no in-memory state.

Implementations

The reference implementation uses file-based locks. This works surprisingly well as long as you don’t do many small writes.

If you do many small writes then you probably want to cache in memory. Fortunately you can buffer one partd with another, writing only large chunks as necessary when spaces runs low:

>>> p = Buffer(Dict(), File(), available_memory=2e9)  # 2GB memory buffer

You might also want to have many distributed process write to a single partd consistently. This can be done with a server

  • Server Process:

    >>> local_partd = File()
    >>> p = Server(local_partd, address='ipc://server')
  • Worker processes:

    >>> p = Client('ipc://server')
    >>> p.append(...)

Encodings and Compression

Once we can robustly and efficiently append bytes we move on to encoding various things as bytes either with serialization systems like Pickle or MSGPack or with compression routines like zlib, snappy, or blosc. In principle we want to compose all of these choice together

  1. Write policy: Dict, File, Buffer, Client

  2. Encoding: Pickle, Numpy, Pandas, …

  3. Compression: Blosc, Snappy, …

Partd objects compose by nesting for example here we make a server backed by a buffered dict/file combination with a client using snappy compressed pickle data:

>>> server = Server(Buffer(Dict(), File(), available_memory=2e0))

>>> client = Pickle(Snappy(Client(server.address)))

And here a partd that writes pickle encoded BZ2 compressed bytes directly to disk:

>>> p = Pickle(BZ2(File('foo')))

Metadata

Release files for partd 0.3.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 partd 0.3.0
File Size Uploaded
partd-0.3.0.tar.gz 14.8 kB Details

Release files / partd-0.3.0.tar.gz

Download URL partd-0.3.0.tar.gz
Size 14.8 kB
Tags Source
SHA-256 checksum
How to use checksums
41ab11dae0eec877864da36be1df8fc55966c9aadb508a83e229efae33f2b541
BLAKE2b-256 checksum
How to use checksums
b402d409b2d98760951be548f785b9cacd827c635bddddc2b8df4b6e1aa8721b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

1.4.2

2 release files

1.4.1

2 release files

1.4.0

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.3.10

2 release files

0.3.9

2 release files

0.3.8

2 release files

0.3.7

2 release files

0.3.6

2 release files

0.3.5

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

1 release file

0.3.1

1 release file

This release

0.3.0 This release

1 release file

0.2.2

1 release file

0.2.1

1 release file

0.2.0

1 release file

0.1.0

1 release file

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