Skip to content

Commit 274aade

Browse files
committed
chore: add more hello world advanced example
1 parent 6b9e27e commit 274aade

File tree

9 files changed

+69
-3
lines changed

9 files changed

+69
-3
lines changed

.gitignore

+12-1
Original file line numberDiff line numberDiff line change
@@ -163,4 +163,15 @@ cython_debug/
163163
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
164164
#.idea/
165165

166-
# End of https://www.toptal.com/developers/gitignore/api/python
166+
# End of https://www.toptal.com/developers/gitignore/api/python
167+
168+
# Custom
169+
## AWS Lambda
170+
*.zip
171+
package/
172+
173+
## Priceloop
174+
upload.sh
175+
176+
## Misc
177+
.DS_Store

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
# Priceloop NoCode Python External Functions Templates
1+
# 🧶 Priceloop NoCode Python External Functions Templates
22

33
To test locally please install python-lambda-local:
44

55
```
66
pip install python-lambda-local
77
```
88

9-
More information on how to deploy it to our platform please go to our [documentation](https://priceloopai.notion.site/External-Functions-f78d153ab7b94a5f8a2f2cc5baa5e9d3).
9+
More information on how to deploy it to our platform please also go to our [documentation](https://priceloopai.notion.site/External-Functions-f78d153ab7b94a5f8a2f2cc5baa5e9d3).

hello_world/README.md

+6
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,9 @@ Run this to test:
55
```
66
python-lambda-local function.py event.json -t 900
77
```
8+
9+
### Deployment
10+
11+
```
12+
zip app.zip function.py
13+
```

hello_world_advanced/README.md

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Hello World Advanced Example
2+
3+
* Create an external function with external dependencies
4+
* Seperate the lambda handler and core logic
5+
6+
Run this to test:
7+
8+
```
9+
python-lambda-local function.py event.json -t 900
10+
```
11+
12+
### Deployment
13+
14+
First install the packages from your `requirements.txt`, zip it and then add your function to the root of the zip file::
15+
16+
```
17+
pip install --target ./package -r requirements.txt
18+
cd package
19+
zip -r ../app.zip .
20+
cd ..
21+
zip -g app.zip *.py
22+
```
23+
24+
Or use this command:
25+
26+
```
27+
./package.sh
28+
```
29+
30+
Once this is done, you can use the `hello_world_app.zip` to push it to our platform.

hello_world_advanced/event.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"BatchedArgs": [["1", "test_data_1"], ["2", "test_data_2"], ["3", "test_data_3"]]
3+
}

hello_world_advanced/function.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from main import return_fake_name
2+
3+
def handler(event, context):
4+
arg_one = list(map(lambda row: return_fake_name(row[0]), event["BatchedArgs"]))
5+
return arg_one

hello_world_advanced/main.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from faker import Faker
2+
3+
fake = Faker()
4+
def return_fake_name(row):
5+
return row + " " + fake.name()

hello_world_advanced/package.sh

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pip install --target ./package -r requirements.txt
2+
cd package
3+
zip -r ../app.zip .
4+
cd ..
5+
zip -g app.zip *.py

hello_world_advanced/requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Faker

0 commit comments

Comments
 (0)