Skip to main content

PartD

Build Status Version Status

Key-value byte store with appendable values

Partd stores key-value pairs. Values are raw bytes. We append on old values.

Partd excels at shuffling operations.

Operations

PartD has two main operations, append and get.

Example

  1. Create a Partd backed by a directory:

    >>> 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 bytes associated to keys:

    >>> p.get('x')         # One key
    b'Hello world!'
    
    >>> p.get(['y', 'x'])  # List of keys
    [b'123456', b'Hello world!']
  4. Destroy partd dataset:

    >>> p.drop()

That’s it.

Implementations

We can back a partd by an in-memory dictionary:

>>> p = Dict()

For larger amounts of data or to share data between processes we back a partd by a directory of files. This uses file-based locks for consistency.:

>>> p = File('/path/to/dataset/')

However this can fail for many small writes. In these cases you may wish to buffer one partd with another, keeping a fixed maximum of data in the buffering partd. This writes the larger elements of the first partd to the second partd when space 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:

    >>> p = Buffer(Dict(), File(), available_memory=2e9)  # 2GB memory buffer
    >>> s = Server(p, address='ipc://server')
  • Worker processes:

    >>> p = Client('ipc://server')  # Client machine talks to remote server

Encodings and Compression

Once we can robustly and efficiently append bytes to a partd we consider compression and encodings. This is generally available with the Encode partd, which accepts three functions, one to apply on bytes as they are written, one to apply to bytes as they are read, and one to join bytestreams. Common configurations already exist for common data and compression formats.

We may wish to compress and decompress data transparently as we interact with a partd. Objects like BZ2, Blosc, ZLib and Snappy exist and take another partd as an argument.:

>>> p = File(...)
>>> p = ZLib(p)

These work exactly as before, the (de)compression happens automatically.

Common data formats like Python lists, numpy arrays, and pandas dataframes are also supported out of the box.:

>>> p = File(...)
>>> p = NumPy(p)
>>> p.append({'x': np.array([...])})

This lets us forget about bytes and think instead in our normal data types.

Composition

In principle we want to compose all of these choices together

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

  2. Encoding: Pickle, Numpy, Pandas, …

  3. Compression: Blosc, Snappy, …

Partd objects compose by nesting. Here we make a partd that writes pickle encoded BZ2 compressed bytes directly to disk:

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

We could construct more complex systems that include compression, serialization, buffering, and remote access.:

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

>>> client = Pickle(Snappy(Client(server.address)))
>>> client.append({'x': [1, 2, 3]})

Metadata

Release files for partd 0.3.4

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.4
File Size Uploaded
partd-0.3.4.tar.gz 15.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for partd 0.3.4
File Interpreter ABI Platform
partd-0.3.4-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 35.3 kB

Release files / partd-0.3.4.tar.gz

Download URL partd-0.3.4.tar.gz
Size 15.7 kB
Tags Source
SHA-256 checksum
How to use checksums
7dce2e5e95c48d8da1b0ea05efcfff1150731e3f4081aecf9d5e8337a30ad24e
BLAKE2b-256 checksum
How to use checksums
810be69d4e325a7b2d0cd5b6a7ff8f9c620c78c21d0f20d95718ff0caad71435
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / partd-0.3.4-py2.py3-none-any.whl

Download URL partd-0.3.4-py2.py3-none-any.whl
Size 19.6 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
aab32734ffd3c0e431cc251ddb66f853a100346eefeb64164dca695b8be0fb51
BLAKE2b-256 checksum
How to use checksums
fe822c3da6299fcba5e2d1723663f78a7cd49dcaa8b3a4f2fea12bb3c1067744
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

This release

0.3.4 This release

2 release files

0.3.3

2 release files

0.3.2

1 release file

0.3.1

1 release file

0.3.0

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