Skip to main content

Pyckish is a micro framework to easily extract/validate/parse AWS Event when using AWS Lambdas.

Project description

Pyckish

AWS Lambda Event extractor/parser/validator"

Pyckish is an "extract, parse and validate" solution to allow ease of use when dealing with AWS Lambdas. It aims to make using Lambdas to handle HTTP requests an alternative that works similarly to other frameworks for back-end applications, like FastAPI.

Currently, it can be used to extract HTTP data that comes in the event dictionary. It extracts from the dictionary, parses it and validates it. It relies heavily on Pydantic, and will make your life simpler if you only like to deal with validated and correctly typed data.

Instead of doing this:

def lambda_handler(event: dict, context: dict) -> float:
    auth = event['headers']['authorization_token']
    store = event['pathParameters']['store']
    item = event['body']
    
    user = get_user(auth)
    price = get_price(item, store, user)
    return price

Do this:

import pyckish
from pyckish.http_elements import Body, Header, PathParameter
from my_models import Item

@pyckish.AWSEventExtractor()
def lambda_handler(
        auth: str = Header(alias='authorization_token'),
        store: str = PathParameter(default='my_store'),
        item: Item = Body()
) -> float:
    user = get_user(auth)
    price = get_price(item.dict(), store, user)
    return price

And get validation and parsing free of trouble thanks to integration with Pydantic. Enjoy the advantages of a much more robust codebase, leaving behind having to extract and manage issues related to missing/wrong values.

Motivation

Today, together with AWS API Gateway, it is possible to use only AWS Lambdas as back-end for your application. The problem is, unlike modern Frameworks, like FastAPI and Starlite, using only AWS Lambdas requires you to develop your own solutions for extracting, parsing, validating as well as creating error handling for the inputs of your code. There are solutions that allow you to use ASGI Frameworks with AWS Lambdas, like Mangum. But it is yet another technology that sits above your bulky framework. Personally, I think that the problem could be solved in a more simple and direct manner. Pyckish aims to be that solution.

Using tools like Serverless Framework with its integration with CloudFormation, many AWS Lambdas can be deployed from a single repository. Those "monorepos" solutions could also make heavy use of Pyckish in order to handle its inputs.

Right now, Pyckish is a tiny baby, and I'm not sure of its future. Weather it will become a full Framework with more capabilities than Chalice, or it is going to remain as a simple "extractor/parser/validator" I do not know.

But I encourage you to try, simplicity and types will seduce you into it.

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

pyckish-0.1.0.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

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

pyckish-0.1.0-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file pyckish-0.1.0.tar.gz.

File metadata

  • Download URL: pyckish-0.1.0.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.1 CPython/3.11.1 Linux/5.15.85-1-MANJARO

File hashes

Hashes for pyckish-0.1.0.tar.gz
Algorithm Hash digest
SHA256 935dbdb145b74a202c7a16dda1126d4a21b8e0f76fe6b2a87c200662d3a3aafb
MD5 f41d3f972cfed80b38510901c1fff440
BLAKE2b-256 36c4b3b62e6649ecb029c9ecfec446846ff13696733695a70651db49e98ccc34

See more details on using hashes here.

File details

Details for the file pyckish-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pyckish-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.1 CPython/3.11.1 Linux/5.15.85-1-MANJARO

File hashes

Hashes for pyckish-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4150ca11a337fed9c496bdffa9c22c7d970c8e00a258849442075ea2c79a3915
MD5 f2f0d0f483b1e4069265ea9042ab1a2c
BLAKE2b-256 dea0e6ecf92a81a2b9777d89a52362afc2f3703d711f4e513cc0741f39967107

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