Spaces:
Runtime error
Runtime error
Commit
•
bf1d125
0
Parent(s):
Duplicate from pplonski/my-notebooks
Browse filesCo-authored-by: Piotr <pplonski@users.noreply.huggingface.co>
- .gitattributes +34 -0
- README.md +15 -0
- app.py +6 -0
- checkbox.ipynb +117 -0
- multiselect.ipynb +106 -0
- range.ipynb +106 -0
- requirements.txt +1 -0
- slider.ipynb +106 -0
- text.ipynb +103 -0
.gitattributes
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
28 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
29 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
30 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
31 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
32 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
33 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
34 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: My Notebooks
|
3 |
+
emoji: 🌍
|
4 |
+
colorFrom: purple
|
5 |
+
colorTo: blue
|
6 |
+
sdk: gradio
|
7 |
+
sdk_version: 3.27.0
|
8 |
+
app_file: app.py
|
9 |
+
pinned: false
|
10 |
+
license: mit
|
11 |
+
fullWidth: true
|
12 |
+
duplicated_from: pplonski/my-notebooks
|
13 |
+
---
|
14 |
+
|
15 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
from subprocess import Popen
|
3 |
+
|
4 |
+
command = ["mercury", "run", f"0.0.0.0:{os.environ.get('PORT', 7860)}", "--verbose"]
|
5 |
+
worker = Popen(command)
|
6 |
+
worker.wait()
|
checkbox.ipynb
ADDED
@@ -0,0 +1,117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": 1,
|
6 |
+
"id": "b05d39ae",
|
7 |
+
"metadata": {},
|
8 |
+
"outputs": [],
|
9 |
+
"source": [
|
10 |
+
"import mercury as mr"
|
11 |
+
]
|
12 |
+
},
|
13 |
+
{
|
14 |
+
"cell_type": "code",
|
15 |
+
"execution_count": 2,
|
16 |
+
"id": "11dd0e47",
|
17 |
+
"metadata": {},
|
18 |
+
"outputs": [
|
19 |
+
{
|
20 |
+
"data": {
|
21 |
+
"application/mercury+json": "{\n \"widget\": \"App\",\n \"title\": \"Checkbox demo\",\n \"description\": \"Show Checkbox widget usage\",\n \"show_code\": true,\n \"show_prompt\": false,\n \"output\": \"app\",\n \"schedule\": \"\",\n \"notify\": \"{}\",\n \"continuous_update\": true,\n \"static_notebook\": false,\n \"show_sidebar\": true,\n \"full_screen\": true,\n \"allow_download\": true,\n \"model_id\": \"mercury-app\",\n \"code_uid\": \"App.0.40.24.2-rand39799366\"\n}",
|
22 |
+
"text/html": [
|
23 |
+
"<h3>Mercury Application</h3><small>This output won't appear in the web app.</small>"
|
24 |
+
],
|
25 |
+
"text/plain": [
|
26 |
+
"mercury.App"
|
27 |
+
]
|
28 |
+
},
|
29 |
+
"metadata": {},
|
30 |
+
"output_type": "display_data"
|
31 |
+
}
|
32 |
+
],
|
33 |
+
"source": [
|
34 |
+
"# setup app properies\n",
|
35 |
+
"app = mr.App(title=\"Checkbox\", description=\"Show Checkbox widget usage\", show_code=True)"
|
36 |
+
]
|
37 |
+
},
|
38 |
+
{
|
39 |
+
"cell_type": "code",
|
40 |
+
"execution_count": 3,
|
41 |
+
"id": "841c5232",
|
42 |
+
"metadata": {},
|
43 |
+
"outputs": [
|
44 |
+
{
|
45 |
+
"data": {
|
46 |
+
"application/mercury+json": "{\n \"widget\": \"Checkbox\",\n \"value\": true,\n \"label\": \"Switch me\",\n \"model_id\": \"204f4edc6b9a4c418f8519b4037ef0be\",\n \"code_uid\": \"Checkbox.0.40.11.2-rand5e9a7097\",\n \"url_key\": \"flag\",\n \"disabled\": false,\n \"hidden\": false\n}",
|
47 |
+
"application/vnd.jupyter.widget-view+json": {
|
48 |
+
"model_id": "204f4edc6b9a4c418f8519b4037ef0be",
|
49 |
+
"version_major": 2,
|
50 |
+
"version_minor": 0
|
51 |
+
},
|
52 |
+
"text/plain": [
|
53 |
+
"mercury.Checkbox"
|
54 |
+
]
|
55 |
+
},
|
56 |
+
"metadata": {},
|
57 |
+
"output_type": "display_data"
|
58 |
+
}
|
59 |
+
],
|
60 |
+
"source": [
|
61 |
+
"# add checkbox\n",
|
62 |
+
"my_flag = mr.Checkbox(value=True, label=\"Switch me\", url_key=\"flag\")"
|
63 |
+
]
|
64 |
+
},
|
65 |
+
{
|
66 |
+
"cell_type": "code",
|
67 |
+
"execution_count": 4,
|
68 |
+
"id": "d751ba3d",
|
69 |
+
"metadata": {},
|
70 |
+
"outputs": [
|
71 |
+
{
|
72 |
+
"name": "stdout",
|
73 |
+
"output_type": "stream",
|
74 |
+
"text": [
|
75 |
+
"Checkbox is ON\n"
|
76 |
+
]
|
77 |
+
}
|
78 |
+
],
|
79 |
+
"source": [
|
80 |
+
"# read checkbox value\n",
|
81 |
+
"if my_flag.value:\n",
|
82 |
+
" print(\"Checkbox is ON\")\n",
|
83 |
+
"else:\n",
|
84 |
+
" print(\"Checkbox is OFF\")"
|
85 |
+
]
|
86 |
+
},
|
87 |
+
{
|
88 |
+
"cell_type": "code",
|
89 |
+
"execution_count": null,
|
90 |
+
"id": "3cd671ad",
|
91 |
+
"metadata": {},
|
92 |
+
"outputs": [],
|
93 |
+
"source": []
|
94 |
+
}
|
95 |
+
],
|
96 |
+
"metadata": {
|
97 |
+
"kernelspec": {
|
98 |
+
"display_name": "mex",
|
99 |
+
"language": "python",
|
100 |
+
"name": "mex"
|
101 |
+
},
|
102 |
+
"language_info": {
|
103 |
+
"codemirror_mode": {
|
104 |
+
"name": "ipython",
|
105 |
+
"version": 3
|
106 |
+
},
|
107 |
+
"file_extension": ".py",
|
108 |
+
"mimetype": "text/x-python",
|
109 |
+
"name": "python",
|
110 |
+
"nbconvert_exporter": "python",
|
111 |
+
"pygments_lexer": "ipython3",
|
112 |
+
"version": "3.8.10"
|
113 |
+
}
|
114 |
+
},
|
115 |
+
"nbformat": 4,
|
116 |
+
"nbformat_minor": 5
|
117 |
+
}
|
multiselect.ipynb
ADDED
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": 1,
|
6 |
+
"id": "157994cc",
|
7 |
+
"metadata": {},
|
8 |
+
"outputs": [],
|
9 |
+
"source": [
|
10 |
+
"import mercury as mr"
|
11 |
+
]
|
12 |
+
},
|
13 |
+
{
|
14 |
+
"cell_type": "code",
|
15 |
+
"execution_count": 2,
|
16 |
+
"id": "f2970759",
|
17 |
+
"metadata": {},
|
18 |
+
"outputs": [
|
19 |
+
{
|
20 |
+
"data": {
|
21 |
+
"application/mercury+json": "{\n \"widget\": \"App\",\n \"title\": \"MultiSelect\",\n \"description\": \"Demo of MutiSelect widget\",\n \"show_code\": true,\n \"show_prompt\": false,\n \"output\": \"app\",\n \"schedule\": \"\",\n \"notify\": \"{}\",\n \"continuous_update\": true,\n \"static_notebook\": false,\n \"show_sidebar\": true,\n \"full_screen\": true,\n \"allow_download\": true,\n \"model_id\": \"mercury-app\",\n \"code_uid\": \"App.0.40.24.1-rand52ff8045\"\n}",
|
22 |
+
"text/html": [
|
23 |
+
"<h3>Mercury Application</h3><small>This output won't appear in the web app.</small>"
|
24 |
+
],
|
25 |
+
"text/plain": [
|
26 |
+
"mercury.App"
|
27 |
+
]
|
28 |
+
},
|
29 |
+
"metadata": {},
|
30 |
+
"output_type": "display_data"
|
31 |
+
}
|
32 |
+
],
|
33 |
+
"source": [
|
34 |
+
"app = mr.App(title=\"MultiSelect\", description=\"Demo of MutiSelect widget\", show_code=True)"
|
35 |
+
]
|
36 |
+
},
|
37 |
+
{
|
38 |
+
"cell_type": "code",
|
39 |
+
"execution_count": 3,
|
40 |
+
"id": "e799cfd3",
|
41 |
+
"metadata": {},
|
42 |
+
"outputs": [
|
43 |
+
{
|
44 |
+
"data": {
|
45 |
+
"application/mercury+json": "{\n \"widget\": \"MultiSelect\",\n \"value\": [\n \"a\",\n \"b\"\n ],\n \"choices\": [\n \"a\",\n \"b\",\n \"c\",\n \"d\",\n \"e\"\n ],\n \"label\": \"Please select letters\",\n \"model_id\": \"4bd323cd1655481fbda0eda5adef7a61\",\n \"code_uid\": \"MultiSelect.0.40.16.1-rand84903bec\",\n \"url_key\": \"selected\",\n \"disabled\": false,\n \"hidden\": false\n}",
|
46 |
+
"application/vnd.jupyter.widget-view+json": {
|
47 |
+
"model_id": "4bd323cd1655481fbda0eda5adef7a61",
|
48 |
+
"version_major": 2,
|
49 |
+
"version_minor": 0
|
50 |
+
},
|
51 |
+
"text/plain": [
|
52 |
+
"mercury.MultiSelect"
|
53 |
+
]
|
54 |
+
},
|
55 |
+
"metadata": {},
|
56 |
+
"output_type": "display_data"
|
57 |
+
}
|
58 |
+
],
|
59 |
+
"source": [
|
60 |
+
"selected = mr.MultiSelect(label=\"Please select letters\", \n",
|
61 |
+
" value=[\"a\", \"b\"], \n",
|
62 |
+
" choices=[\"a\", \"b\", \"c\", \"d\", \"e\"],\n",
|
63 |
+
" url_key=\"selected\")"
|
64 |
+
]
|
65 |
+
},
|
66 |
+
{
|
67 |
+
"cell_type": "code",
|
68 |
+
"execution_count": 4,
|
69 |
+
"id": "86a9e273",
|
70 |
+
"metadata": {},
|
71 |
+
"outputs": [
|
72 |
+
{
|
73 |
+
"name": "stdout",
|
74 |
+
"output_type": "stream",
|
75 |
+
"text": [
|
76 |
+
"['a', 'b']\n"
|
77 |
+
]
|
78 |
+
}
|
79 |
+
],
|
80 |
+
"source": [
|
81 |
+
"print(selected.value)"
|
82 |
+
]
|
83 |
+
}
|
84 |
+
],
|
85 |
+
"metadata": {
|
86 |
+
"kernelspec": {
|
87 |
+
"display_name": "mex",
|
88 |
+
"language": "python",
|
89 |
+
"name": "mex"
|
90 |
+
},
|
91 |
+
"language_info": {
|
92 |
+
"codemirror_mode": {
|
93 |
+
"name": "ipython",
|
94 |
+
"version": 3
|
95 |
+
},
|
96 |
+
"file_extension": ".py",
|
97 |
+
"mimetype": "text/x-python",
|
98 |
+
"name": "python",
|
99 |
+
"nbconvert_exporter": "python",
|
100 |
+
"pygments_lexer": "ipython3",
|
101 |
+
"version": "3.8.10"
|
102 |
+
}
|
103 |
+
},
|
104 |
+
"nbformat": 4,
|
105 |
+
"nbformat_minor": 5
|
106 |
+
}
|
range.ipynb
ADDED
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": 1,
|
6 |
+
"id": "0954eef1",
|
7 |
+
"metadata": {},
|
8 |
+
"outputs": [],
|
9 |
+
"source": [
|
10 |
+
"import mercury as mr"
|
11 |
+
]
|
12 |
+
},
|
13 |
+
{
|
14 |
+
"cell_type": "code",
|
15 |
+
"execution_count": 2,
|
16 |
+
"id": "e49cd34d",
|
17 |
+
"metadata": {},
|
18 |
+
"outputs": [
|
19 |
+
{
|
20 |
+
"data": {
|
21 |
+
"application/mercury+json": "{\n \"widget\": \"App\",\n \"title\": \"Range\",\n \"description\": \"Range widget demo\",\n \"show_code\": true,\n \"show_prompt\": false,\n \"output\": \"app\",\n \"schedule\": \"\",\n \"notify\": \"{}\",\n \"continuous_update\": true,\n \"static_notebook\": false,\n \"show_sidebar\": true,\n \"full_screen\": true,\n \"allow_download\": true,\n \"model_id\": \"mercury-app\",\n \"code_uid\": \"App.0.40.24.1-rand8e094375\"\n}",
|
22 |
+
"text/html": [
|
23 |
+
"<h3>Mercury Application</h3><small>This output won't appear in the web app.</small>"
|
24 |
+
],
|
25 |
+
"text/plain": [
|
26 |
+
"mercury.App"
|
27 |
+
]
|
28 |
+
},
|
29 |
+
"metadata": {},
|
30 |
+
"output_type": "display_data"
|
31 |
+
}
|
32 |
+
],
|
33 |
+
"source": [
|
34 |
+
"app = mr.App(title=\"Range\", description=\"Range widget demo\", show_code=True)"
|
35 |
+
]
|
36 |
+
},
|
37 |
+
{
|
38 |
+
"cell_type": "code",
|
39 |
+
"execution_count": 3,
|
40 |
+
"id": "412fce10",
|
41 |
+
"metadata": {},
|
42 |
+
"outputs": [
|
43 |
+
{
|
44 |
+
"data": {
|
45 |
+
"application/mercury+json": "{\n \"widget\": \"Range\",\n \"value\": [\n 1,\n 6\n ],\n \"min\": 0,\n \"max\": 10,\n \"step\": 1,\n \"label\": \"Your favourite range\",\n \"model_id\": \"c7bb17abbf4b49c4a5b7edf2c971803e\",\n \"code_uid\": \"Range.0.40.30.2-randc2556550\",\n \"url_key\": \"\",\n \"disabled\": false,\n \"hidden\": false\n}",
|
46 |
+
"application/vnd.jupyter.widget-view+json": {
|
47 |
+
"model_id": "c7bb17abbf4b49c4a5b7edf2c971803e",
|
48 |
+
"version_major": 2,
|
49 |
+
"version_minor": 0
|
50 |
+
},
|
51 |
+
"text/plain": [
|
52 |
+
"mercury.Range"
|
53 |
+
]
|
54 |
+
},
|
55 |
+
"metadata": {},
|
56 |
+
"output_type": "display_data"
|
57 |
+
}
|
58 |
+
],
|
59 |
+
"source": [
|
60 |
+
"# add range widget\n",
|
61 |
+
"your_range = mr.Range(value=[1, 6], min=0, max=10, label=\"Your favourite range\", \n",
|
62 |
+
" step=1, url_key=\"my-range\")"
|
63 |
+
]
|
64 |
+
},
|
65 |
+
{
|
66 |
+
"cell_type": "code",
|
67 |
+
"execution_count": 4,
|
68 |
+
"id": "4c3147bc",
|
69 |
+
"metadata": {},
|
70 |
+
"outputs": [
|
71 |
+
{
|
72 |
+
"name": "stdout",
|
73 |
+
"output_type": "stream",
|
74 |
+
"text": [
|
75 |
+
"Your range starts at 1 ends at 6\n"
|
76 |
+
]
|
77 |
+
}
|
78 |
+
],
|
79 |
+
"source": [
|
80 |
+
"# access widget value in the code\n",
|
81 |
+
"print(f\"Your range starts at {your_range.value[0]} ends at {your_range.value[1]}\")"
|
82 |
+
]
|
83 |
+
}
|
84 |
+
],
|
85 |
+
"metadata": {
|
86 |
+
"kernelspec": {
|
87 |
+
"display_name": "mex",
|
88 |
+
"language": "python",
|
89 |
+
"name": "mex"
|
90 |
+
},
|
91 |
+
"language_info": {
|
92 |
+
"codemirror_mode": {
|
93 |
+
"name": "ipython",
|
94 |
+
"version": 3
|
95 |
+
},
|
96 |
+
"file_extension": ".py",
|
97 |
+
"mimetype": "text/x-python",
|
98 |
+
"name": "python",
|
99 |
+
"nbconvert_exporter": "python",
|
100 |
+
"pygments_lexer": "ipython3",
|
101 |
+
"version": "3.8.10"
|
102 |
+
}
|
103 |
+
},
|
104 |
+
"nbformat": 4,
|
105 |
+
"nbformat_minor": 5
|
106 |
+
}
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
mercury>=2.2.6
|
slider.ipynb
ADDED
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": 1,
|
6 |
+
"id": "b2377049",
|
7 |
+
"metadata": {},
|
8 |
+
"outputs": [],
|
9 |
+
"source": [
|
10 |
+
"import mercury as mr"
|
11 |
+
]
|
12 |
+
},
|
13 |
+
{
|
14 |
+
"cell_type": "code",
|
15 |
+
"execution_count": 2,
|
16 |
+
"id": "e2a239f0",
|
17 |
+
"metadata": {},
|
18 |
+
"outputs": [
|
19 |
+
{
|
20 |
+
"data": {
|
21 |
+
"application/mercury+json": "{\n \"widget\": \"App\",\n \"title\": \"Slider\",\n \"description\": \"Demo of Slider widget\",\n \"show_code\": true,\n \"show_prompt\": false,\n \"output\": \"app\",\n \"schedule\": \"\",\n \"notify\": \"{}\",\n \"continuous_update\": true,\n \"static_notebook\": false,\n \"show_sidebar\": true,\n \"full_screen\": true,\n \"allow_download\": true,\n \"model_id\": \"mercury-app\",\n \"code_uid\": \"App.0.40.24.1-rand1686cc3b\"\n}",
|
22 |
+
"text/html": [
|
23 |
+
"<h3>Mercury Application</h3><small>This output won't appear in the web app.</small>"
|
24 |
+
],
|
25 |
+
"text/plain": [
|
26 |
+
"mercury.App"
|
27 |
+
]
|
28 |
+
},
|
29 |
+
"metadata": {},
|
30 |
+
"output_type": "display_data"
|
31 |
+
}
|
32 |
+
],
|
33 |
+
"source": [
|
34 |
+
"app = mr.App(title=\"Slider\", description=\"Demo of Slider widget\", show_code=True)"
|
35 |
+
]
|
36 |
+
},
|
37 |
+
{
|
38 |
+
"cell_type": "code",
|
39 |
+
"execution_count": 3,
|
40 |
+
"id": "b71b36bd",
|
41 |
+
"metadata": {},
|
42 |
+
"outputs": [
|
43 |
+
{
|
44 |
+
"data": {
|
45 |
+
"application/mercury+json": "{\n \"widget\": \"Slider\",\n \"value\": 0,\n \"min\": 0,\n \"max\": 10,\n \"step\": 1,\n \"label\": \"Your favourite number\",\n \"model_id\": \"e72d431e26ba4b39b0dd87af3f159134\",\n \"code_uid\": \"Slider.0.40.26.2-rand67b7c60c\",\n \"url_key\": \"slider\",\n \"disabled\": false,\n \"hidden\": false\n}",
|
46 |
+
"application/vnd.jupyter.widget-view+json": {
|
47 |
+
"model_id": "e72d431e26ba4b39b0dd87af3f159134",
|
48 |
+
"version_major": 2,
|
49 |
+
"version_minor": 0
|
50 |
+
},
|
51 |
+
"text/plain": [
|
52 |
+
"mercury.Slider"
|
53 |
+
]
|
54 |
+
},
|
55 |
+
"metadata": {},
|
56 |
+
"output_type": "display_data"
|
57 |
+
}
|
58 |
+
],
|
59 |
+
"source": [
|
60 |
+
"# add widget\n",
|
61 |
+
"your_slider = mr.Slider(value=0, min=0, max=10, label=\"Your favourite number\", \n",
|
62 |
+
" step=1, url_key=\"slider\")"
|
63 |
+
]
|
64 |
+
},
|
65 |
+
{
|
66 |
+
"cell_type": "code",
|
67 |
+
"execution_count": 4,
|
68 |
+
"id": "13e16734",
|
69 |
+
"metadata": {},
|
70 |
+
"outputs": [
|
71 |
+
{
|
72 |
+
"name": "stdout",
|
73 |
+
"output_type": "stream",
|
74 |
+
"text": [
|
75 |
+
"Your value is 0\n"
|
76 |
+
]
|
77 |
+
}
|
78 |
+
],
|
79 |
+
"source": [
|
80 |
+
"# access widget value in the code\n",
|
81 |
+
"print(f\"Your value is {your_slider.value}\")"
|
82 |
+
]
|
83 |
+
}
|
84 |
+
],
|
85 |
+
"metadata": {
|
86 |
+
"kernelspec": {
|
87 |
+
"display_name": "mex",
|
88 |
+
"language": "python",
|
89 |
+
"name": "mex"
|
90 |
+
},
|
91 |
+
"language_info": {
|
92 |
+
"codemirror_mode": {
|
93 |
+
"name": "ipython",
|
94 |
+
"version": 3
|
95 |
+
},
|
96 |
+
"file_extension": ".py",
|
97 |
+
"mimetype": "text/x-python",
|
98 |
+
"name": "python",
|
99 |
+
"nbconvert_exporter": "python",
|
100 |
+
"pygments_lexer": "ipython3",
|
101 |
+
"version": "3.8.10"
|
102 |
+
}
|
103 |
+
},
|
104 |
+
"nbformat": 4,
|
105 |
+
"nbformat_minor": 5
|
106 |
+
}
|
text.ipynb
ADDED
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": 1,
|
6 |
+
"id": "164f76b7",
|
7 |
+
"metadata": {},
|
8 |
+
"outputs": [],
|
9 |
+
"source": [
|
10 |
+
"import mercury as mr"
|
11 |
+
]
|
12 |
+
},
|
13 |
+
{
|
14 |
+
"cell_type": "code",
|
15 |
+
"execution_count": 2,
|
16 |
+
"id": "17c4a3fd",
|
17 |
+
"metadata": {},
|
18 |
+
"outputs": [
|
19 |
+
{
|
20 |
+
"data": {
|
21 |
+
"application/mercury+json": "{\n \"widget\": \"App\",\n \"title\": \"Text\",\n \"description\": \"Demo of Text widget\",\n \"show_code\": true,\n \"show_prompt\": false,\n \"output\": \"app\",\n \"schedule\": \"\",\n \"notify\": \"{}\",\n \"continuous_update\": true,\n \"static_notebook\": false,\n \"show_sidebar\": true,\n \"full_screen\": true,\n \"allow_download\": true,\n \"model_id\": \"mercury-app\",\n \"code_uid\": \"App.0.40.24.1-rande67e72ed\"\n}",
|
22 |
+
"text/html": [
|
23 |
+
"<h3>Mercury Application</h3><small>This output won't appear in the web app.</small>"
|
24 |
+
],
|
25 |
+
"text/plain": [
|
26 |
+
"mercury.App"
|
27 |
+
]
|
28 |
+
},
|
29 |
+
"metadata": {},
|
30 |
+
"output_type": "display_data"
|
31 |
+
}
|
32 |
+
],
|
33 |
+
"source": [
|
34 |
+
"app = mr.App(title=\"Text\", description=\"Demo of Text widget\", show_code=True)"
|
35 |
+
]
|
36 |
+
},
|
37 |
+
{
|
38 |
+
"cell_type": "code",
|
39 |
+
"execution_count": 3,
|
40 |
+
"id": "f3c12349",
|
41 |
+
"metadata": {},
|
42 |
+
"outputs": [
|
43 |
+
{
|
44 |
+
"data": {
|
45 |
+
"application/mercury+json": "{\n \"widget\": \"Text\",\n \"value\": \"Piotr\",\n \"rows\": 1,\n \"label\": \"What is your name?\",\n \"model_id\": \"9dc1a4398f7a4b96abb2077f790c4f47\",\n \"code_uid\": \"Text.0.40.15.1-rande827c6e5\",\n \"url_key\": \"name\",\n \"disabled\": false,\n \"hidden\": false\n}",
|
46 |
+
"application/vnd.jupyter.widget-view+json": {
|
47 |
+
"model_id": "9dc1a4398f7a4b96abb2077f790c4f47",
|
48 |
+
"version_major": 2,
|
49 |
+
"version_minor": 0
|
50 |
+
},
|
51 |
+
"text/plain": [
|
52 |
+
"mercury.Text"
|
53 |
+
]
|
54 |
+
},
|
55 |
+
"metadata": {},
|
56 |
+
"output_type": "display_data"
|
57 |
+
}
|
58 |
+
],
|
59 |
+
"source": [
|
60 |
+
"name = mr.Text(value=\"Piotr\", label=\"What is your name?\", rows=1, url_key=\"name\")"
|
61 |
+
]
|
62 |
+
},
|
63 |
+
{
|
64 |
+
"cell_type": "code",
|
65 |
+
"execution_count": 4,
|
66 |
+
"id": "6dadd338",
|
67 |
+
"metadata": {},
|
68 |
+
"outputs": [
|
69 |
+
{
|
70 |
+
"name": "stdout",
|
71 |
+
"output_type": "stream",
|
72 |
+
"text": [
|
73 |
+
"Hello Piotr!\n"
|
74 |
+
]
|
75 |
+
}
|
76 |
+
],
|
77 |
+
"source": [
|
78 |
+
"print(f\"Hello {name.value}!\")"
|
79 |
+
]
|
80 |
+
}
|
81 |
+
],
|
82 |
+
"metadata": {
|
83 |
+
"kernelspec": {
|
84 |
+
"display_name": "mex",
|
85 |
+
"language": "python",
|
86 |
+
"name": "mex"
|
87 |
+
},
|
88 |
+
"language_info": {
|
89 |
+
"codemirror_mode": {
|
90 |
+
"name": "ipython",
|
91 |
+
"version": 3
|
92 |
+
},
|
93 |
+
"file_extension": ".py",
|
94 |
+
"mimetype": "text/x-python",
|
95 |
+
"name": "python",
|
96 |
+
"nbconvert_exporter": "python",
|
97 |
+
"pygments_lexer": "ipython3",
|
98 |
+
"version": "3.8.10"
|
99 |
+
}
|
100 |
+
},
|
101 |
+
"nbformat": 4,
|
102 |
+
"nbformat_minor": 5
|
103 |
+
}
|