Skip to content

Commit 6ebbd8e

Browse files
committed
finish tutorials
1 parent bac9607 commit 6ebbd8e

File tree

5 files changed

+29
-36
lines changed

5 files changed

+29
-36
lines changed
121 KB
Loading
92.9 KB
Loading

src/content/docs/snowflake/tutorials/aws-lambda-localstack-snowpark.md

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ The code in this tutorial is available on [GitHub](https://github.com/localstack
2828

2929
Create a new directory for your lambda function and navigate to it:
3030

31-
{{< command >}}
32-
$ mkdir -p lambda-snowpark
33-
$ cd lambda-snowpark
34-
{{< / command >}}
31+
```bash
32+
mkdir -p lambda-snowpark
33+
cd lambda-snowpark
34+
```
3535

3636
Create a new file named `handler.py` and add the following code:
3737

@@ -112,61 +112,61 @@ You can now install the dependencies for your Lambda function. These include:
112112

113113
Run the following command:
114114

115-
{{< command >}}
116-
$ pip3 install \
115+
```bash
116+
pip3 install \
117117
--platform manylinux2010_x86_64 \
118118
--implementation cp \
119119
--only-binary=:all: --upgrade \
120120
--target ./libs \
121121
snowflake-connector-python==2.7.9 boto3==1.26.153 botocore==1.29.153
122-
{{< / command >}}
122+
```
123123

124124
## Package the Lambda function
125125

126126
Package the Lambda function and its dependencies into a ZIP file. Run the following command:
127127

128-
{{< command >}}
129-
$ mkdir -p build
130-
$ cp -r libs/* build/
131-
$ (cd build && zip -q -r function-py.zip .)
132-
{{< / command >}}
128+
```bash
129+
mkdir -p build
130+
cp -r libs/* build/
131+
(cd build && zip -q -r function-py.zip .)
132+
```
133133

134134
You have now created a ZIP file named `function-py.zip` that contains the Lambda function and its dependencies.
135135

136136
## Start the LocalStack container
137137

138138
Start your LocalStack container in your preferred terminal/shell.
139139

140-
{{< command >}}
141-
$ export LOCALSTACK_AUTH_TOKEN=<your_auth_token>
142-
$ DEBUG=1 \
140+
```bash
141+
export LOCALSTACK_AUTH_TOKEN=<your_auth_token>
142+
DEBUG=1 \
143143
LAMBDA_RUNTIME_ENVIRONMENT_TIMEOUT=180 \
144144
IMAGE_NAME=localstack/snowflake \
145145
localstack start
146-
{{< / command >}}
146+
```
147147

148148
> The `DEBUG=1` environment variable is set to enable debug logs. It would allow you to see the SQL queries executed by the Lambda function. The `LAMBDA_RUNTIME_ENVIRONMENT_TIMEOUT` environment variable is set to increase the Lambda function's timeout to 180 seconds.
149149
150150
## Deploy the Lambda function
151151

152152
You can now deploy the Lambda function to LocalStack using the `awslocal` CLI. Run the following command:
153153

154-
{{< command >}}
155-
$ awslocal lambda create-function \
154+
```bash
155+
awslocal lambda create-function \
156156
--function-name localstack-snowflake-lambda-example \
157157
--runtime python3.10 \
158158
--timeout 180 \
159159
--zip-file fileb://build/function-py.zip \
160160
--handler handler.lambda_handler \
161161
--role arn:aws:iam::000000000000:role/lambda-role
162-
{{< / command >}}
162+
```
163163

164164
After successfully deploying the Lambda function, you will receive a response with the details of the function. You can now invoke the function using the `awslocal` CLI:
165165

166-
{{< command >}}
167-
$ awslocal lambda invoke --function-name localstack-snowflake-lambda-example \
166+
```bash
167+
awslocal lambda invoke --function-name localstack-snowflake-lambda-example \
168168
--payload '{"body": "test" }' output.txt
169-
{{< / command >}}
169+
```
170170

171171
You will receive a response with the details of the invocation. You can view the output in the `output.txt` file. To see the SQL queries executed by the Lambda function, check the logs by navigating to LocalStack logs (`localstack logs`).
172172

src/content/docs/snowflake/tutorials/credit-scoring-with-localstack-snowpark.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ You should also download [`credit_files.csv`](https://github.com/localstack-samp
2525

2626
Start your LocalStack container in your preferred terminal/shell.
2727

28-
{{< command >}}
29-
$ export LOCALSTACK_AUTH_TOKEN=<your_auth_token>
30-
$ IMAGE_NAME=localstack/snowflake localstack start
31-
{{< / command >}}
28+
```bash
29+
export LOCALSTACK_AUTH_TOKEN=<your_auth_token>
30+
IMAGE_NAME=localstack/snowflake localstack start
31+
```
3232

3333
## Create a Snowpark session
3434

@@ -126,7 +126,7 @@ credit_df.toPandas().hist(figsize=(15,15))
126126
The following output is displayed:
127127
<br><br>
128128

129-
<img src="credit_df_hist.png" alt="credit_df_hist" width="700"/>
129+
![credit_df_hist](/images/snowflake/credit_df_hist.png)
130130
<br><br>
131131

132132
You can also visualize the categorical features of the `credit_df` table:
@@ -155,8 +155,8 @@ plt.show()
155155
The following output is displayed:
156156
<br><br>
157157

158-
<img src="credit_df_cat.png" alt="credit_df_cat" width="700"/>
158+
![credit_df_cat](/images/snowflake/credit_df_cat.png)
159159

160160
## Conclusion
161161

162-
You can now perform further experimentations with the Snowflake emulator. For example, you can use the Snowpark API to run queries to get various insights, such as determining the range of loans per different category.
162+
You can now perform further experimentations with the Snowflake emulator. For example, you can use the Snowpark API to run queries to get various insights, such as determining the range of loans per different category.

src/content/docs/snowflake/tutorials/index.md

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)