Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: reduce code length for image demo #66

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Image Viewing with Pillow/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

This notebook is intended to be supplemental to the [Picture Perfect: Viewing Images with Snowpark for Python](https://medium.com/@btylerwhite/94f4c6a6a0f?source=friends_link&sk=487ac112536938f139707a1bdb84ddf1) article on Medium.

### Setting it up.
### Setting it up

Clone the repo. If you're using macOS or Linux, execute the following commands:
```
python3.8 -m venv venv
python -m venv venv
source venv/bin/activate
pip install -r Image\ Viewing\ with\ Pillow/requirements.txt
```

### Preparing the Environment
### Notebook run

First, we will create a dedicated database and a few schemas to keep our data organized within the database.
The notebook will create the necessary objects and upload the images.
37 changes: 14 additions & 23 deletions Image Viewing with Pillow/notebook.ipynb
Original file line number Diff line number Diff line change
@@ -1,40 +1,31 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This shorthand method of connecting assumes you have setup a configuration file as documented at\n",
"[Connecting using the connections.toml file](https://docs.snowflake.com/en/developer-guide/python-connector/python-connector-connect#connecting-using-the-connections-toml-file).\n"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"\n",
"import PIL.Image\n",
"from snowflake.snowpark import Session\n",
"\n",
"try:\n",
" from dotenv import load_dotenv\n",
"except ImportError:\n",
" def load_dotenv(**kwargs):\n",
" pass\n",
"\n",
"load_dotenv(override=True)\n",
"\n",
"connection_params = {\n",
" \"account\": os.environ.get(\"SNOWFLAKE_ACCOUNT\"),\n",
" \"user\": os.environ.get(\"SNOWFLAKE_USER\"),\n",
" \"password\": os.environ.get(\"SNOWFLAKE_PASSWORD\"),\n",
" \"role\": \"SYSADMIN\",\n",
"}\n",
"\n",
"session = Session.builder.configs(connection_params).create()"
"session = Session.builder.getOrCreate()"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"Create the objects for this demonstration."
"Create the objects for this demonstration.\n"
]
},
{
Expand Down Expand Up @@ -76,7 +67,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Adjust our context."
"Adjust our context.\n"
]
},
{
Expand All @@ -95,7 +86,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Load the stage."
"Load the stage.\n"
]
},
{
Expand Down Expand Up @@ -124,7 +115,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"List the contents of the stage."
"List the contents of the stage.\n"
]
},
{
Expand Down Expand Up @@ -155,7 +146,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Stream and view the image."
"Stream and view the image.\n"
]
},
{
Expand Down
1 change: 0 additions & 1 deletion Image Viewing with Pillow/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
ipykernel
Pillow
python-dotenv
snowflake-snowpark-python