lambda-packs Precompiled packages for AWS Lambda开源项目

我要开发同款
匿名用户2021年12月02日
62阅读
开发技术JavaScript
所属分类Serverless系统、云计算、Serverless 系统
授权协议MIT License

作品详情

lambda-packs

PrecompiledpackagesforAWSlambda

Howtostarthttps://aws.amazon.com/lambda/andcreate/signinintoaccountLambda>Functions-CreatelambdafunctionBlankfunctionConfiguretriggers-NextConfigurefunctionRuntime-Python2.7LambdafunctionhandlerandroleHandler-service.handlerRole-Createnewrolefromtemplate(s)Rolename-testPolicytemplates-SimpleMicroservicePermissionsAdvancedsettingsMemory(MB)128Timeout1min0secCodeentrytype-Uploada.ZIPfile-choosePack.zipfromrepTest->SaveandtestHowtomodifyModifyservice.pyfilefromsourcesfolderChooseallfilesinsourcesfolderwhencompressing,don'tputitinonefolderUploadzipfileonfunctionpageCurrentpacksSeleniumPhantomJSIntro

SeleniumonPhantomJS.Infact-aready-madetoolforwebscraping.Forexample,thedemonowopensarandompageinWikipediaandsendsitsheader.(PhantomJSatthesametimedisguisesitselfasanormalbrowser,knowshowtologin,clickandfilloutforms)Alsoaddedrequests,soyoucandoAPIrequestsfordifferentresourcestodiscard/takeawaytheinformation.

Usefulforwebtestingandscraping.

Demo

Currentdemoopensrandompagefromwiki(https://en.wikipedia.org/wiki/Special:Random)andprintstitle.

Serverlessstartgitclonehttps://github.com/ryfeus/lambda-packs.gitcdlambda-packs/Selenium_PhantomJS/source/serverlessdeployserverlessinvoke--functionmain--log

YoucanalsoseetheresultsfromtheAPIGatewayendpointinawebbrowser.

Documentation

https://selenium-python.readthedocs.io/

Pyresttest+WRKIntro

Whatdoesthelambdahavetodowithit?InanutshellonAWSinoneregionyoucansimultaneouslyrun200lambdas(moreifyouwritetosupport).Lambdaworksin11regions.Soyoucanruninparallelmorethan2000lambdas,eachofwhichwillconductloadtestingofyourservice.Fiveminutesofsuchtestingwillcostjustonedollar.

Demo

Demointhispackagetriestosendrequeststogithub.comfor5secondswith1connectionandalsoconductpyresttestdummytest.

ToolsWRK(https://github.com/wg/wrk)-themaintoolforloadtesting.Itworkswithmultiplethreads,youcanspecifythenumberofconnectionsandlengthoftheload.Formorefine-tuning,youcanuseLuaJITscripts(https://www.lua.org/).Pyrestest(https://github.com/svanoort/pyresttest)isahandytoolfortestingthefullpipelineoftheAPI.Forexample,theuserregisters,thenusestheapikeytocreatetasks/makenotes/downloadsfiles,thenreadsthem,thendeletesthem.Documentation

https://github.com/wg/wrk

https://github.com/svanoort/pyresttest

Lxml+requestsIntro

PackageforparsingstaticHTMLpages.DifferencehereisthatitworksfasterandconsumeslessmemorythanPhantomJSbutislimitedintermswebsitesitcanparseandotherfeatures.

Serverlessstartserverlessinstall-uhttps://github.com/ryfeus/lambda-packs/tree/master/Lxml_requests/source-nlxml-requestscdlxml-requestsserverlessdeployserverlessinvoke--functionmain--logBuildpackwgethttps://github.com/ryfeus/lambda-packs/blob/master/Lxml_requests/buildPack.shdockerpullamazonlinux:latestdockerrun-v$(pwd):/outputs--namelambdapackgen-damazonlinux:latesttail-f/dev/nulldockerexec-i-tlambdapackgen/bin/bash/outputs/buildPack.shTools

Lxml3.7.1

Documentation

https://lxml.de/

TensorflowIntro

OpensourcelibraryforMachineIntelligence.BasicallyrevolutionizedAIandmadeitmoreaccessible.Usingtensorflowonlambdaisnotasbadasitmaysound-forsomesimplemodelsitisthesimplestandthecheapestwaytodeploy.

Demo

AshelloworldcodeIusedrecognitionofimagestrainedonimagenet(https://www.tensorflow.org/tutorials/image_recognition).Giventhepricetaglambdaonerun(recognitionofonepicture)willcost$0.00005.Thereforeforadollaryoucanrecognize20,000images.Itismuchcheaperthanalmostanyalternatives,thoughcompletelyscalable(200functionscanberuninparallel),andcanbeeasilyintegratedintocloudinfrastructure.Currentdemodownloadsimagefromlink'imagelink'fromeventsource(ifempty-thendownloadshttps://s3.amazonaws.com/ryfeuslambda/tensorflow/imagenet/cropped_panda.jpg)

Tools

Tensorflow1.4.0

Documentation

https://www.tensorflow.org/tutorials/image_recognition

Nightlyversion

Nightlyversionarchiveismorethan50MBinsizebutitisstilleligibleforusingwithAWSLambda(thoughyouneedtouploadpackthroughS3).Formorereadhere:

https://hackernoon.com/exploring-the-aws-lambda-deployment-limits-9a8384b0bec3

Serverlessstartserverlessinstall-uhttps://github.com/ryfeus/lambda-packs/tree/master/tensorflow/source-ntensorflowcdtensorflowserverlessdeployserverlessinvoke--functionmain--logBuildpack

forPython2:

wgethttps://raw.githubusercontent.com/ryfeus/lambda-packs/master/Tensorflow/buildPack.shwgethttps://raw.githubusercontent.com/ryfeus/lambda-packs/master/Tensorflow/index.pydockerpullamazonlinux:latestdockerrun-v$(pwd):/outputs--namelambdapackgen-damazonlinux:latesttail-f/dev/nulldockerexec-i-tlambdapackgen/bin/bash/outputs/buildPack.sh

forPython3:

wgethttps://raw.githubusercontent.com/ryfeus/lambda-packs/master/Tensorflow/buildPack_py3.shwgethttps://raw.githubusercontent.com/ryfeus/lambda-packs/master/Tensorflow/index_py3.pydockerpullamazonlinux:latestdockerrun-v$(pwd):/outputs--namelambdapackgen-damazonlinux:latesttail-f/dev/nulldockerexec-i-tlambdapackgen/bin/bash/outputs/buildPack_py3.sh

Note:RememberYoushouldsetpython3.6forAWSLambdafunctionenvironment.

LayerARN

arn:aws:lambda:us-east-1:339543757547:layer:tensorflow-pack

SklearnIntro

Packageforfansofmachinelearning,buildingmodelsandthelike.Idoubtthatthereisamoreconvenientwaytodeploymodeltotherealworld.

ToolsScikit-learn0.17.1Scipy0.17.0Documentation

https://scikit-learn.org/

SkimageIntro

Packageofimageprocessingtools,andnotonlytostyleimage,butalsoalargesetofcomputervisionalgorithms.

Therearecurrentlytwozippedpacksavailable,Pack.zipandPack_nomatplotlib.zip,youprobablywanttousePack_nomatplotlib.zip.Seehttps://github.com/ryfeus/lambda-packs/issues/5formoreinformation.

Tools

Scikit-image0.12.3

Documentation

https://scikit-image.org/

OpenCV+PILIntro

Anotherpackageofimageprocessingtools,andnotonlytostyleimage,butalsoalargesetofComputervisionalgorithms.

ToolsOpenCV3.1.0PIL4.0.0Documentation

https://pillow.readthedocs.io/

https://docs.opencv.org/3.0-beta/doc/py_tutorials/py_tutorials.html

PandasIntro

Packageforfansofstatistics,datascientistsanddataengineers.RAMatlambdais1.5gigabytes,andthemaximumoperatingtime-5minutes.Iamsurethatwillbeenoughformosttasks.

Tools

Pandas0.19.0

Documentation

https://pandas.pydata.org/

SpacyIntro

OpensourcelibraryforNaturalLanguageProcessinginpython.

ToolsSpacy2.0.11Documentation

https://spacy.io/

Example

ExamplecodeloadslanguagemodelfromS3andusesittoanalyzesentence.

TesseractIntro

OCR(opticalcharacterrecognition)libraryfortextrecognitionfromtheimage.

Documentation

https://github.com/tesseract-ocr/tesseract

PDFgenerator+Microsoftofficefilegenerator(docx,xlsx,pptx)+imagegenerator(jpg,png)+bookgenerator(epub)Intro

"Helloworld"codeinpackagecreatesexampleofeverydocument.Basicallytheselibsarelowmemory(lessthan128MB)andhighspeed(lessthan0.5seconds)soit'ssomethinglike~1mdocumentsgeneratedper1$intermsofAWSLambdapricing.

Toolsdocx(python-docx-https://pypi.python.org/pypi/python-docx)xlsx(XlsxWriter-https://pypi.python.org/pypi/XlsxWriter)pptx(python-pptx-https://pypi.python.org/pypi/python-pptx)pdf(Reportlab-https://pypi.python.org/pypi/reportlab)epub(EbookLib-https://pypi.python.org/pypi/EbookLib)png/jpg/...(Pillow-https://pypi.python.org/pypi/Pillow)Satelliteimageryprocessing(rasterio+OSGEO+pyproj+shapely+PIL)Intro

AWSLambdapackinPythonforprocessingsatelliteimagery.Basicallyitenablestodeploypythoncodeinaneasyandcheapwayforprocessingsatelliteimageryorpolygons.In“helloworld”codeofthepackIdownloadred,green,blueLandsat8bandsfromAWS,makeTrueColorimageoutofitanduploadittoS3.Ittakes35secondsand824MBofRAMforitso~2500scenescanbeprocessedfor1$.

ToolsRasterio(https://github.com/mapbox/rasterio0.36)OSGEO(https://trac.osgeo.org/gdal/wiki/GdalOgrInPython)Pyproj(https://github.com/jswhit/pyproj)Shapely(https://github.com/Toblerity/Shapely)PIL(https://pillow.readthedocs.io/)PyTorch

Python3.6basedPyTorch

ToolsPyTorch1.0.1(CPU)torchvision0.2.1InstalledPackages(deps)numpy-1.16.1pillow-5.4.1six-1.12.0torchvision-0.2.1BuildPack#Youneed`docker`beforerun./build-with-docker.sh
声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论