rupaka 0.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- rupaka-0.0.1/.gitignore +160 -0
- rupaka-0.0.1/LICENSE +21 -0
- rupaka-0.0.1/PKG-INFO +116 -0
- rupaka-0.0.1/README.md +90 -0
- rupaka-0.0.1/pyproject.toml +50 -0
- rupaka-0.0.1/rupaka/__init__.py +1 -0
- rupaka-0.0.1/rupaka/_modidx.py +115 -0
- rupaka-0.0.1/rupaka/agent.py +124 -0
- rupaka-0.0.1/rupaka/blocks/axis/axis.css +4 -0
- rupaka-0.0.1/rupaka/blocks/axis/axis.js +31 -0
- rupaka-0.0.1/rupaka/blocks/axis/block.json +18 -0
- rupaka-0.0.1/rupaka/blocks/axis/example.json +12 -0
- rupaka-0.0.1/rupaka/blocks/bars/bars.css +8 -0
- rupaka-0.0.1/rupaka/blocks/bars/bars.js +24 -0
- rupaka-0.0.1/rupaka/blocks/bars/block.json +16 -0
- rupaka-0.0.1/rupaka/blocks/bars/example.json +9 -0
- rupaka-0.0.1/rupaka/blocks/caption/block.json +11 -0
- rupaka-0.0.1/rupaka/blocks/caption/caption.css +2 -0
- rupaka-0.0.1/rupaka/blocks/caption/caption.js +6 -0
- rupaka-0.0.1/rupaka/blocks/caption/example.json +9 -0
- rupaka-0.0.1/rupaka/blocks/choice/block.json +13 -0
- rupaka-0.0.1/rupaka/blocks/choice/choice.css +2 -0
- rupaka-0.0.1/rupaka/blocks/choice/choice.js +20 -0
- rupaka-0.0.1/rupaka/blocks/choice/example.json +11 -0
- rupaka-0.0.1/rupaka/blocks/gate/block.json +17 -0
- rupaka-0.0.1/rupaka/blocks/gate/example.json +10 -0
- rupaka-0.0.1/rupaka/blocks/gate/gate.css +14 -0
- rupaka-0.0.1/rupaka/blocks/gate/gate.js +61 -0
- rupaka-0.0.1/rupaka/blocks/grid/block.json +23 -0
- rupaka-0.0.1/rupaka/blocks/grid/example.json +9 -0
- rupaka-0.0.1/rupaka/blocks/grid/grid.css +8 -0
- rupaka-0.0.1/rupaka/blocks/grid/grid.js +45 -0
- rupaka-0.0.1/rupaka/blocks/plot/block.json +13 -0
- rupaka-0.0.1/rupaka/blocks/plot/example.json +11 -0
- rupaka-0.0.1/rupaka/blocks/plot/plot.css +2 -0
- rupaka-0.0.1/rupaka/blocks/plot/plot.js +18 -0
- rupaka-0.0.1/rupaka/blocks/point/block.json +19 -0
- rupaka-0.0.1/rupaka/blocks/point/example.json +11 -0
- rupaka-0.0.1/rupaka/blocks/point/point.css +7 -0
- rupaka-0.0.1/rupaka/blocks/point/point.js +36 -0
- rupaka-0.0.1/rupaka/blocks/ranklist/block.json +14 -0
- rupaka-0.0.1/rupaka/blocks/ranklist/example.json +9 -0
- rupaka-0.0.1/rupaka/blocks/ranklist/ranklist.css +13 -0
- rupaka-0.0.1/rupaka/blocks/ranklist/ranklist.js +42 -0
- rupaka-0.0.1/rupaka/blocks/readout/block.json +11 -0
- rupaka-0.0.1/rupaka/blocks/readout/example.json +9 -0
- rupaka-0.0.1/rupaka/blocks/readout/readout.css +1 -0
- rupaka-0.0.1/rupaka/blocks/readout/readout.js +6 -0
- rupaka-0.0.1/rupaka/blocks/row/block.json +10 -0
- rupaka-0.0.1/rupaka/blocks/row/example.json +12 -0
- rupaka-0.0.1/rupaka/blocks/row/row.css +2 -0
- rupaka-0.0.1/rupaka/blocks/row/row.js +2 -0
- rupaka-0.0.1/rupaka/blocks/slider/block.json +18 -0
- rupaka-0.0.1/rupaka/blocks/slider/example.json +10 -0
- rupaka-0.0.1/rupaka/blocks/slider/slider.css +3 -0
- rupaka-0.0.1/rupaka/blocks/slider/slider.js +19 -0
- rupaka-0.0.1/rupaka/blocks/stack/block.json +10 -0
- rupaka-0.0.1/rupaka/blocks/stack/example.json +11 -0
- rupaka-0.0.1/rupaka/blocks/stack/stack.css +2 -0
- rupaka-0.0.1/rupaka/blocks/stack/stack.js +2 -0
- rupaka-0.0.1/rupaka/blocks/toggle/block.json +14 -0
- rupaka-0.0.1/rupaka/blocks/toggle/example.json +10 -0
- rupaka-0.0.1/rupaka/blocks/toggle/toggle.css +5 -0
- rupaka-0.0.1/rupaka/blocks/toggle/toggle.js +11 -0
- rupaka-0.0.1/rupaka/blocks/wheel/block.json +19 -0
- rupaka-0.0.1/rupaka/blocks/wheel/example.json +15 -0
- rupaka-0.0.1/rupaka/blocks/wheel/wheel.css +20 -0
- rupaka-0.0.1/rupaka/blocks/wheel/wheel.js +73 -0
- rupaka-0.0.1/rupaka/check.py +207 -0
- rupaka-0.0.1/rupaka/demos/nakshatra-pada.json +41 -0
- rupaka-0.0.1/rupaka/demos/parabola-vertex.json +27 -0
- rupaka-0.0.1/rupaka/demos/reciprocal-rank-fusion.json +20 -0
- rupaka-0.0.1/rupaka/demos/softmax-temperature.json +17 -0
- rupaka-0.0.1/rupaka/demos/vowel-sandhi.json +39 -0
- rupaka-0.0.1/rupaka/fns/expr.js +56 -0
- rupaka-0.0.1/rupaka/fns/expr.json +10 -0
- rupaka-0.0.1/rupaka/fns/fmt.json +7 -0
- rupaka-0.0.1/rupaka/fns/helpers.js +8 -0
- rupaka-0.0.1/rupaka/fns/ids.json +7 -0
- rupaka-0.0.1/rupaka/fns/lookup.js +8 -0
- rupaka-0.0.1/rupaka/fns/lookup.json +11 -0
- rupaka-0.0.1/rupaka/fns/pick.json +7 -0
- rupaka-0.0.1/rupaka/fns/rrf.js +6 -0
- rupaka-0.0.1/rupaka/fns/rrf.json +10 -0
- rupaka-0.0.1/rupaka/fns/rules.js +14 -0
- rupaka-0.0.1/rupaka/fns/rules.json +11 -0
- rupaka-0.0.1/rupaka/fns/softmax.js +10 -0
- rupaka-0.0.1/rupaka/fns/softmax.json +13 -0
- rupaka-0.0.1/rupaka/fns/sort.json +7 -0
- rupaka-0.0.1/rupaka/render.py +115 -0
- rupaka-0.0.1/rupaka/spec.py +504 -0
- rupaka-0.0.1/rupaka/static/boot.js +9 -0
- rupaka-0.0.1/rupaka/static/fonts/LICENSES.txt +69 -0
- rupaka-0.0.1/rupaka/static/fonts/libre-baskerville-latin-400-normal.woff2 +0 -0
- rupaka-0.0.1/rupaka/static/fonts/libre-baskerville-latin-ext-400-normal.woff2 +0 -0
- rupaka-0.0.1/rupaka/static/fonts/literata-latin-ext-wght-italic.woff2 +0 -0
- rupaka-0.0.1/rupaka/static/fonts/literata-latin-ext-wght-normal.woff2 +0 -0
- rupaka-0.0.1/rupaka/static/fonts/literata-latin-wght-italic.woff2 +0 -0
- rupaka-0.0.1/rupaka/static/fonts/literata-latin-wght-normal.woff2 +0 -0
- rupaka-0.0.1/rupaka/static/page.css +11 -0
- rupaka-0.0.1/rupaka/static/rupaka.css +35 -0
- rupaka-0.0.1/rupaka/static/rupaka.js +93 -0
rupaka-0.0.1/.gitignore
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
_docs/
|
|
2
|
+
_proc/
|
|
3
|
+
|
|
4
|
+
*.bak
|
|
5
|
+
.gitattributes
|
|
6
|
+
.last_checked
|
|
7
|
+
.gitconfig
|
|
8
|
+
*.bak
|
|
9
|
+
*.log
|
|
10
|
+
*~
|
|
11
|
+
~*
|
|
12
|
+
_tmp*
|
|
13
|
+
tmp*
|
|
14
|
+
tags
|
|
15
|
+
*.pkg
|
|
16
|
+
|
|
17
|
+
# Byte-compiled / optimized / DLL files
|
|
18
|
+
__pycache__/
|
|
19
|
+
*.py[cod]
|
|
20
|
+
*$py.class
|
|
21
|
+
|
|
22
|
+
# C extensions
|
|
23
|
+
*.so
|
|
24
|
+
|
|
25
|
+
# Distribution / packaging
|
|
26
|
+
.Python
|
|
27
|
+
env/
|
|
28
|
+
build/
|
|
29
|
+
conda/
|
|
30
|
+
develop-eggs/
|
|
31
|
+
dist/
|
|
32
|
+
downloads/
|
|
33
|
+
eggs/
|
|
34
|
+
.eggs/
|
|
35
|
+
lib/
|
|
36
|
+
lib64/
|
|
37
|
+
parts/
|
|
38
|
+
sdist/
|
|
39
|
+
var/
|
|
40
|
+
wheels/
|
|
41
|
+
*.egg-info/
|
|
42
|
+
.installed.cfg
|
|
43
|
+
*.egg
|
|
44
|
+
|
|
45
|
+
# PyInstaller
|
|
46
|
+
# Usually these files are written by a python script from a template
|
|
47
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
48
|
+
*.manifest
|
|
49
|
+
*.spec
|
|
50
|
+
|
|
51
|
+
# Installer logs
|
|
52
|
+
pip-log.txt
|
|
53
|
+
pip-delete-this-directory.txt
|
|
54
|
+
|
|
55
|
+
# Unit test / coverage reports
|
|
56
|
+
htmlcov/
|
|
57
|
+
.tox/
|
|
58
|
+
.coverage
|
|
59
|
+
.coverage.*
|
|
60
|
+
.cache
|
|
61
|
+
nosetests.xml
|
|
62
|
+
coverage.xml
|
|
63
|
+
*.cover
|
|
64
|
+
.hypothesis/
|
|
65
|
+
|
|
66
|
+
# Translations
|
|
67
|
+
*.mo
|
|
68
|
+
*.pot
|
|
69
|
+
|
|
70
|
+
# Django stuff:
|
|
71
|
+
*.log
|
|
72
|
+
local_settings.py
|
|
73
|
+
|
|
74
|
+
# Flask stuff:
|
|
75
|
+
instance/
|
|
76
|
+
.webassets-cache
|
|
77
|
+
|
|
78
|
+
# Scrapy stuff:
|
|
79
|
+
.scrapy
|
|
80
|
+
|
|
81
|
+
# Sphinx documentation
|
|
82
|
+
docs/_build/
|
|
83
|
+
|
|
84
|
+
# PyBuilder
|
|
85
|
+
target/
|
|
86
|
+
|
|
87
|
+
# Jupyter Notebook
|
|
88
|
+
.ipynb_checkpoints
|
|
89
|
+
|
|
90
|
+
# pyenv
|
|
91
|
+
.python-version
|
|
92
|
+
|
|
93
|
+
# celery beat schedule file
|
|
94
|
+
celerybeat-schedule
|
|
95
|
+
|
|
96
|
+
# SageMath parsed files
|
|
97
|
+
*.sage.py
|
|
98
|
+
|
|
99
|
+
# dotenv
|
|
100
|
+
.env
|
|
101
|
+
|
|
102
|
+
# virtualenv
|
|
103
|
+
.venv
|
|
104
|
+
venv/
|
|
105
|
+
ENV/
|
|
106
|
+
|
|
107
|
+
# Spyder project settings
|
|
108
|
+
.spyderproject
|
|
109
|
+
.spyproject
|
|
110
|
+
|
|
111
|
+
# Rope project settings
|
|
112
|
+
.ropeproject
|
|
113
|
+
|
|
114
|
+
# mkdocs documentation
|
|
115
|
+
/site
|
|
116
|
+
|
|
117
|
+
# mypy
|
|
118
|
+
.mypy_cache/
|
|
119
|
+
|
|
120
|
+
.vscode
|
|
121
|
+
*.swp
|
|
122
|
+
|
|
123
|
+
# osx generated files
|
|
124
|
+
.DS_Store
|
|
125
|
+
.DS_Store?
|
|
126
|
+
.Trashes
|
|
127
|
+
ehthumbs.db
|
|
128
|
+
Thumbs.db
|
|
129
|
+
.idea
|
|
130
|
+
|
|
131
|
+
# pytest
|
|
132
|
+
.pytest_cache
|
|
133
|
+
|
|
134
|
+
# tools/trust-doc-nbs
|
|
135
|
+
docs_src/.last_checked
|
|
136
|
+
|
|
137
|
+
# symlinks to fastai
|
|
138
|
+
docs_src/fastai
|
|
139
|
+
tools/fastai
|
|
140
|
+
|
|
141
|
+
# link checker
|
|
142
|
+
checklink/cookies.txt
|
|
143
|
+
|
|
144
|
+
# .gitconfig is now autogenerated
|
|
145
|
+
.gitconfig
|
|
146
|
+
|
|
147
|
+
# Quarto installer
|
|
148
|
+
.deb
|
|
149
|
+
.pkg
|
|
150
|
+
|
|
151
|
+
# Quarto
|
|
152
|
+
.quarto
|
|
153
|
+
|
|
154
|
+
.venv/
|
|
155
|
+
.kosha/
|
|
156
|
+
_docs/
|
|
157
|
+
_proc/
|
|
158
|
+
nbs/_fixtures/
|
|
159
|
+
|
|
160
|
+
tests/screens/
|
rupaka-0.0.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Karthik
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
rupaka-0.0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: rupaka
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Interactive SVG demos from JSON specs, made of small reusable blocks, that make the learner predict first
|
|
5
|
+
Project-URL: Repository, https://github.com/vedicreader/rupaka
|
|
6
|
+
Project-URL: Documentation, https://vedicreader.github.io/rupaka/
|
|
7
|
+
Author-email: Karthik <karthik.rajgopal@hotmail.com>
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Keywords: demos,interactive,learning,nbdev,svg,teaching
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Education
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
15
|
+
Requires-Python: >=3.10
|
|
16
|
+
Requires-Dist: fastcore>=1.8
|
|
17
|
+
Provides-Extra: check
|
|
18
|
+
Requires-Dist: playwright>=1.40; extra == 'check'
|
|
19
|
+
Provides-Extra: dev
|
|
20
|
+
Requires-Dist: ipykernel>=7.3.0; extra == 'dev'
|
|
21
|
+
Requires-Dist: nbdev>=3.3.26; extra == 'dev'
|
|
22
|
+
Requires-Dist: notebook>=7.6.3; extra == 'dev'
|
|
23
|
+
Requires-Dist: playwright>=1.40; extra == 'dev'
|
|
24
|
+
Requires-Dist: pytest>=8; extra == 'dev'
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
|
|
27
|
+
# rupaka
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->
|
|
31
|
+
|
|
32
|
+
rupaka (रूपक) means a form, a play that the audience sees, and the figure of speech that shows one thing through another.
|
|
33
|
+
A rupaka demo is one interactive figure that teaches one idea. The learner changes the inputs and sees the result change.
|
|
34
|
+
|
|
35
|
+
A demo never shows the answer first. Each demo follows one loop:
|
|
36
|
+
|
|
37
|
+
1. Predict. The demo shows the inputs and asks one question. The result is hidden.
|
|
38
|
+
2. Reveal. The learner locks in with ⌘↩. The demo shows the result and says if the prediction was right.
|
|
39
|
+
3. Manipulate. Now the controls are live. The result changes when the inputs change.
|
|
40
|
+
4. Explain. The caption ends with a new question that the learner answers with the controls.
|
|
41
|
+
|
|
42
|
+
The validator enforces step 1: a block that shows a value which the answer depends on must wait for the gate.
|
|
43
|
+
|
|
44
|
+
## What a demo is
|
|
45
|
+
|
|
46
|
+
A demo is a JSON spec, not code. It has a small state, derived values from named functions (fns), and a list of blocks.
|
|
47
|
+
A model can write a spec safely, because a spec cannot run code.
|
|
48
|
+
|
|
49
|
+
| part | what it is |
|
|
50
|
+
|----|----|
|
|
51
|
+
| block | a reusable UI part in `rupaka/blocks/<name>/`: its JS, its CSS, a `block.json` manifest and an example |
|
|
52
|
+
| fn | a pure function that computes a derived value: [`rules`](https://vedicreader.github.io/rupaka/spec.html#rules), [`rrf`](https://vedicreader.github.io/rupaka/spec.html#rrf), [`softmax`](https://vedicreader.github.io/rupaka/spec.html#softmax), [`lookup`](https://vedicreader.github.io/rupaka/spec.html#lookup), [`expr`](https://vedicreader.github.io/rupaka/spec.html#expr), `ids`, `pick`, `sort`, [`fmt`](https://vedicreader.github.io/rupaka/spec.html#fmt) |
|
|
53
|
+
| gate | the block that asks for the prediction and hides the result until the lock in |
|
|
54
|
+
| spec | the JSON object: `state`, `derive`, `blocks` and `tables` |
|
|
55
|
+
|
|
56
|
+
The blocks are [`gate`](https://vedicreader.github.io/rupaka/spec.html#gate), [`readout`](https://vedicreader.github.io/rupaka/spec.html#readout), [`caption`](https://vedicreader.github.io/rupaka/spec.html#caption), [`row`](https://vedicreader.github.io/rupaka/spec.html#row), [`stack`](https://vedicreader.github.io/rupaka/spec.html#stack), [`slider`](https://vedicreader.github.io/rupaka/spec.html#slider), [`toggle`](https://vedicreader.github.io/rupaka/spec.html#toggle), [`choice`](https://vedicreader.github.io/rupaka/spec.html#choice), [`wheel`](https://vedicreader.github.io/rupaka/spec.html#wheel), [`ranklist`](https://vedicreader.github.io/rupaka/spec.html#ranklist), [`bars`](https://vedicreader.github.io/rupaka/spec.html#bars), [`axis`](https://vedicreader.github.io/rupaka/spec.html#axis), [`point`](https://vedicreader.github.io/rupaka/spec.html#point), [`plot`](https://vedicreader.github.io/rupaka/spec.html#plot) and [`grid`](https://vedicreader.github.io/rupaka/spec.html#grid).
|
|
57
|
+
|
|
58
|
+
## Install
|
|
59
|
+
|
|
60
|
+
``` sh
|
|
61
|
+
pip install rupaka
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
The headless check needs playwright: `pip install "rupaka[check]"`. It uses the Chromium that `playwright install chromium` gives, or the browser in `$FASTCDP_CHROME`. It never runs your everyday Chrome.
|
|
65
|
+
|
|
66
|
+
## How to use
|
|
67
|
+
|
|
68
|
+
Build a spec with the builders, or write the JSON.
|
|
69
|
+
|
|
70
|
+
``` python
|
|
71
|
+
from rupaka.spec import *
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
``` python
|
|
75
|
+
d = demo('sum', 'A sum', ask='Predict the sum before you see it.', state=dict(a=2, b=3), derive=[expr('a + b', 'sum')],
|
|
76
|
+
blocks=[gate('s', 'What is {a} + {b}?', [4, 5, 6], 'sum', why='Say why, in one line.'),
|
|
77
|
+
readout('{a} + {b} = {sum}', after='s')])
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
[`validate`](https://vedicreader.github.io/rupaka/spec.html#validate) returns the errors. An empty list means the spec is good.
|
|
81
|
+
|
|
82
|
+
``` python
|
|
83
|
+
assert validate(d) == []
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
A readout that shows the sum before the gate breaks the think rule:
|
|
87
|
+
|
|
88
|
+
``` python
|
|
89
|
+
bad = {**d, 'blocks': [d['blocks'][0], readout('{a} + {b} = {sum}')]}
|
|
90
|
+
validate(bad)
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Then put the demo where the learner is:
|
|
94
|
+
|
|
95
|
+
| where | how |
|
|
96
|
+
|----|----|
|
|
97
|
+
| a notebook (leela, Jupyter) | `show(spec)`: an HTML output in a sandboxed frame, and the `application/vnd.rupaka+json` mime |
|
|
98
|
+
| Markdown | `md(spec)` writes a ```` ```rupaka ```` fence; `md(spec, frame=True)` writes a frame that leela draws today |
|
|
99
|
+
| a FastHTML page | `Demo(spec)` and `Assets('/rupaka')`; serve `bundle('js')` and `bundle('css')` at that prefix |
|
|
100
|
+
| a file | `save(spec, 'demo.html')` writes one page that works from `file://` with no network |
|
|
101
|
+
|
|
102
|
+
`check(spec)` draws the demo in headless Chrome and plays it. `author(concept, ask)` asks a model for a demo, and checks and repairs it.
|
|
103
|
+
|
|
104
|
+
## The gallery
|
|
105
|
+
|
|
106
|
+
`rupaka/demos/` holds hand-made demos: vowel sandhi, reciprocal rank fusion, softmax and temperature, nakṣatra and pāda, and a parabola.
|
|
107
|
+
|
|
108
|
+
## Develop
|
|
109
|
+
|
|
110
|
+
The notebooks in `nbs/` are the source of the Python. The JS and CSS are hand-written files under `rupaka/static/`, `rupaka/blocks/` and `rupaka/fns/`.
|
|
111
|
+
|
|
112
|
+
``` sh
|
|
113
|
+
uv sync
|
|
114
|
+
uv run nbdev-prepare
|
|
115
|
+
uv run pytest
|
|
116
|
+
```
|
rupaka-0.0.1/README.md
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# rupaka
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->
|
|
5
|
+
|
|
6
|
+
rupaka (रूपक) means a form, a play that the audience sees, and the figure of speech that shows one thing through another.
|
|
7
|
+
A rupaka demo is one interactive figure that teaches one idea. The learner changes the inputs and sees the result change.
|
|
8
|
+
|
|
9
|
+
A demo never shows the answer first. Each demo follows one loop:
|
|
10
|
+
|
|
11
|
+
1. Predict. The demo shows the inputs and asks one question. The result is hidden.
|
|
12
|
+
2. Reveal. The learner locks in with ⌘↩. The demo shows the result and says if the prediction was right.
|
|
13
|
+
3. Manipulate. Now the controls are live. The result changes when the inputs change.
|
|
14
|
+
4. Explain. The caption ends with a new question that the learner answers with the controls.
|
|
15
|
+
|
|
16
|
+
The validator enforces step 1: a block that shows a value which the answer depends on must wait for the gate.
|
|
17
|
+
|
|
18
|
+
## What a demo is
|
|
19
|
+
|
|
20
|
+
A demo is a JSON spec, not code. It has a small state, derived values from named functions (fns), and a list of blocks.
|
|
21
|
+
A model can write a spec safely, because a spec cannot run code.
|
|
22
|
+
|
|
23
|
+
| part | what it is |
|
|
24
|
+
|----|----|
|
|
25
|
+
| block | a reusable UI part in `rupaka/blocks/<name>/`: its JS, its CSS, a `block.json` manifest and an example |
|
|
26
|
+
| fn | a pure function that computes a derived value: [`rules`](https://vedicreader.github.io/rupaka/spec.html#rules), [`rrf`](https://vedicreader.github.io/rupaka/spec.html#rrf), [`softmax`](https://vedicreader.github.io/rupaka/spec.html#softmax), [`lookup`](https://vedicreader.github.io/rupaka/spec.html#lookup), [`expr`](https://vedicreader.github.io/rupaka/spec.html#expr), `ids`, `pick`, `sort`, [`fmt`](https://vedicreader.github.io/rupaka/spec.html#fmt) |
|
|
27
|
+
| gate | the block that asks for the prediction and hides the result until the lock in |
|
|
28
|
+
| spec | the JSON object: `state`, `derive`, `blocks` and `tables` |
|
|
29
|
+
|
|
30
|
+
The blocks are [`gate`](https://vedicreader.github.io/rupaka/spec.html#gate), [`readout`](https://vedicreader.github.io/rupaka/spec.html#readout), [`caption`](https://vedicreader.github.io/rupaka/spec.html#caption), [`row`](https://vedicreader.github.io/rupaka/spec.html#row), [`stack`](https://vedicreader.github.io/rupaka/spec.html#stack), [`slider`](https://vedicreader.github.io/rupaka/spec.html#slider), [`toggle`](https://vedicreader.github.io/rupaka/spec.html#toggle), [`choice`](https://vedicreader.github.io/rupaka/spec.html#choice), [`wheel`](https://vedicreader.github.io/rupaka/spec.html#wheel), [`ranklist`](https://vedicreader.github.io/rupaka/spec.html#ranklist), [`bars`](https://vedicreader.github.io/rupaka/spec.html#bars), [`axis`](https://vedicreader.github.io/rupaka/spec.html#axis), [`point`](https://vedicreader.github.io/rupaka/spec.html#point), [`plot`](https://vedicreader.github.io/rupaka/spec.html#plot) and [`grid`](https://vedicreader.github.io/rupaka/spec.html#grid).
|
|
31
|
+
|
|
32
|
+
## Install
|
|
33
|
+
|
|
34
|
+
``` sh
|
|
35
|
+
pip install rupaka
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
The headless check needs playwright: `pip install "rupaka[check]"`. It uses the Chromium that `playwright install chromium` gives, or the browser in `$FASTCDP_CHROME`. It never runs your everyday Chrome.
|
|
39
|
+
|
|
40
|
+
## How to use
|
|
41
|
+
|
|
42
|
+
Build a spec with the builders, or write the JSON.
|
|
43
|
+
|
|
44
|
+
``` python
|
|
45
|
+
from rupaka.spec import *
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
``` python
|
|
49
|
+
d = demo('sum', 'A sum', ask='Predict the sum before you see it.', state=dict(a=2, b=3), derive=[expr('a + b', 'sum')],
|
|
50
|
+
blocks=[gate('s', 'What is {a} + {b}?', [4, 5, 6], 'sum', why='Say why, in one line.'),
|
|
51
|
+
readout('{a} + {b} = {sum}', after='s')])
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
[`validate`](https://vedicreader.github.io/rupaka/spec.html#validate) returns the errors. An empty list means the spec is good.
|
|
55
|
+
|
|
56
|
+
``` python
|
|
57
|
+
assert validate(d) == []
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
A readout that shows the sum before the gate breaks the think rule:
|
|
61
|
+
|
|
62
|
+
``` python
|
|
63
|
+
bad = {**d, 'blocks': [d['blocks'][0], readout('{a} + {b} = {sum}')]}
|
|
64
|
+
validate(bad)
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Then put the demo where the learner is:
|
|
68
|
+
|
|
69
|
+
| where | how |
|
|
70
|
+
|----|----|
|
|
71
|
+
| a notebook (leela, Jupyter) | `show(spec)`: an HTML output in a sandboxed frame, and the `application/vnd.rupaka+json` mime |
|
|
72
|
+
| Markdown | `md(spec)` writes a ```` ```rupaka ```` fence; `md(spec, frame=True)` writes a frame that leela draws today |
|
|
73
|
+
| a FastHTML page | `Demo(spec)` and `Assets('/rupaka')`; serve `bundle('js')` and `bundle('css')` at that prefix |
|
|
74
|
+
| a file | `save(spec, 'demo.html')` writes one page that works from `file://` with no network |
|
|
75
|
+
|
|
76
|
+
`check(spec)` draws the demo in headless Chrome and plays it. `author(concept, ask)` asks a model for a demo, and checks and repairs it.
|
|
77
|
+
|
|
78
|
+
## The gallery
|
|
79
|
+
|
|
80
|
+
`rupaka/demos/` holds hand-made demos: vowel sandhi, reciprocal rank fusion, softmax and temperature, nakṣatra and pāda, and a parabola.
|
|
81
|
+
|
|
82
|
+
## Develop
|
|
83
|
+
|
|
84
|
+
The notebooks in `nbs/` are the source of the Python. The JS and CSS are hand-written files under `rupaka/static/`, `rupaka/blocks/` and `rupaka/fns/`.
|
|
85
|
+
|
|
86
|
+
``` sh
|
|
87
|
+
uv sync
|
|
88
|
+
uv run nbdev-prepare
|
|
89
|
+
uv run pytest
|
|
90
|
+
```
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "rupaka"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = "Interactive SVG demos from JSON specs, made of small reusable blocks, that make the learner predict first"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
license-files = ["LICENSE"]
|
|
13
|
+
authors = [{name = "Karthik", email = "karthik.rajgopal@hotmail.com"}]
|
|
14
|
+
keywords = ['nbdev', 'svg', 'interactive', 'teaching', 'demos', 'learning']
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 3 - Alpha",
|
|
17
|
+
"Intended Audience :: Education",
|
|
18
|
+
"Programming Language :: Python :: 3",
|
|
19
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
20
|
+
]
|
|
21
|
+
dependencies = ["fastcore>=1.8"]
|
|
22
|
+
|
|
23
|
+
[project.optional-dependencies]
|
|
24
|
+
check = ["playwright>=1.40"]
|
|
25
|
+
dev = ["ipykernel>=7.3.0", "nbdev>=3.3.26", "notebook>=7.6.3", "pytest>=8", "playwright>=1.40"]
|
|
26
|
+
|
|
27
|
+
[project.urls]
|
|
28
|
+
Repository = "https://github.com/vedicreader/rupaka"
|
|
29
|
+
Documentation = "https://vedicreader.github.io/rupaka/"
|
|
30
|
+
|
|
31
|
+
[project.entry-points.nbdev]
|
|
32
|
+
rupaka = "rupaka._modidx:d"
|
|
33
|
+
|
|
34
|
+
[tool.nbdev]
|
|
35
|
+
tst_flags = "slow"
|
|
36
|
+
|
|
37
|
+
[tool.hatch.build.targets.wheel]
|
|
38
|
+
packages = ["rupaka"]
|
|
39
|
+
|
|
40
|
+
[tool.hatch.build.targets.sdist]
|
|
41
|
+
include = ["/rupaka", "/README.md", "/pyproject.toml"]
|
|
42
|
+
|
|
43
|
+
[tool.hatch.version]
|
|
44
|
+
path = "rupaka/__init__.py"
|
|
45
|
+
|
|
46
|
+
[dependency-groups]
|
|
47
|
+
dev = ["rupaka[dev]"]
|
|
48
|
+
|
|
49
|
+
[tool.pytest.ini_options]
|
|
50
|
+
testpaths = ["tests"]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.0.1"
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# Autogenerated by nbdev
|
|
2
|
+
|
|
3
|
+
d = { 'settings': { 'branch': 'main',
|
|
4
|
+
'doc_baseurl': '/rupaka',
|
|
5
|
+
'doc_host': 'https://vedicreader.github.io',
|
|
6
|
+
'git_url': 'https://github.com/vedicreader/rupaka',
|
|
7
|
+
'lib_path': 'rupaka'},
|
|
8
|
+
'syms': { 'rupaka.agent': { 'rupaka.agent._brief': ('agent.html#_brief', 'rupaka/agent.py'),
|
|
9
|
+
'rupaka.agent._prop': ('agent.html#_prop', 'rupaka/agent.py'),
|
|
10
|
+
'rupaka.agent._slug': ('agent.html#_slug', 'rupaka/agent.py'),
|
|
11
|
+
'rupaka.agent._words': ('agent.html#_words', 'rupaka/agent.py'),
|
|
12
|
+
'rupaka.agent.author': ('agent.html#author', 'rupaka/agent.py'),
|
|
13
|
+
'rupaka.agent.catalog': ('agent.html#catalog', 'rupaka/agent.py'),
|
|
14
|
+
'rupaka.agent.demo_prompt': ('agent.html#demo_prompt', 'rupaka/agent.py'),
|
|
15
|
+
'rupaka.agent.demo_sp': ('agent.html#demo_sp', 'rupaka/agent.py'),
|
|
16
|
+
'rupaka.agent.near': ('agent.html#near', 'rupaka/agent.py'),
|
|
17
|
+
'rupaka.agent.parse_json': ('agent.html#parse_json', 'rupaka/agent.py'),
|
|
18
|
+
'rupaka.agent.repair_prompt': ('agent.html#repair_prompt', 'rupaka/agent.py')},
|
|
19
|
+
'rupaka.check': { 'rupaka.check._boxes': ('check.html#_boxes', 'rupaka/check.py'),
|
|
20
|
+
'rupaka.check._check': ('check.html#_check', 'rupaka/check.py'),
|
|
21
|
+
'rupaka.check._close': ('check.html#_close', 'rupaka/check.py'),
|
|
22
|
+
'rupaka.check._inputs': ('check.html#_inputs', 'rupaka/check.py'),
|
|
23
|
+
'rupaka.check._keys': ('check.html#_keys', 'rupaka/check.py'),
|
|
24
|
+
'rupaka.check._loop_running': ('check.html#_loop_running', 'rupaka/check.py'),
|
|
25
|
+
'rupaka.check._parity': ('check.html#_parity', 'rupaka/check.py'),
|
|
26
|
+
'rupaka.check._play': ('check.html#_play', 'rupaka/check.py'),
|
|
27
|
+
'rupaka.check._shot': ('check.html#_shot', 'rupaka/check.py'),
|
|
28
|
+
'rupaka.check._starts': ('check.html#_starts', 'rupaka/check.py'),
|
|
29
|
+
'rupaka.check._state': ('check.html#_state', 'rupaka/check.py'),
|
|
30
|
+
'rupaka.check.browser': ('check.html#browser', 'rupaka/check.py'),
|
|
31
|
+
'rupaka.check.browser_path': ('check.html#browser_path', 'rupaka/check.py'),
|
|
32
|
+
'rupaka.check.can_check': ('check.html#can_check', 'rupaka/check.py'),
|
|
33
|
+
'rupaka.check.check': ('check.html#check', 'rupaka/check.py'),
|
|
34
|
+
'rupaka.check.contrast': ('check.html#contrast', 'rupaka/check.py'),
|
|
35
|
+
'rupaka.check.in_thread': ('check.html#in_thread', 'rupaka/check.py')},
|
|
36
|
+
'rupaka.render': { 'rupaka.render.Assets': ('render.html#assets', 'rupaka/render.py'),
|
|
37
|
+
'rupaka.render.Demo': ('render.html#demo', 'rupaka/render.py'),
|
|
38
|
+
'rupaka.render.Show': ('render.html#show', 'rupaka/render.py'),
|
|
39
|
+
'rupaka.render.Show.__init__': ('render.html#show.__init__', 'rupaka/render.py'),
|
|
40
|
+
'rupaka.render.Show.__repr__': ('render.html#show.__repr__', 'rupaka/render.py'),
|
|
41
|
+
'rupaka.render.Show._repr_html_': ('render.html#show._repr_html_', 'rupaka/render.py'),
|
|
42
|
+
'rupaka.render.Show._repr_mimebundle_': ('render.html#show._repr_mimebundle_', 'rupaka/render.py'),
|
|
43
|
+
'rupaka.render.assets': ('render.html#assets', 'rupaka/render.py'),
|
|
44
|
+
'rupaka.render.bundle': ('render.html#bundle', 'rupaka/render.py'),
|
|
45
|
+
'rupaka.render.font_css': ('render.html#font_css', 'rupaka/render.py'),
|
|
46
|
+
'rupaka.render.host': ('render.html#host', 'rupaka/render.py'),
|
|
47
|
+
'rupaka.render.md': ('render.html#md', 'rupaka/render.py'),
|
|
48
|
+
'rupaka.render.page': ('render.html#page', 'rupaka/render.py'),
|
|
49
|
+
'rupaka.render.save': ('render.html#save', 'rupaka/render.py'),
|
|
50
|
+
'rupaka.render.show': ('render.html#show', 'rupaka/render.py'),
|
|
51
|
+
'rupaka.render.spec_json': ('render.html#spec_json', 'rupaka/render.py'),
|
|
52
|
+
'rupaka.render.version': ('render.html#version', 'rupaka/render.py')},
|
|
53
|
+
'rupaka.spec': { 'rupaka.spec._all_waits': ('spec.html#_all_waits', 'rupaka/spec.py'),
|
|
54
|
+
'rupaka.spec._ancestors': ('spec.html#_ancestors', 'rupaka/spec.py'),
|
|
55
|
+
'rupaka.spec._b': ('spec.html#_b', 'rupaka/spec.py'),
|
|
56
|
+
'rupaka.spec._check_blocks': ('spec.html#_check_blocks', 'rupaka/spec.py'),
|
|
57
|
+
'rupaka.spec._check_gate': ('spec.html#_check_gate', 'rupaka/spec.py'),
|
|
58
|
+
'rupaka.spec._drop': ('spec.html#_drop', 'rupaka/spec.py'),
|
|
59
|
+
'rupaka.spec._expr': ('spec.html#_expr', 'rupaka/spec.py'),
|
|
60
|
+
'rupaka.spec._gates': ('spec.html#_gates', 'rupaka/spec.py'),
|
|
61
|
+
'rupaka.spec._int32': ('spec.html#_int32', 'rupaka/spec.py'),
|
|
62
|
+
'rupaka.spec._jsround': ('spec.html#_jsround', 'rupaka/spec.py'),
|
|
63
|
+
'rupaka.spec._lex': ('spec.html#_lex', 'rupaka/spec.py'),
|
|
64
|
+
'rupaka.spec._lookup': ('spec.html#_lookup', 'rupaka/spec.py'),
|
|
65
|
+
'rupaka.spec._num': ('spec.html#_num', 'rupaka/spec.py'),
|
|
66
|
+
'rupaka.spec._props': ('spec.html#_props', 'rupaka/spec.py'),
|
|
67
|
+
'rupaka.spec._reads': ('spec.html#_reads', 'rupaka/spec.py'),
|
|
68
|
+
'rupaka.spec._root': ('spec.html#_root', 'rupaka/spec.py'),
|
|
69
|
+
'rupaka.spec._rrf': ('spec.html#_rrf', 'rupaka/spec.py'),
|
|
70
|
+
'rupaka.spec._rules': ('spec.html#_rules', 'rupaka/spec.py'),
|
|
71
|
+
'rupaka.spec._safe': ('spec.html#_safe', 'rupaka/spec.py'),
|
|
72
|
+
'rupaka.spec._softmax': ('spec.html#_softmax', 'rupaka/spec.py'),
|
|
73
|
+
'rupaka.spec._sortby': ('spec.html#_sortby', 'rupaka/spec.py'),
|
|
74
|
+
'rupaka.spec._taint': ('spec.html#_taint', 'rupaka/spec.py'),
|
|
75
|
+
'rupaka.spec._type_err': ('spec.html#_type_err', 'rupaka/spec.py'),
|
|
76
|
+
'rupaka.spec._utf16': ('spec.html#_utf16', 'rupaka/spec.py'),
|
|
77
|
+
'rupaka.spec._waits': ('spec.html#_waits', 'rupaka/spec.py'),
|
|
78
|
+
'rupaka.spec._walk': ('spec.html#_walk', 'rupaka/spec.py'),
|
|
79
|
+
'rupaka.spec.axis': ('spec.html#axis', 'rupaka/spec.py'),
|
|
80
|
+
'rupaka.spec.bars': ('spec.html#bars', 'rupaka/spec.py'),
|
|
81
|
+
'rupaka.spec.caption': ('spec.html#caption', 'rupaka/spec.py'),
|
|
82
|
+
'rupaka.spec.choice': ('spec.html#choice', 'rupaka/spec.py'),
|
|
83
|
+
'rupaka.spec.demo': ('spec.html#demo', 'rupaka/spec.py'),
|
|
84
|
+
'rupaka.spec.examples': ('spec.html#examples', 'rupaka/spec.py'),
|
|
85
|
+
'rupaka.spec.expr': ('spec.html#expr', 'rupaka/spec.py'),
|
|
86
|
+
'rupaka.spec.fmt': ('spec.html#fmt', 'rupaka/spec.py'),
|
|
87
|
+
'rupaka.spec.fmt_text': ('spec.html#fmt_text', 'rupaka/spec.py'),
|
|
88
|
+
'rupaka.spec.fn_manifests': ('spec.html#fn_manifests', 'rupaka/spec.py'),
|
|
89
|
+
'rupaka.spec.from_': ('spec.html#from_', 'rupaka/spec.py'),
|
|
90
|
+
'rupaka.spec.gallery': ('spec.html#gallery', 'rupaka/spec.py'),
|
|
91
|
+
'rupaka.spec.gate': ('spec.html#gate', 'rupaka/spec.py'),
|
|
92
|
+
'rupaka.spec.get': ('spec.html#get', 'rupaka/spec.py'),
|
|
93
|
+
'rupaka.spec.grid': ('spec.html#grid', 'rupaka/spec.py'),
|
|
94
|
+
'rupaka.spec.is_': ('spec.html#is_', 'rupaka/spec.py'),
|
|
95
|
+
'rupaka.spec.js_str': ('spec.html#js_str', 'rupaka/spec.py'),
|
|
96
|
+
'rupaka.spec.long_sentences': ('spec.html#long_sentences', 'rupaka/spec.py'),
|
|
97
|
+
'rupaka.spec.lookup': ('spec.html#lookup', 'rupaka/spec.py'),
|
|
98
|
+
'rupaka.spec.manifests': ('spec.html#manifests', 'rupaka/spec.py'),
|
|
99
|
+
'rupaka.spec.parse_expr': ('spec.html#parse_expr', 'rupaka/spec.py'),
|
|
100
|
+
'rupaka.spec.plot': ('spec.html#plot', 'rupaka/spec.py'),
|
|
101
|
+
'rupaka.spec.point': ('spec.html#point', 'rupaka/spec.py'),
|
|
102
|
+
'rupaka.spec.ranklist': ('spec.html#ranklist', 'rupaka/spec.py'),
|
|
103
|
+
'rupaka.spec.readout': ('spec.html#readout', 'rupaka/spec.py'),
|
|
104
|
+
'rupaka.spec.row': ('spec.html#row', 'rupaka/spec.py'),
|
|
105
|
+
'rupaka.spec.rrf': ('spec.html#rrf', 'rupaka/spec.py'),
|
|
106
|
+
'rupaka.spec.rules': ('spec.html#rules', 'rupaka/spec.py'),
|
|
107
|
+
'rupaka.spec.run': ('spec.html#run', 'rupaka/spec.py'),
|
|
108
|
+
'rupaka.spec.show_value': ('spec.html#show_value', 'rupaka/spec.py'),
|
|
109
|
+
'rupaka.spec.slider': ('spec.html#slider', 'rupaka/spec.py'),
|
|
110
|
+
'rupaka.spec.softmax': ('spec.html#softmax', 'rupaka/spec.py'),
|
|
111
|
+
'rupaka.spec.stack': ('spec.html#stack', 'rupaka/spec.py'),
|
|
112
|
+
'rupaka.spec.toggle': ('spec.html#toggle', 'rupaka/spec.py'),
|
|
113
|
+
'rupaka.spec.upgrade': ('spec.html#upgrade', 'rupaka/spec.py'),
|
|
114
|
+
'rupaka.spec.validate': ('spec.html#validate', 'rupaka/spec.py'),
|
|
115
|
+
'rupaka.spec.wheel': ('spec.html#wheel', 'rupaka/spec.py')}}}
|