Spaces:
Sleeping
Sleeping
Provide a running jypyter lab environment
Browse filesMerge branch 'jupyter' into 'main'
- Dockerfile +4 -1
- jupyter/notebooks/SOLID_Musing.ipynb +0 -112
- jupyter/scripts/SOLID_Musing.py +0 -59
- jupyter/scripts/ex_autoreload.py +38 -0
- jupyter/scripts/test_persistent_data.py +42 -0
Dockerfile
CHANGED
|
@@ -89,8 +89,11 @@ VOLUME /data
|
|
| 89 |
|
| 90 |
ENV PYTHONPATH=$APP_CODE:$PYTHONPATH
|
| 91 |
|
|
|
|
|
|
|
|
|
|
| 92 |
# Expose streamlit application
|
| 93 |
EXPOSE 8501
|
| 94 |
EXPOSE 7860
|
| 95 |
ENTRYPOINT [ "bash", "-o", "allexport" ]
|
| 96 |
-
CMD [ "start_server.sh" ]
|
|
|
|
| 89 |
|
| 90 |
ENV PYTHONPATH=$APP_CODE:$PYTHONPATH
|
| 91 |
|
| 92 |
+
RUN ln -s $APP_DATA/ data
|
| 93 |
+
ADD jupyter/notebooks notebooks
|
| 94 |
+
|
| 95 |
# Expose streamlit application
|
| 96 |
EXPOSE 8501
|
| 97 |
EXPOSE 7860
|
| 98 |
ENTRYPOINT [ "bash", "-o", "allexport" ]
|
| 99 |
+
CMD [ "-f", "./start_server.sh" ]
|
jupyter/notebooks/SOLID_Musing.ipynb
DELETED
|
@@ -1,112 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"cells": [
|
| 3 |
-
{
|
| 4 |
-
"attachments": {},
|
| 5 |
-
"cell_type": "markdown",
|
| 6 |
-
"id": "8d39ce6d",
|
| 7 |
-
"metadata": {},
|
| 8 |
-
"source": [
|
| 9 |
-
"## *Principles* ? What is the point ?"
|
| 10 |
-
]
|
| 11 |
-
},
|
| 12 |
-
{
|
| 13 |
-
"attachments": {},
|
| 14 |
-
"cell_type": "markdown",
|
| 15 |
-
"id": "c10de8ce",
|
| 16 |
-
"metadata": {},
|
| 17 |
-
"source": [
|
| 18 |
-
"The SOLID principles are:\n",
|
| 19 |
-
"\n",
|
| 20 |
-
"* The **S**ingle-Responsibility Principle (*SRP*)\n",
|
| 21 |
-
"* The **O**pen-Closed Principle (*OCP*)\n",
|
| 22 |
-
"* The **L**iskov Substitution Principle (*LSP*)\n",
|
| 23 |
-
"* The **I**nterface Segregation Principle (*ISP*)\n",
|
| 24 |
-
"* The **D**ependency inversion Principle (*DIP*)\n",
|
| 25 |
-
"\n",
|
| 26 |
-
"These five principles are not a specific ordered list (do this, then that, etc) but a collection of best practices, developed through the decades. They are gathered into an acronym, as a mnemonic vehicle to be remembered, similar to others in computer science, e.g.: *DRY*: Don’t Repeat Yourself; *KISS*: Keep It Small and Simple; as pieces of accumulated wisdom. A little side note, the acronym was created years after these five principles were set together.\n",
|
| 27 |
-
"\n",
|
| 28 |
-
"\n",
|
| 29 |
-
"\n",
|
| 30 |
-
"From https://towardsdatascience.com/solid-coding-in-python-1281392a6a94"
|
| 31 |
-
]
|
| 32 |
-
},
|
| 33 |
-
{
|
| 34 |
-
"attachments": {},
|
| 35 |
-
"cell_type": "markdown",
|
| 36 |
-
"id": "014fad04",
|
| 37 |
-
"metadata": {},
|
| 38 |
-
"source": [
|
| 39 |
-
"STUPID is an acronym that describes bad practices in Oriented Object Programming:\n",
|
| 40 |
-
"\n",
|
| 41 |
-
"* **S**ingleton\n",
|
| 42 |
-
"* **T**ight Coupling\n",
|
| 43 |
-
"* **U**ntestability\n",
|
| 44 |
-
"* **P**remature Optimization\n",
|
| 45 |
-
"* **I**ndescriptive Naming\n",
|
| 46 |
-
"* **D**uplication\n",
|
| 47 |
-
"\n",
|
| 48 |
-
"from https://williamdurand.fr/2013/07/30/from-stupid-to-solid-code/#:~:text=SOLID%20is%20an%20acronym%20that,Liskov%20Substitution%20Principle\n"
|
| 49 |
-
]
|
| 50 |
-
},
|
| 51 |
-
{
|
| 52 |
-
"attachments": {},
|
| 53 |
-
"cell_type": "markdown",
|
| 54 |
-
"id": "30f034a5",
|
| 55 |
-
"metadata": {},
|
| 56 |
-
"source": [
|
| 57 |
-
"# Loading the package dynamically\n"
|
| 58 |
-
]
|
| 59 |
-
},
|
| 60 |
-
{
|
| 61 |
-
"cell_type": "code",
|
| 62 |
-
"execution_count": null,
|
| 63 |
-
"id": "98f2f3f8",
|
| 64 |
-
"metadata": {
|
| 65 |
-
"lines_to_next_cell": 2
|
| 66 |
-
},
|
| 67 |
-
"outputs": [],
|
| 68 |
-
"source": [
|
| 69 |
-
"%load_ext autoreload\n",
|
| 70 |
-
"%autoreload 1"
|
| 71 |
-
]
|
| 72 |
-
},
|
| 73 |
-
{
|
| 74 |
-
"cell_type": "code",
|
| 75 |
-
"execution_count": null,
|
| 76 |
-
"id": "14acf530",
|
| 77 |
-
"metadata": {},
|
| 78 |
-
"outputs": [],
|
| 79 |
-
"source": [
|
| 80 |
-
"%aimport athai.hello"
|
| 81 |
-
]
|
| 82 |
-
},
|
| 83 |
-
{
|
| 84 |
-
"attachments": {},
|
| 85 |
-
"cell_type": "markdown",
|
| 86 |
-
"id": "f8be4aa9",
|
| 87 |
-
"metadata": {},
|
| 88 |
-
"source": []
|
| 89 |
-
}
|
| 90 |
-
],
|
| 91 |
-
"metadata": {
|
| 92 |
-
"kernelspec": {
|
| 93 |
-
"display_name": "Python 3 (ipykernel)",
|
| 94 |
-
"language": "python",
|
| 95 |
-
"name": "python3"
|
| 96 |
-
},
|
| 97 |
-
"language_info": {
|
| 98 |
-
"codemirror_mode": {
|
| 99 |
-
"name": "ipython",
|
| 100 |
-
"version": 3
|
| 101 |
-
},
|
| 102 |
-
"file_extension": ".py",
|
| 103 |
-
"mimetype": "text/x-python",
|
| 104 |
-
"name": "python",
|
| 105 |
-
"nbconvert_exporter": "python",
|
| 106 |
-
"pygments_lexer": "ipython3",
|
| 107 |
-
"version": "3.9.16"
|
| 108 |
-
}
|
| 109 |
-
},
|
| 110 |
-
"nbformat": 4,
|
| 111 |
-
"nbformat_minor": 5
|
| 112 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
jupyter/scripts/SOLID_Musing.py
DELETED
|
@@ -1,59 +0,0 @@
|
|
| 1 |
-
# ---
|
| 2 |
-
# jupyter:
|
| 3 |
-
# jupytext:
|
| 4 |
-
# text_representation:
|
| 5 |
-
# extension: .py
|
| 6 |
-
# format_name: percent
|
| 7 |
-
# format_version: '1.3'
|
| 8 |
-
# jupytext_version: 1.14.6
|
| 9 |
-
# kernelspec:
|
| 10 |
-
# display_name: Python 3 (ipykernel)
|
| 11 |
-
# language: python
|
| 12 |
-
# name: python3
|
| 13 |
-
# ---
|
| 14 |
-
|
| 15 |
-
# %% [markdown]
|
| 16 |
-
# ## *Principles* ? What is the point ?
|
| 17 |
-
|
| 18 |
-
# %% [markdown]
|
| 19 |
-
# The SOLID principles are:
|
| 20 |
-
#
|
| 21 |
-
# * The **S**ingle-Responsibility Principle (*SRP*)
|
| 22 |
-
# * The **O**pen-Closed Principle (*OCP*)
|
| 23 |
-
# * The **L**iskov Substitution Principle (*LSP*)
|
| 24 |
-
# * The **I**nterface Segregation Principle (*ISP*)
|
| 25 |
-
# * The **D**ependency inversion Principle (*DIP*)
|
| 26 |
-
#
|
| 27 |
-
# These five principles are not a specific ordered list (do this, then that, etc) but a collection of best practices, developed through the decades. They are gathered into an acronym, as a mnemonic vehicle to be remembered, similar to others in computer science, e.g.: *DRY*: Don’t Repeat Yourself; *KISS*: Keep It Small and Simple; as pieces of accumulated wisdom. A little side note, the acronym was created years after these five principles were set together.
|
| 28 |
-
#
|
| 29 |
-
#
|
| 30 |
-
#
|
| 31 |
-
# From https://towardsdatascience.com/solid-coding-in-python-1281392a6a94
|
| 32 |
-
|
| 33 |
-
# %% [markdown]
|
| 34 |
-
# STUPID is an acronym that describes bad practices in Oriented Object Programming:
|
| 35 |
-
#
|
| 36 |
-
# * **S**ingleton
|
| 37 |
-
# * **T**ight Coupling
|
| 38 |
-
# * **U**ntestability
|
| 39 |
-
# * **P**remature Optimization
|
| 40 |
-
# * **I**ndescriptive Naming
|
| 41 |
-
# * **D**uplication
|
| 42 |
-
#
|
| 43 |
-
# from https://williamdurand.fr/2013/07/30/from-stupid-to-solid-code/#:~:text=SOLID%20is%20an%20acronym%20that,Liskov%20Substitution%20Principle
|
| 44 |
-
#
|
| 45 |
-
|
| 46 |
-
# %% [markdown]
|
| 47 |
-
# # Loading the package dynamically
|
| 48 |
-
#
|
| 49 |
-
|
| 50 |
-
# %%
|
| 51 |
-
# %load_ext autoreload
|
| 52 |
-
# %autoreload 1
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
# %%
|
| 56 |
-
# %aimport athai.hello
|
| 57 |
-
|
| 58 |
-
# %% [markdown]
|
| 59 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
jupyter/scripts/ex_autoreload.py
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# ---
|
| 2 |
+
# jupyter:
|
| 3 |
+
# jupytext:
|
| 4 |
+
# text_representation:
|
| 5 |
+
# extension: .py
|
| 6 |
+
# format_name: percent
|
| 7 |
+
# format_version: '1.3'
|
| 8 |
+
# jupytext_version: 1.14.7
|
| 9 |
+
# kernelspec:
|
| 10 |
+
# display_name: Python 3 (ipykernel)
|
| 11 |
+
# language: python
|
| 12 |
+
# name: python3
|
| 13 |
+
# ---
|
| 14 |
+
|
| 15 |
+
# %% [markdown]
|
| 16 |
+
# # Automatic reloading example for interactive development
|
| 17 |
+
#
|
| 18 |
+
|
| 19 |
+
# %%
|
| 20 |
+
# %load_ext autoreload
|
| 21 |
+
# %autoreload 1
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
# %%
|
| 25 |
+
# %aimport athai.hello
|
| 26 |
+
|
| 27 |
+
# %% [markdown]
|
| 28 |
+
#
|
| 29 |
+
|
| 30 |
+
# %%
|
| 31 |
+
from athai import hello
|
| 32 |
+
|
| 33 |
+
# %%
|
| 34 |
+
hello.build_greetings("Jae")
|
| 35 |
+
|
| 36 |
+
# %%
|
| 37 |
+
|
| 38 |
+
# %%
|
jupyter/scripts/test_persistent_data.py
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# ---
|
| 2 |
+
# jupyter:
|
| 3 |
+
# jupytext:
|
| 4 |
+
# text_representation:
|
| 5 |
+
# extension: .py
|
| 6 |
+
# format_name: percent
|
| 7 |
+
# format_version: '1.3'
|
| 8 |
+
# jupytext_version: 1.14.7
|
| 9 |
+
# kernelspec:
|
| 10 |
+
# display_name: Python 3 (ipykernel)
|
| 11 |
+
# language: python
|
| 12 |
+
# name: python3
|
| 13 |
+
# ---
|
| 14 |
+
|
| 15 |
+
# %%
|
| 16 |
+
import os
|
| 17 |
+
from pathlib import Path
|
| 18 |
+
|
| 19 |
+
import numpy as np
|
| 20 |
+
import pandas as pd
|
| 21 |
+
|
| 22 |
+
# %%
|
| 23 |
+
from athai.data_utils import cached_download_csv
|
| 24 |
+
|
| 25 |
+
# %%
|
| 26 |
+
DATE_COLUMN = "date/time"
|
| 27 |
+
DATA_URL = (
|
| 28 |
+
"https://s3-us-west-2.amazonaws.com/"
|
| 29 |
+
"streamlit-demo-data/uber-raw-data-sep14.csv.gz"
|
| 30 |
+
)
|
| 31 |
+
|
| 32 |
+
DATA_PATH = Path(os.environ.get("APP_DATA"))
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
# %%
|
| 36 |
+
nrows=10
|
| 37 |
+
data = cached_download_csv(DATA_PATH, DATA_URL, nrows=nrows)
|
| 38 |
+
data
|
| 39 |
+
|
| 40 |
+
# %%
|
| 41 |
+
|
| 42 |
+
# %%
|