Skip to main content

No project description provided

Project description

Tests

A Box

What is this?

A basic Content Addressable aRchive (CAR) v1 reader and writer. Enough to get you reading from the ATProto firehose and emitting blocks from your own PDS. More details on ATProto's CAR usage here.

Installation

pip install carbox

Basic Usage

from datetime import datetime
from carbox.car import Block, read_car, write_car
from carbox.message import read_event_pair
import dag_cbor

# Where websocket_msg is a message comes from the firehose.
header, event = read_event_pair(websocket_msg)
roots, blocks = read_car(event['blocks'])
records = [dag_cbor.decode(block) for block in blocks]

record = {
  '$type': 'app.bsky.feed.post',
  'text': 'Hello, world!',
  'createdAt': datetime.now().isoformat(),
}
block = Block(decoded=record)
car_bytes = write_car(block.cid, [block])

Changelog

0.3 - 2024-03-16

  • Relax dependencies to allow minor version upgrades.

0.2 - 2023-09-07

Add write support via car.write_car. See usage example above for details.

0.0.1 - 2023-05-07

Initial release.

Release instructions

Here's how to package, test, and ship a new release.

  1. Run the unit tests.

    source [path_to_virtualenv]/bin/activate.csh
    pytest
    
  2. Bump the version number in pyproject.toml. git grep the old version number to make sure it only appears in the changelog. Change the current changelog entry in README.md for this new version from unreleased to the current date.

  3. git commit -am 'release vX.Y'

  4. Upload to test.pypi.org for testing.

    poetry build
    setenv ver X.Y
    twine upload -r pypitest dist/carbox-$ver*
    
  5. Install from test.pypi.org.

    cd /tmp
    python3 -m venv local
    source local/bin/activate.csh
    # make sure we force pip to use the uploaded version
    pip3 uninstall carbox
    pip3 install --upgrade pip
    pip3 install -i https://test.pypi.org/simple --extra-index-url https://pypi.org/simple carbox==$ver
    deactivate
    
  6. Smoke test that the code trivially loads and runs:

    from carbox.car import Block, read_car, write_car
    
    block = Block(decoded={'foo': ['bar', 2, 3.14]})
    car_bytes = write_car([block.cid], [block])
    assert read_car(car_bytes) == ([block.cid], [block])
    
  7. Tag the release in git. In the tag message editor, delete the generated comments at bottom, leave the first line blank (to omit the release "title" in github), put ### Notable changes on the second line, then copy and paste this version's changelog contents below it.

    git tag -a v$ver --cleanup=verbatim
    git push && git push --tags
    
  8. Click here to draft a new release on GitHub. Enter vX.Y in the Tag version box. Leave Release title empty. Copy ### Notable changes and the changelog contents into the description text box.

  9. Upload to pypi.org!

    twine upload dist/carbox-$ver*
    

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

carbox-0.3.tar.gz (13.4 kB view details)

Uploaded Source

Built Distribution

carbox-0.3-py3-none-any.whl (13.5 kB view details)

Uploaded Python 3

File details

Details for the file carbox-0.3.tar.gz.

File metadata

  • Download URL: carbox-0.3.tar.gz
  • Upload date:
  • Size: 13.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for carbox-0.3.tar.gz
Algorithm Hash digest
SHA256 f19eb5a456a378073e6ca31c4ba0a6a30249f49c94850c60e5aecb2dcc5544ba
MD5 bc3046598c9bd154884434c3dd6aceca
BLAKE2b-256 be0c38765d95b1b96c87f566b7b157d9608d77b0190883af4cf6863bee299f27

See more details on using hashes here.

File details

Details for the file carbox-0.3-py3-none-any.whl.

File metadata

  • Download URL: carbox-0.3-py3-none-any.whl
  • Upload date:
  • Size: 13.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for carbox-0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 3ca4d2a3e50ff4c807673e354dc6704c9ec8b61929629dbfa803d4e56e87451d
MD5 5bfea7285705ef5113029e9628cd670b
BLAKE2b-256 dd8e81fa3a426c135bfc17a972e9f8a9fd14cc5af17bef756d7b2d2e061d7001

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page