Skip to content

Commit 1d8c045

Browse files
mcioffistrangetom
andauthored
Redesign for webtools — move to vite/react/ts (#25)
* Drop flask front-end * First batch of vite/react/ts front-end with flask server * Updates for docs and readability * Cleanup * Update assets + readme * Refactoring webtools + integrating flask-socketio * Bump readme * Bump * dev reqs & concurrent pids bash in npm * Change handling of edit mode from modal to inline * cleanup * Labeller help hover * Missed doc notes * Train model tab updates - Cleaned up flask code - Removed train tab interrupt button (limitations) - Added package requirements precheck on app startup - Added time elapsed on training screen * Accidental none check against thread, preventing re-runs * Asset screenshot * Move time tracker on trainer to zustrand state "Time elapsed" tracking needs to live within managed state, and not ui state, due to the training being asynchronous and user can use the app while the model is training in the background * Bump * Add seed input to training * Add seed input to training (server) * Sets up cache reset on model loader Addresses one of the comments by @strangetom on #25 (comment) regarding cache resetting by the @ lru_cache decorator on the model loading. This ensures completed training cycles done via the web app (which impacts the parser) updates the parser optimistically to handle the cache resetting * Bump up third-party package versions against vite and mantine * WIP - add gridsearch options, revert to logger.info, and refine console output from websockets 1. Work-in-progress new feature for gridsearch 2. Rever to logger.info for websocket output, to be aligned with develop branch 4. Refine the console output, should have originally used <pre> tags to persist reserved str \n, \t, etc Note: This commit refers to a function set_redirect_log_stream, that will be introduced in #35, since it is required to set a logging stream handle correctly to pipe results to websockets * Screenshots * Remove remnants * Cleanup, readability, etc * Remove interrupt and keepModels based on maintainer feedback * Pre-commit format fixes, part I * Pre-commit fixes, part II (adds biomejs for webtools linter/formatter/etc) Tacks on to the existing pre-commit hooks in the repo with BiomeJS. BiomeJS is specifically for the web side (typescript/js/css). Local configuration modeled after preconfigs at https://github.com/biomejs/pre-commit. Commit includes all file format fixes necessary. Anticipated that config will be modified as necessary if new web contributors participate in future commits. * Restore training.sqlite3 to previous commit Accidentally included new training.sqlite3 in e01430b * Address bug feedback, round I - [x] Parser: The amount flags are not shown in the results table - [x] Parser: order labels in token tooltip as per old webapp - [x] Parser: Reorder rows in result table as per old webapp - [x] General: Can we avoid use of google fonts? Everything else (after running npm install) is entirely local. - [x] Parser: show % sign in tooltips for scores for each label - [x] Trainer: Output include debug info app.sockets, which isn't relevant to training. - [x] Trainer: html and tsv files saved in webtools directory instead of parent - [x] General: on the parser and labeller pages, the contrast between text and colours is a bit low (particularly for anything on a red background). This is probably best fixed by increasing the font size on those pages, since it's a little small anyway. - [x] Trainer: default model location incorrect (this was changed recently, is should be in ingredient_parser/en/data/) - [x] Trainer: split value does not allow more than one decimal place. There shouldn't really be any limit of the number of decimal places (but in practice, 3 might be a more reasonable limit than 1). - [x] Trainer: saveur dataset is selected by default, but doesn't exist. - [x] Parser: Missing separate_names option * Address bugs feedback, round II - [x] Trainer: Inputs for seed, split do not focus on click so cannot edit without tabbing to the inputs or finding another way to focus them. This might be a wider problem than just those. - [x] Trainer: unable to start another training run after completing a previous one if confusion matrix is generated by the first run. There's a RuntimeError related to Tk. * Address bugs feedback, round III - [x] Labeller: Unable to search unicode fractions - [x] Labeller: Unable to quickly select a label for a token using first letter (as per <select> element) - [x] Labeller: Bug when searching (coarse, dried returns no results but should return sentence id 4718) * Address bugs feedback, round IV - [x] Trainer: The split value seems to be capped at 0.9. That should probably changed 0.999 - [x] Labeller: There's a weird bug when changing the label for a token - an addition PUNC token gets inserted. This seems to effect any sentence containing a comma when you change the label of the first token. * Address bugs feedback, round V - [x] Labeller: Is it possible to be able to tab between tokens in a sentence to change to the next one? * Address bugs feedback, round VI - [x] Trainer: Gridsearch incomplete --------- Co-authored-by: tom <tpstrange@gmail.com>
1 parent 23b6e52 commit 1d8c045

File tree

272 files changed

+14384
-1942
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

272 files changed

+14384
-1942
lines changed

.pre-commit-config.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,52 @@ repos:
55
rev: v5.0.0
66
hooks:
77
- id: check-added-large-files
8+
name: (base:repo) debug-statements
89
args: ['--maxkb=5000']
910
stages: [pre-commit]
1011
- id: check-ast
12+
name: (base:repo) check-ast
1113
stages: [pre-commit]
1214
- id: check-toml
15+
name: (base:repo) check-toml
1316
stages: [pre-commit]
1417
- id: check-yaml
18+
name: (base:repo) check-yaml
1519
stages: [pre-commit]
1620
- id: debug-statements
21+
name: (base:repo) debug-statements
1722
stages: [pre-commit]
1823
- repo: https://github.com/astral-sh/ruff-pre-commit
1924
rev: v0.11.6
2025
hooks:
2126
- id: ruff
27+
name: (base:repo) ruff
2228
args: ["--fix"]
2329
stages: [pre-commit]
2430
- id: ruff-format
31+
name: (base:repo) ruff-format
2532
stages: [pre-commit]
2633
- repo: https://github.com/sphinx-contrib/sphinx-lint
2734
rev: v1.0.0
2835
hooks:
2936
- id: sphinx-lint
37+
name: (docs:repo) sphinx-lint
3038
stages: [pre-commit]
39+
- repo: local
40+
hooks:
41+
- id: biome-check-ts-js
42+
name: (webtools:repo) biome check typescript/javascript
43+
entry: npx @biomejs/biome check --write ./webtools/src --config-path=./webtools/biome.json --files-ignore-unknown=true --no-errors-on-unmatched
44+
language: node
45+
types: [text]
46+
files: "\\.(jsx?|tsx?|c(js|ts)|m(js|ts)|d\\.(ts|cts|mts)|jsonc?)$"
47+
exclude: ^docs/
48+
require_serial: true
49+
- id: biome-check-css
50+
name: (webtools:repo) biome check css
51+
entry: npx @biomejs/biome check --write ./webtools/src --config-path=./webtools/biome.json --files-ignore-unknown=true --no-errors-on-unmatched
52+
language: node
53+
types: [text]
54+
files: "\\.(css?)$"
55+
exclude: ^docs/
56+
require_serial: true

README.md

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ Word-level results:
5959

6060
## Development
6161

62-
The development dependencies are in the ```requirements-dev.txt``` file. Details on the training process can be found in the [Model Guide](https://ingredient-parser.readthedocs.io/en/latest/guide/index.html) documentation.
62+
**Basic**
63+
64+
The development dependencies are in the `requirements-dev.txt` file. Details on the training process can be found in the [Model Guide](https://ingredient-parser.readthedocs.io/en/latest/guide/index.html) documentation.
6365

6466
Before committing anything, install [pre-commit](https://pre-commit.com/) and run
6567
```
@@ -68,16 +70,34 @@ pre-commit install
6870

6971
to install the pre-commit hooks.
7072

71-
Please target the **develop** branch for pull requests. The main branch is used for stable releases and hotfixes only.
73+
**Web app**
7274

73-
There is a simple web app for testing the parser with ingredient sentences and showing the parsed output. To run the web app, run the command
75+
There is a simple web app for testing the parser, browsing the database, labelling entries, and running the basic model.
76+
77+
To run the web app, follow the prior steps on `requirements-dev.txt`, and separately install [Node](https://nodejs.org/en/download), the JS runtime. Once globally installed on your machine, download your packages in the webtools directory with:
78+
79+
```bash
80+
$ npm install
81+
```
82+
83+
After package installs, run dev to start.
7484

7585
```bash
76-
$ flask --app webapp run
86+
$ npm run dev
7787
```
7888

79-
![Screen shot of web app](docs/source/_static/app-screenshot.png)
89+
*tl;dr — inside package.json, `flask` runs the base server, `sockets` runs the web sockets server, and `watch` runs vite build for the react/typescripe bundle — separate flask instances are required to accommodate better web socket behavior*
90+
91+
![Screen shot of web parser](docs/source/_static/app.parser.screenshot.png)
92+
![Screen shot of web labeller](docs/source/_static/app.labeller.screenshot.png)
93+
![Screen shot of web trainer](docs/source/_static/app.trainer.screenshot.png)
94+
95+
**Documentation**
96+
97+
The dependencies for building the documentation are in the `requirements-doc.txt` file.
8098

81-
This requires the development dependencies to be installed.
99+
**Contribution**
82100

83-
The dependencies for building the documentation are in the ```requirements-doc.txt``` file.
101+
Please target the **develop** branch for pull requests. The main branch is used for stable releases and hotfixes only.
102+
103+
There is a simple web app for testing the parser with ingredient sentences and showing the parsed output. To run the web app, run the command
84.2 KB
Loading
63.1 KB
Loading
91.2 KB
Loading

docs/source/_static/logo_source.svg

Lines changed: 1 addition & 279 deletions
Loading

docs/source/how-to/extending.rst

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,16 +128,15 @@ Depending on the language, you may need a language specific :func:`tokenize <ing
128128

129129
.. tip::
130130

131-
A web app has been developed to aid in the adding and labelling of training sentences. Run the command
131+
A web app has been developed to aid in the adding and labelling of training sentences. If intending to add another language, you will need to adjust some of the web app code. Regardless, you can run these commands under the webtools directory to install the packages and run the web app.
132132

133133
.. code:: bash
134134
135-
$ flask --app labeller run
135+
$ npm install
136+
$ npm run dev
136137
137138
Then navigate to http://localhost:5000 in your browser.
138139

139-
You may need to tweak this to work with the correct database.
140-
141140
1. Normalise
142141
~~~~~~~~~~~~
143142

0 commit comments

Comments
 (0)