-
-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #143 from hummingbot/feat/enhance_controllers_conf…
…ig_management Feat/enhance controllers config management
- Loading branch information
Showing
25 changed files
with
547 additions
and
297 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,32 @@ | ||
import streamlit as st | ||
from CONFIG import BACKEND_API_HOST, BACKEND_API_PORT | ||
|
||
from backend.services.backend_api_client import BackendAPIClient | ||
from frontend.st_utils import get_backend_api_client | ||
from frontend.utils import generate_random_name | ||
|
||
backend_api_client = BackendAPIClient.get_instance(host=BACKEND_API_HOST, port=BACKEND_API_PORT) | ||
backend_api_client = get_backend_api_client() | ||
|
||
|
||
def get_default_config_loader(controller_name: str): | ||
use_default_config = st.checkbox("Use default config", value=True) | ||
all_configs = backend_api_client.get_all_controllers_config() | ||
if use_default_config: | ||
st.session_state["default_config"] = {} | ||
else: | ||
configs = [config for config in all_configs if config["controller_name"] == controller_name] | ||
default_config = st.selectbox("Select a config", [config["id"] for config in configs]) | ||
st.session_state["default_config"] = next((config for config in all_configs if config["id"] == default_config), {}) | ||
existing_configs = [config["id"].split("_")[0] for config in all_configs] | ||
default_dict = {"id": generate_random_name(existing_configs)} | ||
default_config = st.session_state.get("default_config") | ||
config_controller_name = st.session_state.get("controller_name", controller_name) | ||
st.write(f"controller_name: {controller_name} | config_controller_name: {config_controller_name}") | ||
if default_config is None or controller_name != config_controller_name: | ||
st.session_state["default_config"] = default_dict | ||
with st.expander("Configurations", expanded=True): | ||
c1, c2 = st.columns(2) | ||
with c1: | ||
use_default_config = st.checkbox("Use default config", value=True) | ||
with c2: | ||
if not use_default_config: | ||
configs = [config for config in all_configs if config["controller_name"] == controller_name] | ||
if len(configs) > 0: | ||
default_config = st.selectbox("Select a config", [config["id"] for config in configs]) | ||
st.session_state["default_config"] = next((config for config in all_configs if config["id"] == default_config), None) | ||
st.session_state["default_config"]["id"] = st.session_state["default_config"]["id"].split("_")[0] | ||
else: | ||
st.warning("No existing configs found for this controller.") | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.