Spaces:
Sleeping
Sleeping
Commit
·
dfff3a1
1
Parent(s):
211f128
Upload 4 files
Browse files- Dockerfile +11 -0
- SupplierSourcing.xlsx +0 -0
- app.ipynb +245 -0
- requirements.txt +4 -0
Dockerfile
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM python:3.9
|
2 |
+
|
3 |
+
WORKDIR /code
|
4 |
+
|
5 |
+
COPY ./requirements.txt /code/requirements.txt
|
6 |
+
|
7 |
+
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
8 |
+
|
9 |
+
COPY . .
|
10 |
+
|
11 |
+
CMD ["mnn", "serve", "/code/app.ipynb", "--address", "0.0.0.0", "--port", "7860", "--allow-websocket-origin", "*"]
|
SupplierSourcing.xlsx
ADDED
Binary file (9.21 kB). View file
|
|
app.ipynb
ADDED
@@ -0,0 +1,245 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": null,
|
6 |
+
"id": "f11fb0aa-9798-42c4-8045-89a17119a7b5",
|
7 |
+
"metadata": {},
|
8 |
+
"outputs": [],
|
9 |
+
"source": [
|
10 |
+
"import manganite\n",
|
11 |
+
"%load_ext manganite"
|
12 |
+
]
|
13 |
+
},
|
14 |
+
{
|
15 |
+
"cell_type": "markdown",
|
16 |
+
"id": "93cd20ee-490f-449e-8d26-dce9f1940993",
|
17 |
+
"metadata": {},
|
18 |
+
"source": [
|
19 |
+
"# Widget Showcase\n",
|
20 |
+
"\n",
|
21 |
+
"This notebook presents all widget types available in Manganite. Feel free to copy their code and use it in your own dashboards.\n",
|
22 |
+
"\n",
|
23 |
+
"The `%%mnn widget` magic command has the following structure:\n",
|
24 |
+
"\n",
|
25 |
+
"```bash\n",
|
26 |
+
"%%mnn widget --type TYPE [PARAMS] --tab TAB [--position ROW COL SPAN] --header HEADER --var VAR_NAME\n",
|
27 |
+
"```\n",
|
28 |
+
"\n",
|
29 |
+
"where `TYPE` and optional `PARAMS` define the widget, `TAB`, `ROW`, `COL` and `SPAN` determine where to place it, and `HEADER` gives it a title above. `VAR_NAME` has to refer to an existing variable (can be defined in the same cell) of matching type (`bool` for a checkbox, `int` or `float` for a slider, etc.)\n",
|
30 |
+
"\n",
|
31 |
+
"`PARAMS` can take various forms, depending on widget type. Select boxes and radio buttons accept a variable holding their options (a collection of strings, can be any of `list`, `tuple`, `set`). Sliders take three numeric parameters, in the format of `MIN:MAX:STEP`. File pickers accept an optional string describing allowed file types, as defined for the `accept` attribute of the corresponding [HTML element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#accept)."
|
32 |
+
]
|
33 |
+
},
|
34 |
+
{
|
35 |
+
"cell_type": "code",
|
36 |
+
"execution_count": null,
|
37 |
+
"id": "6f124879-338f-4da6-ac9c-ae6a0593d621",
|
38 |
+
"metadata": {},
|
39 |
+
"outputs": [],
|
40 |
+
"source": [
|
41 |
+
"import datetime\n",
|
42 |
+
"import pandas as pd\n",
|
43 |
+
"list_of_options = ['option a', 'option b', 'option c']"
|
44 |
+
]
|
45 |
+
},
|
46 |
+
{
|
47 |
+
"cell_type": "code",
|
48 |
+
"execution_count": null,
|
49 |
+
"id": "605179e0-d800-46a8-86ed-f23172d778c3",
|
50 |
+
"metadata": {},
|
51 |
+
"outputs": [],
|
52 |
+
"source": [
|
53 |
+
"%%mnn widget --type checkbox --tab \"Options\" --header \"Checkbox\" --var b_1\n",
|
54 |
+
"b_1 = True"
|
55 |
+
]
|
56 |
+
},
|
57 |
+
{
|
58 |
+
"cell_type": "code",
|
59 |
+
"execution_count": null,
|
60 |
+
"id": "b10f338c-584b-4766-9ee3-268efadaf2f7",
|
61 |
+
"metadata": {},
|
62 |
+
"outputs": [],
|
63 |
+
"source": [
|
64 |
+
"%%mnn widget --type switch --tab \"Options\" --header \"Switch\" --var b_2\n",
|
65 |
+
"b_2 = False"
|
66 |
+
]
|
67 |
+
},
|
68 |
+
{
|
69 |
+
"cell_type": "code",
|
70 |
+
"execution_count": null,
|
71 |
+
"id": "5cd14108-e3a2-4d3f-b319-a2fa908f6735",
|
72 |
+
"metadata": {
|
73 |
+
"editable": true,
|
74 |
+
"slideshow": {
|
75 |
+
"slide_type": ""
|
76 |
+
},
|
77 |
+
"tags": []
|
78 |
+
},
|
79 |
+
"outputs": [],
|
80 |
+
"source": [
|
81 |
+
"%%mnn widget --type select list_of_options --tab \"Options\" --header \"Select\" --var s\n",
|
82 |
+
"s = list_of_options[0]"
|
83 |
+
]
|
84 |
+
},
|
85 |
+
{
|
86 |
+
"cell_type": "code",
|
87 |
+
"execution_count": null,
|
88 |
+
"id": "8ec0923b-8fda-418c-a2b7-a7d9d85cbd2c",
|
89 |
+
"metadata": {},
|
90 |
+
"outputs": [],
|
91 |
+
"source": [
|
92 |
+
"%%mnn widget --type radio list_of_options --tab \"Options\" --header \"Radio buttons\" --var r\n",
|
93 |
+
"r = list_of_options[1]"
|
94 |
+
]
|
95 |
+
},
|
96 |
+
{
|
97 |
+
"cell_type": "code",
|
98 |
+
"execution_count": null,
|
99 |
+
"id": "aa3169ae-6060-45f6-ae92-f7d8869288a0",
|
100 |
+
"metadata": {},
|
101 |
+
"outputs": [],
|
102 |
+
"source": [
|
103 |
+
"%%mnn widget --type slider 0:100:1 --tab \"Numbers\" --position 0 0 6 --header \"Int slider\" --var i\n",
|
104 |
+
"i = 42"
|
105 |
+
]
|
106 |
+
},
|
107 |
+
{
|
108 |
+
"cell_type": "code",
|
109 |
+
"execution_count": null,
|
110 |
+
"id": "1fe24fc2-6db7-46e0-b5bf-7adf4978987a",
|
111 |
+
"metadata": {},
|
112 |
+
"outputs": [],
|
113 |
+
"source": [
|
114 |
+
"%%mnn widget --type text --tab \"Numbers\" --header \"Int input\" --var j\n",
|
115 |
+
"j = -128"
|
116 |
+
]
|
117 |
+
},
|
118 |
+
{
|
119 |
+
"cell_type": "code",
|
120 |
+
"execution_count": null,
|
121 |
+
"id": "94e20a08-e77d-4d15-a299-e69dc1b4a29c",
|
122 |
+
"metadata": {},
|
123 |
+
"outputs": [],
|
124 |
+
"source": [
|
125 |
+
"%%mnn widget --type slider -4:4:0.01 --tab \"Numbers\" --position 1 0 6 --header \"Float slider\" --var f\n",
|
126 |
+
"f = 3.14"
|
127 |
+
]
|
128 |
+
},
|
129 |
+
{
|
130 |
+
"cell_type": "code",
|
131 |
+
"execution_count": null,
|
132 |
+
"id": "892d031c-caad-4430-af09-10e5269368ad",
|
133 |
+
"metadata": {
|
134 |
+
"editable": true,
|
135 |
+
"slideshow": {
|
136 |
+
"slide_type": ""
|
137 |
+
},
|
138 |
+
"tags": []
|
139 |
+
},
|
140 |
+
"outputs": [],
|
141 |
+
"source": [
|
142 |
+
"%%mnn widget --type text --tab \"Numbers\" --header \"Float input\" --var g\n",
|
143 |
+
"g = 9.99"
|
144 |
+
]
|
145 |
+
},
|
146 |
+
{
|
147 |
+
"cell_type": "code",
|
148 |
+
"execution_count": null,
|
149 |
+
"id": "6a7ecf24",
|
150 |
+
"metadata": {},
|
151 |
+
"outputs": [],
|
152 |
+
"source": [
|
153 |
+
"%%mnn widget --type text --tab \"Strings\" --header \"String input\" --var st\n",
|
154 |
+
"st = 'Hello manganite'"
|
155 |
+
]
|
156 |
+
},
|
157 |
+
{
|
158 |
+
"cell_type": "code",
|
159 |
+
"execution_count": null,
|
160 |
+
"id": "cd7001ff-f6dc-4286-9794-d3666dec0a90",
|
161 |
+
"metadata": {},
|
162 |
+
"outputs": [],
|
163 |
+
"source": [
|
164 |
+
"%%mnn widget --type date --tab \"Dates\" --header \"Date\" --var d\n",
|
165 |
+
"d = datetime.date.today()"
|
166 |
+
]
|
167 |
+
},
|
168 |
+
{
|
169 |
+
"cell_type": "code",
|
170 |
+
"execution_count": null,
|
171 |
+
"id": "20734b96-2c9c-46d9-8547-d717ce8f5c13",
|
172 |
+
"metadata": {},
|
173 |
+
"outputs": [],
|
174 |
+
"source": [
|
175 |
+
"%%mnn widget --type datetime --tab \"Dates\" --header \"Datetime\" --var dt\n",
|
176 |
+
"dt = datetime.datetime.now()"
|
177 |
+
]
|
178 |
+
},
|
179 |
+
{
|
180 |
+
"cell_type": "code",
|
181 |
+
"execution_count": null,
|
182 |
+
"id": "fffdb0a9-8115-4675-952d-5983545dc478",
|
183 |
+
"metadata": {},
|
184 |
+
"outputs": [],
|
185 |
+
"source": [
|
186 |
+
"%%mnn widget --type table --tab \"Pandas\" --position 0 0 6 --header \"DataFrame\" --var df\n",
|
187 |
+
"df = pd.read_excel('SupplierSourcing.xlsx',index_col=0)"
|
188 |
+
]
|
189 |
+
},
|
190 |
+
{
|
191 |
+
"cell_type": "code",
|
192 |
+
"execution_count": null,
|
193 |
+
"id": "9b40f9b7-7f04-4702-9ee7-097fb171e01e",
|
194 |
+
"metadata": {},
|
195 |
+
"outputs": [],
|
196 |
+
"source": [
|
197 |
+
"%%mnn widget --type file --tab \"Files\" --position 0 0 3 --header \"File picker (any file)\" --var file_path\n",
|
198 |
+
"file_path = '' # initial value is ignored"
|
199 |
+
]
|
200 |
+
},
|
201 |
+
{
|
202 |
+
"cell_type": "code",
|
203 |
+
"execution_count": null,
|
204 |
+
"id": "723ee2a1-39ce-4f3a-99ea-f10eebccae1a",
|
205 |
+
"metadata": {},
|
206 |
+
"outputs": [],
|
207 |
+
"source": [
|
208 |
+
"%%mnn widget --type file '.csv' --tab \"Files\" --position 0 3 3 --header \"File picker (only CSV)\" --var csv_path\n",
|
209 |
+
"csv_path = '' # initial value is ignored"
|
210 |
+
]
|
211 |
+
},
|
212 |
+
{
|
213 |
+
"cell_type": "code",
|
214 |
+
"execution_count": null,
|
215 |
+
"id": "cd9d0f32-d91c-4ac7-bc32-a81fb91697c4",
|
216 |
+
"metadata": {},
|
217 |
+
"outputs": [],
|
218 |
+
"source": [
|
219 |
+
"%%mnn widget --type table --tab \"Files\" --position 1 0 6 --header \"CSV preview\" --var csv_df\n",
|
220 |
+
"csv_df = pd.read_csv(csv_path) if csv_path else pd.DataFrame() # show empty DataFrame if no file selected"
|
221 |
+
]
|
222 |
+
}
|
223 |
+
],
|
224 |
+
"metadata": {
|
225 |
+
"kernelspec": {
|
226 |
+
"display_name": "Python 3 (ipykernel)",
|
227 |
+
"language": "python",
|
228 |
+
"name": "python3"
|
229 |
+
},
|
230 |
+
"language_info": {
|
231 |
+
"codemirror_mode": {
|
232 |
+
"name": "ipython",
|
233 |
+
"version": 3
|
234 |
+
},
|
235 |
+
"file_extension": ".py",
|
236 |
+
"mimetype": "text/x-python",
|
237 |
+
"name": "python",
|
238 |
+
"nbconvert_exporter": "python",
|
239 |
+
"pygments_lexer": "ipython3",
|
240 |
+
"version": "3.9.0"
|
241 |
+
}
|
242 |
+
},
|
243 |
+
"nbformat": 4,
|
244 |
+
"nbformat_minor": 5
|
245 |
+
}
|
requirements.txt
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
jupyter
|
2 |
+
pandas
|
3 |
+
cvxpy
|
4 |
+
manganite==0.0.5
|