Commit eb9c205
Fix threads in offline deployment (#333)
* feat: add configurable max threads for local and online deployments
- Add max_threads configuration to settings.json with separate values
for local (4) and online (2) deployments
- Add get_max_threads() helper function in common.py that returns
appropriate thread count based on deployment mode
- Add Threads number input in parameter_section for local mode UI
- Update CommandExecutor.run_multiple_commands() to use semaphore
limiting based on max_threads setting
- Update CommandExecutor.run_topp() to pass -threads parameter to
TOPP tools with intelligently distributed thread allocation
Thread distribution algorithm:
- parallel_commands = min(num_files, max_threads)
- threads_per_command = max(1, max_threads // parallel_commands)
This ensures optimal resource usage: with 4 max_threads and 2 files,
runs 2 parallel commands with 2 threads each; with 4 files, runs 4
parallel commands with 1 thread each.
https://claude.ai/code/session_01XGuw7AxoKRWHr9EZX1SDXi
* fix: properly initialize session state for Threads number input
Pre-initialize max_threads_override in session state before rendering
the widget, and remove the value parameter to let Streamlit read from
session state. This ensures user changes are properly tracked.
https://claude.ai/code/session_01XGuw7AxoKRWHr9EZX1SDXi
* fix: persist Threads parameter across page navigation
Use input_widget() which integrates with the parameter manager to
persist the value to params.json. Also copy value to session state
for get_max_threads() to access.
https://claude.ai/code/session_01XGuw7AxoKRWHr9EZX1SDXi
* refactor: use parameter manager directly in get_max_threads()
- Pass parameter_manager to get_max_threads() to read persisted value
- Remove session state copying workaround in StreamlitUI
- Cleaner design that reads directly from params.json
https://claude.ai/code/session_01XGuw7AxoKRWHr9EZX1SDXi
* refactor: move _get_max_threads() to CommandExecutor
- Move function from common.py to CommandExecutor as private method
- Simplifies code by using self.parameter_manager directly
- Remove unnecessary import and parameter passing
https://claude.ai/code/session_01XGuw7AxoKRWHr9EZX1SDXi
* fix: validate _get_max_threads() return value
Coerce to int and clamp to minimum of 1 to prevent:
- Semaphore(0) deadlocks
- Divide-by-zero in threads_per_command calculation
- Issues from non-numeric config values
https://claude.ai/code/session_01XGuw7AxoKRWHr9EZX1SDXi
* style: move streamlit import to top of file
https://claude.ai/code/session_01XGuw7AxoKRWHr9EZX1SDXi
* feat: log warning for invalid max_threads values
Logs to minimal log (level 0) when max_threads is non-numeric or < 1.
https://claude.ai/code/session_01XGuw7AxoKRWHr9EZX1SDXi
* simplify: remove warning logging from _get_max_threads()
UI already enforces min_value=1, keep just the validation.
https://claude.ai/code/session_01XGuw7AxoKRWHr9EZX1SDXi
* simplify: remove exception handling, fail loud on invalid config
https://claude.ai/code/session_01XGuw7AxoKRWHr9EZX1SDXi
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 0820681 commit eb9c205
File tree
3 files changed
+30
-32
lines changed- src
- common
- workflow
3 files changed
+30
-32
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | 35 | | |
59 | 36 | | |
60 | 37 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
28 | 51 | | |
29 | 52 | | |
30 | 53 | | |
| |||
43 | 66 | | |
44 | 67 | | |
45 | 68 | | |
46 | | - | |
47 | | - | |
48 | 69 | | |
49 | | - | |
| 70 | + | |
50 | 71 | | |
51 | 72 | | |
52 | 73 | | |
| |||
234 | 255 | | |
235 | 256 | | |
236 | 257 | | |
237 | | - | |
238 | | - | |
| 258 | + | |
239 | 259 | | |
240 | 260 | | |
241 | 261 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1112 | 1112 | | |
1113 | 1113 | | |
1114 | 1114 | | |
1115 | | - | |
1116 | | - | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
1117 | 1120 | | |
1118 | | - | |
1119 | | - | |
1120 | 1121 | | |
1121 | 1122 | | |
1122 | 1123 | | |
| |||
0 commit comments