mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-11-03 16:02:04 +00:00
Bugfix/cli max rows (#6374)
* fix: cli max rows * fix: settings menu --------- Co-authored-by: Henrique Joaquim <henriquecjoaquim@gmail.com>
This commit is contained in:
4
cli/openbb_cli/assets/i18n/en.yml
vendored
4
cli/openbb_cli/assets/i18n/en.yml
vendored
@@ -10,8 +10,8 @@ en:
|
||||
exe: execute .openbb routine scripts (use exe --example for an example)
|
||||
_configure_: Configure your own CLI
|
||||
_main_menu_: Main menu
|
||||
settings/_info_: Feature flags
|
||||
settings/_settings_: Settings and preferences
|
||||
settings/_feature_flags_: Feature flags
|
||||
settings/_preferences_: Preferences
|
||||
settings/retryload: retry misspelled commands with load first
|
||||
settings/interactive: open dataframes in interactive window
|
||||
settings/cls: clear console after each command
|
||||
|
||||
@@ -65,7 +65,7 @@ AVAILABLE_FLAIRS = {
|
||||
":mercury": "(☿)",
|
||||
":hidden": "",
|
||||
":sun": "(☼)",
|
||||
":moon": "(☾)",
|
||||
":moon": "(🌕)",
|
||||
":nuke": "(☢)",
|
||||
":hazard": "(☣)",
|
||||
":tunder": "(☈)",
|
||||
@@ -76,6 +76,6 @@ AVAILABLE_FLAIRS = {
|
||||
":scales": "(⚖)",
|
||||
":ball": "(⚽)",
|
||||
":golf": "(⛳)",
|
||||
":piece": "(☮)",
|
||||
":peace": "(☮)",
|
||||
":yy": "(☯)",
|
||||
}
|
||||
|
||||
@@ -317,7 +317,7 @@ class CLIController(BaseController):
|
||||
return parse_and_split_input(an_input=an_input, custom_filters=custom_filters)
|
||||
|
||||
def call_settings(self, _):
|
||||
"""Process feature flags command."""
|
||||
"""Process settings command."""
|
||||
from openbb_cli.controllers.settings_controller import (
|
||||
SettingsController,
|
||||
)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
"""Feature Flags Controller Module."""
|
||||
"""Settings Controller Module."""
|
||||
|
||||
import argparse
|
||||
from typing import List, Optional
|
||||
@@ -16,7 +16,7 @@ session = Session()
|
||||
|
||||
|
||||
class SettingsController(BaseController):
|
||||
"""Feature Flags Controller class."""
|
||||
"""Settings Controller class."""
|
||||
|
||||
CHOICES_COMMANDS: List[str] = [
|
||||
"retryload",
|
||||
@@ -56,7 +56,7 @@ class SettingsController(BaseController):
|
||||
settings = session.settings
|
||||
|
||||
mt = MenuText("settings/")
|
||||
mt.add_info("_info_")
|
||||
mt.add_info("_feature_flags_")
|
||||
mt.add_setting("interactive", settings.USE_INTERACTIVE_DF)
|
||||
mt.add_setting("cls", settings.USE_CLEAR_AFTER_CMD)
|
||||
mt.add_setting("promptkit", settings.USE_PROMPT_TOOLKIT)
|
||||
@@ -68,7 +68,7 @@ class SettingsController(BaseController):
|
||||
mt.add_setting("version", settings.SHOW_VERSION)
|
||||
mt.add_setting("obbject_msg", settings.SHOW_MSG_OBBJECT_REGISTRY)
|
||||
mt.add_raw("\n")
|
||||
mt.add_info("_settings_")
|
||||
mt.add_info("_preferences_")
|
||||
mt.add_cmd("console_style")
|
||||
mt.add_cmd("flair")
|
||||
mt.add_cmd("timezone")
|
||||
@@ -77,7 +77,7 @@ class SettingsController(BaseController):
|
||||
mt.add_cmd("n_cols")
|
||||
mt.add_cmd("obbject_res")
|
||||
|
||||
session.console.print(text=mt.menu_text, menu="Feature Flags")
|
||||
session.console.print(text=mt.menu_text, menu="Settings")
|
||||
|
||||
def call_overwrite(self, _):
|
||||
"""Process overwrite command."""
|
||||
|
||||
@@ -454,6 +454,9 @@ def print_rich_table( # noqa: PLR0912
|
||||
if export:
|
||||
return
|
||||
|
||||
MAX_COLS = Session().settings.ALLOWED_NUMBER_OF_COLUMNS
|
||||
MAX_ROWS = Session().settings.ALLOWED_NUMBER_OF_ROWS
|
||||
|
||||
# Make a copy of the dataframe to avoid SettingWithCopyWarning
|
||||
df = df.copy()
|
||||
|
||||
@@ -525,16 +528,12 @@ def print_rich_table( # noqa: PLR0912
|
||||
if columns_to_auto_color is None and rows_to_auto_color is None:
|
||||
df = df.applymap(lambda x: return_colored_value(str(x)))
|
||||
|
||||
exceeds_allowed_columns = (
|
||||
len(df.columns) > Session().settings.ALLOWED_NUMBER_OF_COLUMNS
|
||||
)
|
||||
exceeds_allowed_rows = len(df) > Session().settings.ALLOWED_NUMBER_OF_ROWS
|
||||
exceeds_allowed_columns = len(df.columns) > MAX_COLS
|
||||
exceeds_allowed_rows = len(df) > MAX_ROWS
|
||||
|
||||
if exceeds_allowed_columns:
|
||||
original_columns = df.columns.tolist()
|
||||
trimmed_columns = df.columns.tolist()[
|
||||
: Session().settings.ALLOWED_NUMBER_OF_COLUMNS
|
||||
]
|
||||
trimmed_columns = df.columns.tolist()[:MAX_COLS]
|
||||
df = df[trimmed_columns]
|
||||
trimmed_columns = [
|
||||
col for col in original_columns if col not in trimmed_columns
|
||||
@@ -542,9 +541,9 @@ def print_rich_table( # noqa: PLR0912
|
||||
|
||||
if exceeds_allowed_rows:
|
||||
n_rows = len(df.index)
|
||||
trimmed_rows = df.index.tolist()[: Session().settings.ALLOWED_NUMBER_OF_ROWS]
|
||||
df = df.loc[trimmed_rows]
|
||||
trimmed_rows_count = n_rows - Session().settings.ALLOWED_NUMBER_OF_ROWS
|
||||
max_rows = MAX_ROWS
|
||||
df = df[:max_rows]
|
||||
trimmed_rows_count = n_rows - max_rows
|
||||
|
||||
if use_tabulate_df:
|
||||
table = Table(title=title, show_lines=True, show_header=show_header)
|
||||
|
||||
Reference in New Issue
Block a user