Commit 2c151d0
Dashboard: restructure/refactor toolbar code (BLAST-ImpactX#981)
* add: functionality to parse variables from input file
Only allowing int,float values at the moment. So no lists, or math expressions
* update: update delete available after loading variables
otherwise the delete button stays disabled to the user
* add: variable to reset button
Not implemented in a very robust way right now
* fix: prevent crash
For example, say lattice element #1 references a variable called 'ns'. If the lattice list is reset or elements are deleted, the variable update handler would still try to access index 1, causing an IndexError. This patch adds a guard to skip updates if the referenced lattice element index is no longer valid.
* update: parser to only load in variables which are used in the lattice configuration
* empty the variables list before loading in variables
* update: allow negative inputs with variables
* add float wrapper
* update: on_variable_change
modify docstring and set variable value to None if empty
* simplify 'process_if_variable'
* variable renames and move code block
* shorted helper function name
* add docstring to state.change('variables')
* correctly update lattice elements on variable change after element deletion
Prevents cases similar to the following: Say you add three lattice elements, the first two reference a variable named ns, the third one references a variable named ns2 in the same parameter name. If we end up deleting the second lattice element, and update the value of the ns variable, the ns2 originally from index 2 becomes ns
* add parse_variables docstring
and update var name
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* fix docstring
* move input toolbar to separate file
also need to move toolbarimport class to remove circular dependency
* move parser to separate folder
new folder name is 'dashboard_parser'
importParser renamed to parser.py
importParserHelper renamed to parser_helper.py
* move logic to ui_populator.py
* rename
* move RunToolbar to separate file
* move AnalyzeToolbar to separate file
* introduce general_toolbar.py
contain toolbar components utilized in all the routes
* strip '_toolbar' from file name
fix resulting circular import
* simplify ui_populator
break into sub functions
* update class docstring
* update docstrings
* break out populate_variables logic
* add inline comments
* relocate some code
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>1 parent 350aa81 commit 2c151d0
File tree
17 files changed
+602
-513
lines changed- src/python/impactx/dashboard
- Input
- distribution
- Run
- Toolbar
- file_imports
- python
- sim_history
17 files changed
+602
-513
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | 83 | | |
87 | 84 | | |
88 | 85 | | |
| |||
99 | 96 | | |
100 | 97 | | |
101 | 98 | | |
102 | | - | |
103 | | - | |
104 | 99 | | |
105 | 100 | | |
106 | 101 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
101 | 102 | | |
102 | 103 | | |
103 | 104 | | |
| 105 | + | |
104 | 106 | | |
105 | 107 | | |
106 | 108 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | | - | |
| 53 | + | |
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
71 | | - | |
| 71 | + | |
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
85 | | - | |
| 85 | + | |
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
0 commit comments