Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9bcdd5b

Browse files
authored
Merge pull request #11 from HDE/master
Release v0.1.4 .
2 parents 78f0edd + 04b62dd commit 9bcdd5b

File tree

11 files changed

+130
-67
lines changed

11 files changed

+130
-67
lines changed

CHANGELOG.txt

+5
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,8 @@ Version 0.1.3
1717
-------------
1818

1919
- Exit with non-zero code when execution of function fails.
20+
21+
Version 0.1.4
22+
-------------
23+
24+
- Support Python 3.6.

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2015 HDE, Inc.
3+
Copyright (c) 2015-2017 HDE, Inc.
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

+28-18
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@
22

33
[![Join the chat at https://gitter.im/HDE/python-lambda-local](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/HDE/python-lambda-local?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
44
[![wercker status](https://app.wercker.com/status/04f5bc5b7de3d5c6f13eb5b871035226/s "wercker status")](https://app.wercker.com/project/bykey/04f5bc5b7de3d5c6f13eb5b871035226)
5+
[![PyPI version](https://badge.fury.io/py/python-lambda-local.svg)](https://badge.fury.io/py/python-lambda-local)
56

67
Run lambda function on local machine
78

89
## Prepare development environment
910

10-
Please use a newly created virtualenv for python2.7.
11+
Please use a newly created virtualenv of Python 2.7 or Python 3.6 .
1112

1213
## Installation
1314

1415
Within virtualenv, run the following command.
1516

1617
``` bash
17-
$ cd $PROJECT_ROOT
18-
$ pip install ./
18+
$ pip install python-lambda-local
1919
```
2020

2121
This will install the package with name `python-lambda-local` in the virtualenv.
@@ -27,7 +27,7 @@ Run `python-lambda-local -h` to see the help.
2727

2828
```
2929
usage: python-lambda-local [-h] [-l LIBRARY_PATH] [-f HANDLER_FUNCTION]
30-
[-t TIMEOUT]
30+
[-t TIMEOUT] [-a ARN_STRING] [-v VERSION_NAME]
3131
FILE EVENT
3232
3333
Run AWS Lambda function written in Python on local machine.
@@ -44,6 +44,10 @@ optional arguments:
4444
Lambda function handler name. Default: "handler".
4545
-t TIMEOUT, --timeout TIMEOUT
4646
Seconds until lambda function timeout. Default: 3
47+
-a ARN_STRING, --arn-string ARN_STRING
48+
arn string for function
49+
-v VERSION_NAME, --version-name VERSION_NAME
50+
function version name
4751
```
4852

4953
### Prepare development directory
@@ -72,29 +76,30 @@ Suppose your project directory is like this:
7276
└── test.py
7377
```
7478

75-
In the handler's code is in `test.py` and the function name of the handler is `handler`.
76-
The source depends on 3rd party library `rx` and it is install in the directory `lib`.
77-
The test event of json format is in `event.json` file.
79+
The handler's code is in `test.py` and the function name of the handler is `handler`.
80+
The source depends on 3rd party library `rx` and it is installed in the directory `lib`.
81+
The test event in json format is in `event.json` file.
7882

7983
#### Content of `test.py`:
8084

8185
``` python
86+
from __future__ import print_function
8287
from rx import Observable
8388

8489

8590
def handler(event, context):
86-
xs = Observable.from_([1, 2, 3, 4, 5, 6])
91+
xs = Observable.from_(range(event['answer']))
8792
ys = xs.to_blocking()
88-
zs = (x*x for x in ys if x > 3)
93+
zs = (x*x for x in ys if x % 7 == 0)
8994
for x in zs:
90-
print x
95+
print(x)
9196
```
9297

9398
#### Content of `event.json`:
9499

95100
``` json
96101
{
97-
"key": "value"
102+
"answer": 42
98103
}
99104
```
100105

@@ -109,11 +114,16 @@ python-lambda-local -l lib/ -f handler -t 5 test.py event.json
109114
The output will be like:
110115

111116
```
112-
[INFO 2015-10-16 18:21:14,774] Event: {'key': 'value'}
113-
[INFO 2015-10-16 18:21:14,774] START RequestId: 324cb1c5-fa9b-4f39-8ad9-01c95f7d5744
114-
16
115-
25
116-
36
117-
[INFO 2015-10-16 18:21:14,775] END RequestId: 324cb1c5-fa9b-4f39-8ad9-01c95f7d5744
118-
[INFO 2015-10-16 18:21:14,775] RESULT: None
117+
[root - INFO - 2017-04-19 12:39:05,512] Event: {u'answer': 42}
118+
[root - INFO - 2017-04-19 12:39:05,512] START RequestId: b918f9ae-0ca1-44af-9937-dd5f9eeedcc1
119+
0
120+
49
121+
196
122+
441
123+
784
124+
1225
125+
[root - INFO - 2017-04-19 12:39:05,515] END RequestId: b918f9ae-0ca1-44af-9937-dd5f9eeedcc1
126+
[root - INFO - 2017-04-19 12:39:05,515] RESULT:
127+
None
128+
[root - INFO - 2017-04-19 12:39:05,515] REPORT RequestId: b918f9ae-0ca1-44af-9937-dd5f9eeedcc1 Duration: 2.27 ms
119129
```

README.rst

+49-30
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
python-lambda-local
22
===================
33

4+
|Join the chat at https://gitter.im/HDE/python-lambda-local| |wercker
5+
status| |PyPI version|
6+
47
Run lambda function on local machine
58

69
Prepare development environment
710
-------------------------------
811

9-
Please use a newly created virtualenv for python2.7.
12+
Please use a newly created virtualenv of Python 2.7 or Python 3.6 .
1013

1114
Installation
1215
------------
@@ -15,8 +18,7 @@ Within virtualenv, run the following command.
1518

1619
.. code:: bash
1720
18-
$ cd $PROJECT_ROOT
19-
$ pip install ./
21+
$ pip install python-lambda-local
2022
2123
This will install the package with name ``python-lambda-local`` in the
2224
virtualenv. Now you can use the command ``python-lambda-local`` to run
@@ -30,7 +32,7 @@ Run ``python-lambda-local -h`` to see the help.
3032
::
3133

3234
usage: python-lambda-local [-h] [-l LIBRARY_PATH] [-f HANDLER_FUNCTION]
33-
[-t TIMEOUT]
35+
[-t TIMEOUT] [-a ARN_STRING] [-v VERSION_NAME]
3436
FILE EVENT
3537

3638
Run AWS Lambda function written in Python on local machine.
@@ -47,6 +49,10 @@ Run ``python-lambda-local -h`` to see the help.
4749
Lambda function handler name. Default: "handler".
4850
-t TIMEOUT, --timeout TIMEOUT
4951
Seconds until lambda function timeout. Default: 3
52+
-a ARN_STRING, --arn-string ARN_STRING
53+
arn string for function
54+
-v VERSION_NAME, --version-name VERSION_NAME
55+
function version name
5056

5157
Prepare development directory
5258
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -60,49 +66,50 @@ Suppose your project directory is like this:
6066

6167
├── event.json
6268
├── lib
63-
├── rx
64-
├── abstractobserver.py
65-
├── ... (package content of rx)
69+
   ├── rx
70+
   │   ├── abstractobserver.py
71+
   │   ├── ... (package content of rx)
6672
...
67-
└── testscheduler.py
68-
└── Rx-1.2.3.dist-info
69-
├── DESCRIPTION.rst
70-
├── METADATA
71-
├── metadata.json
72-
├── pbr.json
73-
├── RECORD
74-
├── top_level.txt
75-
├── WHEEL
76-
└── zip-safe
73+
   │   └── testscheduler.py
74+
   └── Rx-1.2.3.dist-info
75+
   ├── DESCRIPTION.rst
76+
   ├── METADATA
77+
   ├── metadata.json
78+
   ├── pbr.json
79+
   ├── RECORD
80+
   ├── top_level.txt
81+
   ├── WHEEL
82+
   └── zip-safe
7783
└── test.py
7884

79-
In the handler's code is in ``test.py`` and the function name of the
85+
The handler's code is in ``test.py`` and the function name of the
8086
handler is ``handler``. The source depends on 3rd party library ``rx``
81-
and it is install in the directory ``lib``. The test event of json
87+
and it is installed in the directory ``lib``. The test event in json
8288
format is in ``event.json`` file.
8389

8490
Content of ``test.py``:
8591
^^^^^^^^^^^^^^^^^^^^^^^
8692

8793
.. code:: python
8894
95+
from __future__ import print_function
8996
from rx import Observable
9097
9198
9299
def handler(event, context):
93-
xs = Observable.from_([1, 2, 3, 4, 5, 6])
100+
xs = Observable.from_(range(event['answer']))
94101
ys = xs.to_blocking()
95-
zs = (x*x for x in ys if x > 3)
102+
zs = (x*x for x in ys if x % 7 == 0)
96103
for x in zs:
97-
print x
104+
print(x)
98105
99106
Content of ``event.json``:
100107
^^^^^^^^^^^^^^^^^^^^^^^^^^
101108

102109
.. code:: json
103110
104111
{
105-
"key": "value"
112+
"answer": 42
106113
}
107114
108115
Run the lambda function
@@ -119,10 +126,22 @@ The output will be like:
119126

120127
::
121128

122-
[INFO 2015-10-16 18:21:14,774] Event: {'key': 'value'}
123-
[INFO 2015-10-16 18:21:14,774] START RequestId: 324cb1c5-fa9b-4f39-8ad9-01c95f7d5744
124-
16
125-
25
126-
36
127-
[INFO 2015-10-16 18:21:14,775] END RequestId: 324cb1c5-fa9b-4f39-8ad9-01c95f7d5744
128-
[INFO 2015-10-16 18:21:14,775] RESULT: None
129+
[root - INFO - 2017-04-19 12:39:05,512] Event: {u'answer': 42}
130+
[root - INFO - 2017-04-19 12:39:05,512] START RequestId: b918f9ae-0ca1-44af-9937-dd5f9eeedcc1
131+
0
132+
49
133+
196
134+
441
135+
784
136+
1225
137+
[root - INFO - 2017-04-19 12:39:05,515] END RequestId: b918f9ae-0ca1-44af-9937-dd5f9eeedcc1
138+
[root - INFO - 2017-04-19 12:39:05,515] RESULT:
139+
None
140+
[root - INFO - 2017-04-19 12:39:05,515] REPORT RequestId: b918f9ae-0ca1-44af-9937-dd5f9eeedcc1 Duration: 2.27 ms
141+
142+
.. |Join the chat at https://gitter.im/HDE/python-lambda-local| image:: https://badges.gitter.im/Join%20Chat.svg
143+
:target: https://gitter.im/HDE/python-lambda-local?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
144+
.. |wercker status| image:: https://app.wercker.com/status/04f5bc5b7de3d5c6f13eb5b871035226/s
145+
:target: https://app.wercker.com/project/bykey/04f5bc5b7de3d5c6f13eb5b871035226
146+
.. |PyPI version| image:: https://badge.fury.io/py/python-lambda-local.svg
147+
:target: https://badge.fury.io/py/python-lambda-local

lambda_local/__init__.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
'''
22
python-lambda-local: Main module
33
4-
Copyright 2015 HDE, Inc.
4+
Copyright 2015-2017 HDE, Inc.
55
Licensed under MIT.
66
'''
77

88
from __future__ import print_function
99
import argparse
10-
from main import run
1110
import sys
1211
from multiprocessing import Process
1312

13+
from .main import run
14+
1415

1516
def main():
1617
args = parse_args()
@@ -46,5 +47,6 @@ def parse_args():
4647

4748
return parser.parse_args()
4849

50+
4951
if __name__ == "__main__":
5052
main()

lambda_local/context.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'''
2-
Copyright 2015 HDE, Inc.
2+
Copyright 2015-2017 HDE, Inc.
33
Licensed under MIT.
44
'''
55

lambda_local/event.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'''
2-
Copyright 2015 HDE, Inc.
2+
Copyright 2015-2017 HDE, Inc.
33
Licensed under MIT.
44
'''
55

lambda_local/main.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'''
2-
Copyright 2015 HDE, Inc.
2+
Copyright 2015-2017 HDE, Inc.
33
Licensed under MIT.
44
'''
55

@@ -13,10 +13,10 @@
1313
import timeit
1414
from botocore.vendored.requests.packages import urllib3
1515

16-
import event
17-
import context
18-
from timeout import time_limit
19-
from timeout import TimeoutException
16+
from . import event
17+
from . import context
18+
from .timeout import time_limit
19+
from .timeout import TimeoutException
2020

2121
logging.basicConfig(stream=sys.stdout,
2222
level=logging.INFO,

lambda_local/timeout.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'''
2-
Copyright 2015 HDE, Inc.
2+
Copyright 2015-2017 HDE, Inc.
33
Licensed under MIT.
44
'''
55

setup.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
'''
22
python-lambda-local: Run lambda function in python on local machine.
33
4-
Note that "python setup.py test" invokes pytest on the package. With
5-
appropriately configured setup.cfg, this will check both xxx_test modules and
6-
docstrings.
7-
8-
Copyright 2015 HDE, Inc.
4+
Copyright 2015-2017 HDE, Inc.
95
Licensed under MIT.
106
'''
117
import sys
@@ -26,15 +22,19 @@ def run_tests(self):
2622
sys.exit(pytest.main(self.test_args))
2723

2824

29-
version = "0.1.3"
25+
version = "0.1.4"
3026

3127
setup(name="python-lambda-local",
3228
version=version,
3329
description="Run lambda function in python on local machine.",
3430
long_description=open("README.rst").read(),
3531
classifiers=[
36-
'Development Status :: 1 - Planning',
37-
'Programming Language :: Python'
32+
'Development Status :: 3 - Alpha',
33+
'Operating System :: POSIX ',
34+
'Programming Language :: Python',
35+
'Programming Language :: Python :: 2.7',
36+
'Programming Language :: Python :: 3.6',
37+
'License :: OSI Approved :: MIT License'
3838
],
3939
keywords="AWS Lambda",
4040
author="YANG Xudong",

0 commit comments

Comments
 (0)