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 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/context 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.Lambda()
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.1.tar.gz (6.4 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.1-py3-none-any.whl (10.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyckish-0.1.1.tar.gz
  • Upload date:
  • Size: 6.4 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.1.tar.gz
Algorithm Hash digest
SHA256 f3324a730a0270d0bb2086a69b3c4c45955bc7bb54f66a3e68064cf36665f346
MD5 03216e2b434bfae128b19a08456bf91a
BLAKE2b-256 cd4250b2ca402cbf113de9153679190c8757c48bb44e67d4e7419c5b03bfff03

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyckish-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 10.9 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a507b5c106a2124f15a230a1e5e8c61ac646d94b9bd043ab1665523c35559e31
MD5 ff0aa7ba8959037f7828cc25058e5ff8
BLAKE2b-256 e930e3102590d58c0217806107d57c4b77f37622df13819d018cefe49d5e60b9

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