Skip to main content

Pyckish is an extract/parse/validate solution to allow ease of use when dealing with AWS Lambdas.

Project description

pyckish

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(),
        item: Item = Body()
) -> float:
    user = get_user(auth)
    price = get_price(item, 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 Framework, 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.)

Usage

comming soon...

Lambda Decorator

...

Custom LambdaInputElement

...

Adding Error Handlers

...

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.2.1.tar.gz (7.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.2.1-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyckish-0.2.1.tar.gz
  • Upload date:
  • Size: 7.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.2.1.tar.gz
Algorithm Hash digest
SHA256 73dfb09d566d2a3ca7b94b9ba51e1c4315a5ca25adb8addc5f02743e414deb56
MD5 fb64242c23952b91de40f71758a11fc1
BLAKE2b-256 1b2d72bd3ec8c26d634b350cb2cfaeb3c348374f399f259db6156e69156b992e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyckish-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 11.3 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.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 278aad5652dd5be5ba58d107a483dab4292b9866ad86c222eb5b338b109687f2
MD5 7002853ffec70f7a9ce3d21741e51bef
BLAKE2b-256 d6782bd8a2c05566d6f2fc820537a811c3f3140f80a69418a5d9830c0108662d

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