Skip to main content

High level utilities for a subset of boto3 operations common for AWS serverless development in Python.

Project description

xoto3

xoto3 (pronounced zoto-three) is a layer of useful micro-utilities for boto3 (the AWS Python library) particularly suitable for serverless development.

These come from years of experience developing a serverless platform at XOi Technologies, and represent real production code.

Installing

Get started quickly by installing the package with pip install xoto3

Features

Some of the features included:

  • A more general purpose boto3 client API paginator.

  • Higher-level abstractions for DynamoDB, including:

    • pure data transformation safeguards against various sorts of data that DynamoDB won't accept.
    • an multi-item, multi-table composable, retrying, transaction wrapper for TransactWriteItems, allowing arbitrary writes (up to the built in API limitations) to multiple databases to be expressed as pure Python.
    • a transactional single-item update that allows you to express your single-item update transformation in pure Python.
    • transparent BatchGet and BatchWrite utilities that work around the many annoyances of boto3 and DynamoDB itself.
    • composable query interfaces that make writing basic queries against DynamoDB fun.

    see readme for examples

  • Cloudwatch Insights and Log Groups Query URL formatters.

  • General-purpose AWS Lambda finalization code, to make sure buffered IO gets a chance to flush before your Lambda gets paused.

  • Wrapper for SSM parameter puts and gets, including built-in support for parameter values larger than what SSM will accept by automatically splitting your values and reconstructing them on gets.

Various other utilities are included as well - feel free to poke through the source code.

None of these features "rely" on any of the others, so all of the power is left in your hands. This is not a framework; just a set of mostly pure-functional utilities, with a couple of handy wrappers for boto3 functions that perform IO.

Other Utilities

Some fairly general-purpose utilities are also included. See the readme for more details.

Some highlights:

  • tree_map - recursively map through a tree of Python builtins
  • lazy - general purpose lazy-loading container
  • Various serialization utilities (datetimes, decimals, JSON helpers)
  • pipe_multiprocessing - a Process Pool for places like AWS Lambda where Python's built-in shared memory-dependent Pool does not work.

Development

Getting set up

This repository leverages Poetry >= 2.3. Install it with pipx install "poetry>=2.3,<2.4" Then simply run poetry install. You'll want to periodically run poetry update as well.

The poetry.lock file is not version-controlled, and shouldn't be (there's an argument to be made about pinning dev dependencies)

Versioning

The version is set in pyproject.toml. Update it with poetry version (major|minor|patch|<x.y.z>).

Testing

You can run all unit tests with poetry run pytest tests.

You can additionally include all the DynamoDB integration tests by setting some environment variables:

XOTO3_INTEGRATION_TEST_DYNAMODB_ID_TABLE_NAME: the name of a DynamoDB table with a primary key that is a partition key of id and no range key. XOTO3_INTEGRATION_TEST_NO_RANGE_KEY_INDEX_HASH_KEY: the name of an attribute which is the partition key of a GSI with no range key.

If you don't currently have a table viable for testing, you can use the following script to easily create one: poetry run python ./scripts/create_integration_test_table.py

Development

Writing tests

Any new changes should be accompanied by unit tests. Integration tests should also be included where they are helpful.

Integration tests should make use of environment variables and pytest's ability to skip a test in the event that an environment variable is not set.

Additionally, pytest is configured to run all tests in parallel, so any integration test you write must be independent of any other test, and must not leave behind test data.

Your integration tests should be written alongside the unit tests. We do not keep them in a separate folder.

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

xoto3-2.1.0.tar.gz (76.4 kB view details)

Uploaded Source

Built Distribution

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

xoto3-2.1.0-py3-none-any.whl (107.3 kB view details)

Uploaded Python 3

File details

Details for the file xoto3-2.1.0.tar.gz.

File metadata

  • Download URL: xoto3-2.1.0.tar.gz
  • Upload date:
  • Size: 76.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for xoto3-2.1.0.tar.gz
Algorithm Hash digest
SHA256 e3577ad13f51954226c9d0f19da06aa1d2fd0a894fcde666bdb4088e2ddb4979
MD5 c3b7a05ffce6bf7619bf712c928018db
BLAKE2b-256 e028894533b3e800a9e1e18d8e616c820c5f67f8aa94d335d9a1e223c8e1d6fd

See more details on using hashes here.

File details

Details for the file xoto3-2.1.0-py3-none-any.whl.

File metadata

  • Download URL: xoto3-2.1.0-py3-none-any.whl
  • Upload date:
  • Size: 107.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for xoto3-2.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e6b5b4bc706e25d2d297bf1857cf1639a4b4d7f0a89594e8a3ae35857a3f1121
MD5 f87476f6d04e52ea2092f889c463b33f
BLAKE2b-256 c594c79e91ea2ecc12448bce9d14e897fb678c65a3b0d893e8ec66b0da7e722b

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