Skip to main content

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

Project description

plot

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyckish-0.2.0.tar.gz
  • Upload date:
  • Size: 6.9 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.0.tar.gz
Algorithm Hash digest
SHA256 038cd4907da6597c8866d1df38c8d010d5069b7dcdb0eca18c28a8ee47df9191
MD5 8501e535a9cd797e5eb1ad6327a82fc5
BLAKE2b-256 0735b75b11eac922d6a24249c601ed9a929757fcd8ffd5dc540276c1e02c083e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyckish-0.2.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7fad412ed7580ea17f16415c309dc6525b07a5c636fe59d75d7c544dc4c8574a
MD5 cd8d905c3cd9e8f5bc71e49a21198ea0
BLAKE2b-256 457c0803d641113cdb692e876fcaeec449d9ff4cea5d5666bf460202d6216a3c

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