Showing posts with label Python. Show all posts
Showing posts with label Python. Show all posts

Sunday, April 26, 2020

AWS Lambda using Python

AWS HOWTO
https://docs.aws.amazon.com/lambda/latest/dg/getting-started.html


AWS repository
https://github.com/awsdocs/aws-lambda-developer-guide


Check prerequisities

[dave@dave ~]$ aws --version

aws-cli/2.0.1 Python/3.7.3 Linux/5.5.16-200.fc31.x86_64 botocore/2.0.0dev5

[dave@dave ~]$ python --version

Python 3.7.6

 



Python Lambda

import json

 
def lambda_handler(event, context):

    # TODO implement

    return {

        'statusCode': 200,

        'body': json.dumps('Hello from Lambda!')

    }



Get lambda in AWS CLI

[dave@dave aws-lambda-developer-guide]$  aws lambda get-function --function-name dave-test-function

{

    "Configuration": {

        "FunctionName": "dave-test-function",

        "FunctionArn": "arn:aws:lambda:eu-central-1:45454545454:function:dave-test-function",

        "Runtime": "python3.8",

        "Role": "arn:aws:iam::45454545:role/dave-lambda-role-test",

        "Handler": "lambda_function.lambda_handler",

        "CodeSize": 299,

        "Description": "",

        "Timeout": 3,

        "MemorySize": 128,

        "LastModified": "2020-04-26T07:53:06.901+0000",

        "CodeSha256": "45454545454545",

        "Version": "$LATEST",

        "TracingConfig": {

            "Mode": "PassThrough"

        },

        "RevisionId": "454545454545",

        "State": "Active",

        "LastUpdateStatus": "Successful"

    },

    "Code": {

        "RepositoryType": "S3",

        "Location": "https://awslambda-eu-cent-1-tasks.s3.eu-central-1.amazonaws.com/snapshots/454534345656/dave-test-function-456544562342423424"

    }

}

 

Sunday, March 1, 2020

Install Python3 on Centos 7

To avoid impact on Centos own Python 2 packages use Python3  venv

Install Python3

$ sudo yum install -y python3


Create venv on Python3

$ python3 -m venv python3-virtualenv

$ pip3 freeze

$ source python3-virtualenv/bin/activate


$ python

Python 3.6.8 (default, Aug  7 2019, 17:28:10) 

[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux

Type "help", "copyright", "credits" or "license" for more information.

>>> 



On Fedora 31 Python 3 is default


[dave@localhost ~]$ python3

Python 3.7.6 (default, Jan 30 2020, 09:44:41) 

[GCC 9.2.1 20190827 (Red Hat 9.2.1-1)] on linux

Type "help", "copyright", "credits" or "license" for more information.

>>> 

[dave@localhost ~]$ python2

Python 2.7.17 (default, Oct 20 2019, 00:00:00) 

[GCC 9.2.1 20190827 (Red Hat 9.2.1-1)] on linux2

Type "help", "copyright", "credits" or "license" for more information.

>>> 

[dave@localhost ~]$ python

Python 3.7.6 (default, Jan 30 2020, 09:44:41) 

[GCC 9.2.1 20190827 (Red Hat 9.2.1-1)] on linux

Type "help", "copyright", "credits" or "license" for more information.

>>> 

 

Wednesday, January 23, 2019

Python - configure development environment

Configure Python SDK in IntteliJ
https://www.jetbrains.com/help/idea/configuring-local-python-interpreters.html


 Python tutorial

https://docs.python.org/3/tutorial/index.html


Install scientific modules

https://www.scipy.org/install.html


Using RPM
sudo dnf install numpy scipy python-matplotlib ipython python-pandas sympy python-nose atlas-devel