Skip to content

Commit 5a9a870

Browse files
committed
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
1 parent e653f77 commit 5a9a870

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

src/common/common.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,15 @@
3232
OS_PLATFORM = sys.platform
3333

3434

35-
def get_max_threads() -> int:
35+
def get_max_threads(parameter_manager=None) -> int:
3636
"""
3737
Get max threads for current deployment mode.
3838
39-
In local mode, checks for UI override in session state.
40-
In online mode, uses the configured value directly.
39+
In local mode, reads from parameter manager (persisted params.json).
40+
In online mode, uses the configured value directly from settings.
41+
42+
Args:
43+
parameter_manager: Optional ParameterManager instance for reading persisted params.
4144
4245
Returns:
4346
int: Maximum number of threads to use for parallel processing.
@@ -48,11 +51,12 @@ def get_max_threads() -> int:
4851
if settings.get("online_deployment", False):
4952
return max_threads_config.get("online", 2)
5053
else:
51-
# Local mode: check for UI override, fallback to config default
52-
return st.session_state.get(
53-
"max_threads_override",
54-
max_threads_config.get("local", 4)
55-
)
54+
# Local mode: read from parameter manager if available
55+
default = max_threads_config.get("local", 4)
56+
if parameter_manager is not None:
57+
params = parameter_manager.get_parameters_from_json()
58+
return params.get("max_threads", default)
59+
return default
5660

5761

5862
def is_safe_workspace_name(name: str) -> bool:

src/workflow/CommandExecutor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def run_multiple_commands(
4646
from src.common.common import get_max_threads
4747

4848
# Get thread settings and calculate distribution
49-
max_threads = get_max_threads()
49+
max_threads = get_max_threads(self.parameter_manager)
5050
num_commands = len(commands)
5151
parallel_commands = min(num_commands, max_threads)
5252

@@ -235,7 +235,7 @@ def run_topp(self, tool: str, input_output: dict, custom_params: dict = {}) -> b
235235

236236
# Calculate threads per command based on max_threads setting
237237
from src.common.common import get_max_threads
238-
max_threads = get_max_threads()
238+
max_threads = get_max_threads(self.parameter_manager)
239239
parallel_commands = min(n_processes, max_threads)
240240
threads_per_command = max(1, max_threads // parallel_commands)
241241

src/workflow/StreamlitUI.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,10 +1120,6 @@ def parameter_section(self, custom_parameter_function) -> None:
11201120
min_value=1,
11211121
help="Maximum threads for parallel processing. Threads are distributed between parallel commands and per-tool thread allocation."
11221122
)
1123-
# Copy to session state for get_max_threads() to access
1124-
prefixed_key = f"{self.parameter_manager.param_prefix}max_threads"
1125-
if prefixed_key in st.session_state:
1126-
st.session_state.max_threads_override = st.session_state[prefixed_key]
11271123

11281124
# Display preset buttons if presets are available for this workflow
11291125
self.preset_buttons()

0 commit comments

Comments
 (0)