Saravanan666/pypi-org huggingface dataset:
Package: lambda-packager
lambda-packagerThe purpose of this tool is to avoid writing AWS lambda packaging scripts repeatedly. It is intended to give a consistent output regardless of how you currently define your python dependencies. The tool was built as most existing tools are built into larger frameworks that have other considerations when adoptingCurrently, requires python >=3.8 and later due torequired features of copytreeUsageYou can run with the following:$lambda-packager# or if not in the project directory$lambda-packager--project-directorypath/to/project/dirlambda-packager will include any dependencies defined inpoetry (pyproject.toml)requirements.txtPipenv(Coming soon!)By default lambda-packager will include all src files that match*.pyYou can customise this through config inpyproject.toml:[tool.lambda-packager]src_patterns=["lambda_packager/*.py"]Hidden filesHidden files and folders are ignored by default when including src filesif you wish to disable this, then add the following config to yourpyproject.toml[tool.lambda-packager]ignore_hidden_files=falseIgnore foldersIf there are folders that you wish always exclude, then you can useignore_foldersNote:ignore_foldersis always respected even if there was a match viasrc_patterns[tool.lambda-packager]ignore_folders=["venv"]Ignore hashesOnly has an effect when using poetrypyproject.tomlfilesSkips exporting hashes from poetry to avoid issues when using non-pypi packages
by providing--without-hashesflag when callingpoetry exportSeehttps://github.com/hmrc/python-aws-lambda-packager/issues/2for more info (Note: version number remains pinned when this is enabled)without_hashes=TrueFull usageusage: lambda-packager [-h] [--project-directory PROJECT_DIRECTORY] [-l {DEBUG,INFO,WARNING,ERROR}]

Build code and dependencies into zip files that can be uploaded and run in AWS Lambda

optional arguments:
  -h, --help            show this help message and exit
  --project-directory PROJECT_DIRECTORY
                        The path to the top level project directory. This is where source files and files that declare dependencies are expected to be held. Defaults to current directory
  -l {DEBUG,INFO,WARNING,ERROR}, --log-level {DEBUG,INFO,WARNING,ERROR}
                        set output verbosity, defaults to 'INFO'LicenseThis code is open source software licensed under theApache 2.0 License.
Package: lambda-parse-sqs
Lambda Parse SQS MessagesWhen creating a Lambda subscription to consume SQS events, it's possible to receive multiple messages at once function invocation. So, its necessary to parse message body and iterate over multiple events.pipinstalllambda-parse-sqsfromlambda_parse_sqsimportparse_messagesdeflambda_handler(event,context):messages=parse_messages(event)formessageinmessages:# Do wethever you want
Package: lambdapdk
Lambdapdk IntroductionThe Lambdapdk project includes a number of open source Process Design Kits (PDKs). The original source of these PDKs is documented in the README file for each PDK. Cell level mapping is included to the generic technology independentLambdaliblibrary.Lambdapdk is supported by theSiliconCompilerproject.Supported PDKs:ASAP7FreePDK45Skywater130Global Foundries 180LicenseApache License 2.0Specific PDK licences can be found in their respective folders.Issues / BugsWe useGitHub Issuesfor tracking requests and bugs.
Package: lambda-pkg-resources
lambda-pkg-resourcesAn extension topkg_resourcesthat provides for dist-info (standardwhl) installation of packages and for exclusion of unwanted or unnecessary packagesThe AWS Lambda execution environment inherently provides a number of Python packages, with the two most important of these beingboto3andbotocore. The combination of these (and their dependencies) are several MB of package storage.Many of the Python open-source packages built to work with AWSinstall_requirestheboto3package. While this is appropriate for non-Lamdba usage, it presents two problems when used in a Lambda function.The first problem is bloat of the Lambda function package, leading to longer cold-start times and an inability to use the Lambda console to manage the code in the function.The second problem is that the version ofboto3included in the Lambda package necessarily "drifts" from the version of the AWS API that it is attempting to call. This can lead to strange errors where the Lambda function starts throwing strange errors or simply failing to execute appropriately (sometimes with no exceptions thrown).This library allows for the programatic creation of Lambda funciton and layer packages that install what is required for the function/layer to run while excluding, anywhere within the dependency tree, the Python packages that are already provided by the AWS Lambda execution environment. It can additionally be used programatically to exclude packages in other execution environments if desired.This library provides three components that work in conjunction with the standardpkg_resourcesPython package to perform a dist-info install of dependent packages and allow for exclusion of packages that are not desired.LAMBDA_EXCLUDESA global variable that is asetof the current package names provided by the AWS Lambda execution environment.ExcludesWorkingSetExtendsWorkingSetand performs a dist-info install of packages via the overriddenresolvemethod.DistInstallerAn installer to that can be used in theresolvemethod of eitherWorkingSetorExcludesWorkingSetthrough the use of thefetch_distmethod.Example Usagefromlambda_pkg_resourcesimportDistInstaller,ExcludesWorkingSet,LAMBDA_EXCLUDESfrompkg_resourcesimportparse_requirementsws=ExcludesWorkingSet(entries=["package/install/directory"],excludes={"six"},)di=DistInstaller("package/install/directory")ws.resolve(parse_requirements(["watchtower","python-jose"]),installer=di.fetch_dist,replace_conflicting=True)This will installwatchtowerandpython-josein "packages/install/directory", excluding the packagesixanywhere it is found in the dependency tree.This package is used inlambda-setuptoolsto remove all of the libraries listed inLAMBDA_EXCLUDESfrom the
built package or library using theldistcommand.
Package: lambda-project-creator
lambda-project-creator===============Easily and quickly command line utility creating Lambda Project for lambda-uploader(https://pypi.python.org/pypi/lambda-uploader).Installation~~~~~~~~~~~~The latest release of lambda-project-creator can be installed via pip:::pip install lambda-project-creatorAn alternative install method would be manually installing it leveraging``setup.py``:::git clone https://github.com/cloudfish7/lambda-project-creatorcd lambda-project-creatorpython setup.py installCommand Line Usage~~~~~~~~~~~~~~~~~~To create Lambda Project simply, run following command.. code:: shelllambda-project-creator -p sampleprjGet created following file and directory. Also get installed lambda-uploader... code:: shellsampleprj├── .venv_sampleprj├── lambda.json├── requirement.txt└── lambda.py
Package: lambda-proxy-cache
lambda-proxy-cacheAdd a caching layer tolambda-proxyInstall$pipinstall-Upip
$pipinstalllambda-proxy-cacheOr install from source:$gitclonehttps://github.com/vincentsarago/lambda-proxy-cache.git
$cdlambda-proxy-cache
$pipinstall-Upip
$pipinstall-e.Usagefromlambda_proxy_cache.proxyimportAPIfromlambda_proxy_cache.backends.memcacheimportMemcachedCacheapp=API(name="app",cache_layer=MemcachedCache("MyHostURL"))@app.get('/user/<name>')defprint_name(name):# Do something here...return('OK','plain/text',name)# By adding `no_cache=True` we tell the proxy to not use the cache@app.get('/user/<name>/id',no_cache=True)defprint_id(name):# Do something here...return('OK','plain/text',id)Contribution & DevellopementIssues and pull requests are more than welcome.Dev install & Pull-Request$gitclonehttps://github.com/vincentsarago/lambda-proxy-cache.git
$cdlambda-proxy-cache
$pipinstall-e.[dev]This repo is set to use pre-commit to runflake8,pydocstringandblack("uncompromising Python code formatter") when committing new code.$pre-commitinstall
$gitadd.
$gitcommit-m'my change'black.........................PassedFlake8........................PassedVerifyingPEP257Compliance...Passed
$gitpushorigin
Package: lambda-pyskel
lambda-pyskelCreate python AWS Lambda skeleton from templates.Shameless inspiration from @sgillieshttps://github.com/mapbox/pyskelInstallYou can install lambda-pyskel using pip$pipinstall-Upip
$pipinstalllambda-pyskelor install from source:$gitclonehttps://github.com/vincentsarago/lambda-pyskel.git
$cdlambda-pyskel
$pipinstall-Upip
$pipinstall-e.TemplatesThreedifferent templates are available:simple: simple python lambda functionrasterio: include rasterio wheelsgdal: include custom gdal (2.4.1) installationfrom remotepixel docker imageEach templates has the following structure::pyskel/                : main module
    __init__.py
    handler.py         : handler function
tests/                 : python tests
    test_handler.py
    test_mod.py
Dockerfile             : Dockerfile to create the package.zip
LICENSE                : BSD-2 license file
Makefile               : make commands to create/tests the packages
README.md             : Readme
setup.py               : Python setup
tox.ini                : tox templateDeployement ToolkitIn addition to python module templates, lambda-pyskel can also add
configuration files forserverlessorkestoolkit.kes:http://devseed.com/kes/serverless:https://serverless.comUsage$lps--help
Usage:lps[OPTIONS]NAMECreatenewpythonAWSLambdaskeleton.

Options:--versionShowtheversionandexit.--template[simple|rasterio|gdal]Usespecifictemplate(default:'simple')--serverless-toolkit[kes|serverless]Adddeployementtoolkit--helpShowthismessageandexit.Create a python lambda function with rasterio$lpsyo--templaterasterio
$ls-1yoDockerfileLICENSEMakefileREADME.rstsetup.pytests/tox.iniyo/# edit yo/handler.py and setup.py$makebuildContribution & DevellopementIssues and pull requests are more than welcome.Dev install & Pull-Request$gitclonehttps://github.com/vincentsarago/lambda-pyskel.git
$cdlambda-pyskel
$pipinstall-e.[dev]Python3.6 onlyThis repo is set to usepre-committo runflake8,pydocstringandblack("uncompromising Python code formatter") when committing new code.$ pre-commit install
$ git add .
$ git commit -m'my change'
black....................................................................Passed
Flake8...................................................................Passed
Verifying PEP257 Compliance..............................................Passed
$ git push origin
Package: lambda-pyutils
Python utility library for machine learningOpencvDnn based face detector:Example usage:from pyutils.cvfacedetector.facedetector import FaceDetector
faceDetector = FaceDetector(confidence=0.6) # pass optional confidence

results = faceDetector.detectFaces(img) # returns list of (face, box) for each detected face
for face, box, confidence in results:
    print('face', face.shape)
    print('box', box)
    print('confidence', confidence)

> face (235, 235, 3)
> box [73, 105, 235, 235]
> confidence 0.9877282Building and publishing the build# create virtual environment
python -m virtualenv venv
./venv/scripts/activate.ps1 (or source in linux)
pip install -r requirements.txt
python -m build

# upload to test.pypi.org   
python -m twine upload --repository testpypi dist/*

# upload to pypi.org
python -m twine upload dist/*Installing the packageFrom test.pypi.org:pip install -i https://test.pypi.org/simple/ lambda-pyutilsFrom pypi.org:pip install lambda-pyutils
Package: lambdarado
Lambdarado puts together:AFlaskapp written in PythonADocker imagethat contains the app code and dependenciesAWS Lambda + AWS Gateway to run the app in the AWSWerkzeugto test app locallyIt runs the relevant code depending on where it runs.On the local computer, it runs
the a debug server, serving requests to127.0.0.1with yourapp. You can start it directly (python3 main.py) or from a
container (docker run ...) to test the app.In the AWS Cloud the requests are handled with the sameapp, but in a
different way. Lambdarado creates
ahandler,
that is compatible with the combination of API Gateway + Lambda.Install$pip3installlambdaradoConfigureDockerfile:FROMpublic.ecr.aws/lambda/python:3.8# ... here should be the code that creates the image ...ENTRYPOINT["python","main.py"]You build the imageas usual,
but theENTRYPOINTis just a call to a.pyfile in the project root.
And there is noCMD.main.pyfromlambdaradoimportstartdefget_app():# this function must return WSGI app, e.g. Flaskfrommy_app_moduleimportappreturnappstart(get_app)When starting the Lambda function instance, theget_appmethod will runonce,
but themain.pymodule will be importedtwice. Make sure that the app is only created
whenget_appis called, not whenmain.pyis imported.In other words, simply runningpython3 main.pywithout callingstartshould
NOT do anything heavy and probably should not even declare or import theapp.RunLocal debug serverRunning shell command on development machine:$ python3 main.pyThis will start Werkzeug server listening tohttp://127.0.0.1:5000.Local debug server in DockerCommand-line:$dockerrun-p5005:5000docker-image-nameThis will start Werkzeug server listening tohttp://0.0.0.0:5000(inside the docker). The server is accessible ashttp://127.0.0.1:5005from the development (host) machine.Production server on AWS LambdaAfter deploying the same image as a Lambda function, it will serve the requests
to the AWS Gateway with yourapp.You should connect the AWS Gateway to your Lambda function. For the function
to receive all HTTP requests, you may need to redirect the/{proxy+}route
to the function and makelambda:InvokeFunctionpolicy less restrictiveUnder the hood:Theawslambdaricwill receive
requests from and send requests to the Lambda serviceTheapig_wsgiwill translate requests
received byawslambdaricfrom the AWS Gateway. So your application doesn't
have to handle calls from the gateway directly. For the application, requests
will look like normal HTTP
Package: lambda-repl
lambda_replThelambda_replpackage contains aREPLfor thelambda calculus.To use it, executelambda-replorpython3 -m lambda_repland enter commands.RequirementsPython >= 3.10 and the packageslambda_calculusandlarkare required to use this package.Installationpython3-mpipinstalllambda-replExamplespython3 -m lambda_repl
Welcome to the the Lambda REPL, type 'help' for help
λ alias I = \x.x
λ alias K = λx.λy.x
λ import SUCC = lambda_calculus.terms.arithmetic.SUCCESSOR
λ aliases
I = (λx.x)
K = (λx.(λy.x))
SUCC = (λn.(λf.(λx.(f ((n f) x)))))
λ trace K a b
β ((λy.a) b)
β a
λ exit
Exiting REPL...
Package: lambda-requests
Lambda-requests use the well familiar requests library to access your HTTP
enabled AWS Lambda functions.Quick startInstallationpipintalllambda-requestsUsage>>>importlambda_requests>>>lr=lambda_requests.Session()>>>lr.get("http+lambda://flaskexp-test/test/foo")<Response[200]>In short, start a lambda_requests.Session() and then access you lambdas by
passinghttp+lambda://{name-of-lambda-function}/…as the uri to the commonrequestsmethods such asget,postand the usual parameters such as query
strings, form data and so on.Lambda authorization is configured viaboto3, and can be set up usingenvironment variablesor aconfiguration file. Configuration file is
recommended. Example credential file ~/.aws/credentials:[default]aws_access_key_id=XXXXXXXXXXXXXXXXXXXXaws_secret_access_key=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXSimilar to authorization, region can be configured either via theenvironment
variableAWS_DEFAULT_REGION,configuration file. Region can also be set
on initialization ofSession(region=”us-west-2”). Example configuration
file ~/.aws/config:[profile default]region=us-west-2The lambdas must supportproxy integration, which is used commonly by frameworks
such asZappa,Mangum.WhyIn using REST microservice architecture it is important to be able to
conveniently make calls from one service to another. To use this pattern
in AWS serverless ecosphere along with Lambda one is practically forced
to stand up an API Gateway in front of the lambda. This has several distinct
disadvantages, all mostly along the lines of security.API Gateway publicly exposes endpointsAPI Gateway uses own authentication / authorization schema. While Lambda
already supplies us with IAM.Extra dependencies in call chain. While availability is high, latency may
still be of concern.Over all, to reduce exposure of private sub-services, re-use IAM authentication
/ authorization and reduce latency.How does its workSimple, we register a new protocol name with requests and use a lambda
specifictransport adapterwhich translates a requests request
tolambda invokecompatible with AWS API Gateway simple proxy format.LimitationsFollowing functionality has not been tested and is likely to not be functional:CookiesBasicauth
Package: lambdarest
lambdarestPython routing mini-framework forAWS Lambdawith optional JSON-schema validation.Featureslambda_handlerfunction constructor with built-in dispatcherDecorator to register functions to handle HTTP methodsOptional JSON-schema input validation using same decoratorMerchandise ❤️You can support the development bybuying a wonderful cuporbuy coffee for the maintainers cupExternal articles / tutorialsdevgrok.com: Create a Private Microservice Using an Application Load BalancerArticle about how to uselambdarestwithAWS Application Load Balancerrockset.com: Building a Serverless Microservice Using Rockset and AWS LambdaArticle about how to set uplambdarestin AWS infrastructureOther articles? add themhereInstallationInstall the package fromPyPIusingpip:$pipinstalllambdarestGetting StartedThis module helps you to handle different HTTP methods in your AWS Lambda.fromlambdarestimportlambda_handler@lambda_handler.handle("get")defmy_own_get(event):return{"this":"will be json dumped"}##### TEST #####input_event={"body":'{}',"httpMethod":"GET","resource":"/"}result=lambda_handler(event=input_event)assertresult=={"body":'{"this": "will be json dumped"}',"statusCode":200,"headers":{}}DocumentationSeedocsfordocumentation and examplescovering amongst:Advanced usage exampleQuery paramsHeaders and MultiValueHeadersRoutingAuthorization ScopesException HandlingAWS Application Load BalancerCORSAnormal unittest behaviour withlambda_handlersingletonBecause of python unittests leaky test-cases it seems like you shall beware ofthis issuewhen using the singletonlambda_handlerin a multiple test-case scenario.TestsUse the following commands to install requirements and run test-suite:$pipinstall-e".[dev]"$blacktests/lambdarest/
$rm-ftest_readme.py
$pytest--doctest-modules-vvvFor more info seeContributing...ChangelogSeeHISTORY.mdContributorsThanks for contributing!@sphaugh,@amacks,@jacksgt,@mkreg,@aphexer,@nabrosimoff,@elviejokike,@eduardomourar,@devgrok,@AlbertoTrindade,@paddie,@svdgraaf,@simongarnier,@martinbuberl,@adamelmore,@sloevWanna contribute?And by the way, we have aCode Of Friendlyhood!
Package: lambda-router
lambda_router: Python Helpers for AWS Lambdaslambda_routeris a Python package that provides a few helpers for writing Python-based AWS Lambda functions.Its main goal is to reduce the boilerplate code when writing lambda functions that need to handle multiple routes.Getting StartedInstall with:$pipinstalllambda_routerCreating a basic, single-route app:importlambda_routerconfig=lambda_router.Config()# Load all environment variables prefix with JSR_.config.load_from_environment(prefix="JSR_")app=lambda_router.App(name="example_lambda",config=config)app.route()defmain(event):# This is the main route of your lambdareturn{"message":"success"}Or a multi-route app that uses thetypefield in the lambda event for routing:importlambda_routerconfig=lambda_router.Config()# Load all environment variables prefix with JSR_.config.load_from_environment(prefix="JSR_")app=lambda_router.App(name="example_lambda",config=config,route=lambda_router.routers.EventField(key="type"))app.route("route_one")defmain(event):return{"message":"success from route_one"}app.route("route_two")defmain(event):return{"message":"success from route_two"}ContributingUsepoetryto install the dev requirements:$poetryinstallInstall the git pre-commit hooks:$poetryrunpre-commitinstall
Package: lambda-run
lambda-runrun python code or shell commands on aws lambda invoke contextinstall:# use bare package for production
$ pip install lambda-run

# use to install dev dependencies
# needed to execute commands from cli 
$ pip install lambda-run[cli]usage:wrap your lambda function like this:importlambda_run# wrapping will catch 'lambdaRun' events# otherwise it will pass the event forward@lambda_run.wrap_handlerdeflambda_handler(event,context):# your regular lambda handler...print(event,context)return'OK'execute commands from cli:# set AWS env vars for boto3exportAWS_PROFILE=profileAWS_DEFAULT_REGION=eu-west-1# Usage: lambda-run [OPTIONS] FUNCTION_NAME [PAYLOAD]# attach payload directly as last argumentlambda-run-mpythonmy-lambda'import sys; print(sys.path)'# or by posix pipe/redirect, for example:# pipe itecho'import sys; print(sys.path)'|lambda-run-mpythonmy-lambda# oneliner redirectlambda-run-mshellmy-lambda<<<'python manage.py createsuperuser'# or multilinelambda-run-mpythonmy-lambda<<EOFfor i in range(10):print(i)EOF# or file contentlambda-run-mshellmy-lambda<bash-script.sh
Package: lambda-runtimes
Lambda RuntimesPython library for getting a list of all Lambda runtimes from AWS's documentation page, and interacting with it.UsageInstall the requirements withpip3 install -r requirements.txtBasic UsageThe LambdaRuntimes library implements a list of LambdaRuntimes fetched from the AWS documentation website. Internally, it is just a list of results parsed from the tables on the Lambda runtimes page with some helper functions to make working with them easier.Import the library at the top of your python file and create an instance of theLambdaRuntimesclass. This fetches a list of the runtimes from the AWS docs page.fromlambdaruntimesimportLambdaRuntimesruntimes=LambdaRuntimes()You can optionally specify another location for the source docs page if you have a cache or proxy.fromlambdaruntimesimportLambdaRuntimesruntimes=LambdaRuntimes(lambda_runtime_docs_url="http://localhost:8000/lambda-runtimes.html")Iterating Over RuntimesTheLambdaRuntimesclass is a valid iterator, so you can loop over all runtimes using normal Python flow control tools.fromlambdaruntimesimportLambdaRuntimesruntimes=LambdaRuntimes()forruntimeinruntimes:print(runtime)You can also directly access theruntimesproperty of the instance, and iterate over it instead.Getting a Single RuntimeYou can query for a runtime by its identifier using theget_runtime()function.runtimes.get_runtime("nodejs")>>>LambdaRuntime(name='Node.js 0.10',identifier='nodejs',sdk=None,os='Amazon Linux',arch=None,deprecation_phase_1=datetime.datetime(2016,10,31,0,0),deprecation_phase_2=datetime.datetime(2016,10,31,0,0),runtime_is_expiring=True,runtime_is_expired=True)Checking if a Runtime is ExpiringYou can query if a runtime has a set expiry date by its identifier using theruntime_is_expiring()function.runtimes.runtime_is_expiring("nodejs")>>>TrueChecking if a Runtime has ExpiredYou can query if a runtime has expired by its identifier using theruntime_is_expired()function.runtimes.runtime_is_expired("nodejs")>>>TrueThe LambdaRuntime Data ClassThe iterables and functions in the library mostly return instances of theLambdaRuntimeclass. This data class has fields that reflect the data on the AWS documentation website.This data class is made with Pydantic and so type hints should work in your IDE of choice.Each instance will have at least the following properties:name:stridentifier:strsdk:Optional[str]os:strarch:Optional[str]deprecation_phase_1:Optional[datetime]=Nonedeprecation_phase_2:Optional[datetime]=Noneruntime_is_expiring:boolruntime_is_expired:bool