Skip to content

Commit

Permalink
Move dependency install to top
Browse files Browse the repository at this point in the history
  • Loading branch information
yujiyokoo committed Nov 28, 2024
1 parent 6b7751b commit 2039f6e
Showing 1 changed file with 65 additions and 49 deletions.
114 changes: 65 additions & 49 deletions examples/python/jupyter_notebook/CipherStash-Getting-Started.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,58 @@
"Otherwise, sign up to [CipherStash](https://cipherstash.com/signup), install [CipherStash CLI](https://github.com/cipherstash/cli-releases/releases/latest), and do the following steps:"
]
},
{
"cell_type": "markdown",
"id": "1847f62f-e77d-4fe7-b7e6-3356b405beee",
"metadata": {},
"source": [
"### Install dependency packages\n",
"As we will need to restart the Jupyter notebook kernel after installation, install `psycopg2`, `django` and `eqlpy` (from a specific branch):"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4b0a726a-96e0-4fc9-a846-7f4d747ba847",
"metadata": {},
"outputs": [],
"source": [
"%pip install psycopg2 django"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "91fbf4ee-a195-45c1-8e65-05ed60ef1311",
"metadata": {},
"outputs": [],
"source": [
"! git clone https://github.com/cipherstash/eqlpy.git --branch cip-981-add-dgjango-orm-support"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "96c523b8-89a8-4e96-836c-c24c71b057bb",
"metadata": {},
"outputs": [],
"source": [
"%pip install -e eqlpy/"
]
},
{
"cell_type": "markdown",
"id": "8f233255-5e16-4025-8a4f-ee76a1504566",
"metadata": {},
"source": [
"### Restart kernel\n",
"\n",
"From the top menu bar of Jupyter notebook (not the browser), select \"Kernel\" then \"Restart kernel\".\n",
"When you get prompted whether you want to restart the kernel, select \"Restart\".\n",
"\n",
"**Without this step, you might not have access to eqlpy**"
]
},
{
"cell_type": "markdown",
"id": "0d2fd39b-86a2-4e34-a214-7c9bf13f9579",
Expand Down Expand Up @@ -183,7 +235,7 @@
"metadata": {},
"outputs": [],
"source": [
"%env CS_CLIENT_ACCESS_KEY=<client_access_key>"
"%env CS_CLIENT_ACCESS_KEY=<client_acces_key>"
]
},
{
Expand Down Expand Up @@ -220,7 +272,9 @@
"cell_type": "code",
"execution_count": null,
"id": "dd60b2fa-14c0-4206-b5c8-74b8d83b1086",
"metadata": {},
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"! docker compose up postgres -d"
Expand Down Expand Up @@ -325,7 +379,9 @@
"cell_type": "code",
"execution_count": null,
"id": "3c2b1e45-7fb4-4ed4-9fdd-4d964c3d8225",
"metadata": {},
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"! docker compose up proxy -d"
Expand All @@ -338,7 +394,7 @@
"source": [
"The command above should start CipherStash Proxy.\n",
"At any point, you can check the logs to see if there are any errors in your terminal window.\n",
"From the directory where your docker-copmose.yml is located (`jupyter_notebook/` by default):\n",
"From the directory where your docker-compose.yml is located (`jupyter_notebook/` by default):\n",
"\n",
"> docker compose logs -f proxy"
]
Expand Down Expand Up @@ -374,54 +430,14 @@
"The constructor for `EqlText` takes the string value, the table name (`\"examples\"`) and the column name (`\"encrypted_utf8_str\"`)."
]
},
{
"cell_type": "markdown",
"id": "637d0665-e53b-40e5-b685-aa1aa4354e46",
"metadata": {},
"source": [
"### Install psycopg2 and django\n",
"\n",
"Install `psycopg2` and `django`, and eqlpy if you have not done so yet:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "bb1cc638-bd6b-4776-98a7-0e25a778be96",
"metadata": {},
"outputs": [],
"source": [
"%pip install psycopg2 django"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "8df5d243-56d2-4b30-90c8-f28a1455d319",
"metadata": {},
"outputs": [],
"source": [
"! git clone https://github.com/cipherstash/eqlpy.git --branch cip-981-add-dgjango-orm-support"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a9c62e97-bda5-4a35-9ad9-90ab6171ef7d",
"metadata": {},
"outputs": [],
"source": [
"%pip install -e eqlpy/"
]
},
{
"cell_type": "markdown",
"id": "1bbca0fa-4942-4e40-bffa-a3eb2027c671",
"metadata": {},
"source": [
"### Import class definitions\n",
"\n",
"There are some classes defined for encrytped types in this project directory.\n",
"There are some classes defined for encrypted types in this project directory.\n",
"They are in `eql_types.py` in the `eqlpy` package if you are interested in implementation details."
]
},
Expand Down Expand Up @@ -790,7 +806,7 @@
"\n",
"* Containment query\n",
"* Field extraction\n",
"* WHERE with field exctraction\n",
"* WHERE with field extraction\n",
"* ORDER BY with field extraction\n",
"* GROUP BY with field extraction\n",
"\n",
Expand Down Expand Up @@ -1060,7 +1076,7 @@
"from eqlpy.eql_types import EqlText, EqlFloat, EqlJsonb\n",
"from eqlpy.eqldjango import *\n",
"\n",
"# Confgigure Django\n",
"# Configure Django\n",
"if not settings.configured:\n",
" settings.configure(\n",
" DEBUG=True,\n",
Expand All @@ -1069,7 +1085,7 @@
" ],\n",
" DATABASES={\n",
" \"default\": {\n",
" \"ENGINE\": \"django.db.backends.postgresql\",\n",
" \"ENGINE\": \"django.db.backends.postgresql_psycopg2\",\n",
" \"NAME\": \"cipherstash_getting_started\",\n",
" \"USER\": \"postgres\",\n",
" \"PASSWORD\": \"postgres\",\n",
Expand Down Expand Up @@ -1335,7 +1351,7 @@
"example = Example.objects.first()\n",
"print(f\"<Example#{example.id}, string: {example.encrypted_utf8_str}, int: {example.encrypted_int}>\")\n",
"print()\n",
"print(\"Upadting\")\n",
"print(\"Updating\")\n",
"print()\n",
"example.encrypted_utf8_str = \"UPDATED STRING\"\n",
"example.encrypted_int = 128\n",
Expand Down

0 comments on commit 2039f6e

Please sign in to comment.