summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrique Joaquim <henriquecjoaquim@gmail.com>2024-05-13 10:21:41 +0100
committerGitHub <noreply@github.com>2024-05-13 09:21:41 +0000
commit6f9d46d5f90d075578f8165082a50d399a935cfe (patch)
tree5224c20b91059fd07a93d5049edc698622b262ae
parentb99655a9733599c45588a3c6fd4d0c436a8ca3b2 (diff)
remove hold command and its references (#6399)
* remove hold command and its references * remove --local flag as we don't use it anymore @IgorWounds * reset package folder * reset reference * unnecessary line break removed
-rw-r--r--cli/openbb_cli/config/setup.py62
-rw-r--r--cli/openbb_cli/controllers/base_controller.py124
-rw-r--r--cli/openbb_cli/controllers/cli_controller.py6
3 files changed, 1 insertions, 191 deletions
diff --git a/cli/openbb_cli/config/setup.py b/cli/openbb_cli/config/setup.py
index 4d3eece690b..4e682a535e8 100644
--- a/cli/openbb_cli/config/setup.py
+++ b/cli/openbb_cli/config/setup.py
@@ -1,71 +1,9 @@
"""Configuration for the CLI."""
-import copy
from pathlib import Path
-from typing import TYPE_CHECKING, List, Optional, TypeVar
from openbb_cli.config.constants import ENV_FILE_SETTINGS, SETTINGS_DIRECTORY
-if TYPE_CHECKING:
- from openbb_charting.core.openbb_figure import OpenBBFigure
-
-# ruff: noqa:PLW0603
-
-OpenBBFigureT = TypeVar("OpenBBFigureT", bound="OpenBBFigure")
-HOLD: bool = False
-COMMAND_ON_CHART: bool = True
-current_figure: Optional[OpenBBFigureT] = None # type: ignore
-new_axis: bool = True
-legends: List = []
-last_legend = ""
-
-
-# pylint: disable=global-statement
-def set_last_legend(leg: str):
- """Set the last legend."""
- global last_legend
- last_legend = copy.deepcopy(leg)
-
-
-def reset_legend() -> None:
- """Reset the legend."""
- global legends
- legends = []
-
-
-def get_legends() -> list:
- """Get the legends."""
- return legends
-
-
-def set_same_axis() -> None:
- """Set the same axis."""
- global new_axis
- new_axis = False
-
-
-def set_new_axis() -> None:
- """Set the new axis."""
- global new_axis
- new_axis = True
-
-
-def make_new_axis() -> bool:
- """Make a new axis."""
- return new_axis
-
-
-def get_current_figure() -> Optional["OpenBBFigure"]:
- """Get the current figure."""
- return current_figure
-
-
-def set_current_figure(fig: Optional[OpenBBFigureT] = None):
- """Set the current figure."""
- # pylint: disable=global-statement
- global current_figure
- current_figure = fig
-
def bootstrap():
"""Setup pre-launch configurations for the CLI."""
diff --git a/cli/openbb_cli/controllers/base_controller.py b/cli/openbb_cli/controllers/base_controller.py
index 9db39807a09..5c644f479c9 100644
--- a/cli/openbb_cli/controllers/base_controller.py
+++ b/cli/openbb_cli/controllers/base_controller.py
@@ -10,7 +10,6 @@ from pathlib import Path
from typing import Any, Dict, List, Literal, Optional, Union
import pandas as pd
-from openbb_cli.config import setup
from openbb_cli.config.completer import NestedCompleter
from openbb_cli.config.constants import SCRIPT_TAGS
from openbb_cli.controllers.choices import build_controller_choice_map
@@ -63,14 +62,12 @@ class BaseController(metaclass=ABCMeta):
"r",
"reset",
"stop",
- "hold",
"whoami",
"results",
]
CHOICES_COMMANDS: List[str] = []
CHOICES_MENUS: List[str] = []
- HOLD_CHOICES: dict = {}
NEWS_CHOICES: dict = {}
COMMAND_SEPARATOR = "/"
KEYS_MENU = "keys" + COMMAND_SEPARATOR
@@ -166,113 +163,6 @@ class BaseController(metaclass=ABCMeta):
return old_class.menu()
return class_ins(*args, **kwargs).menu()
- def call_hold(self, other_args: List[str]) -> None:
- """Process hold command."""
- self.save_class()
- parser = argparse.ArgumentParser(
- add_help=False,
- formatter_class=argparse.ArgumentDefaultsHelpFormatter,
- prog="hold",
- description="Turn on figure holding. This will stop showing images until hold off is run.",
- )
- parser.add_argument(
- "-o",
- "--option",
- choices=["on", "off"],
- type=str,
- default="off",
- dest="option",
- )
- parser.add_argument(
- "-s",
- "--sameaxis",
- action="store_true",
- default=False,
- help="Put plots on the same axis. Best when numbers are on similar scales",
- dest="axes",
- )
- parser.add_argument(
- "--title",
- type=str,
- default="",
- dest="title",
- nargs="+",
- help="When using hold off, this sets the title for the figure.",
- )
- if other_args and "-" not in other_args[0][0]:
- other_args.insert(0, "-o")
-
- ns_parser = self.parse_known_args_and_warn(
- parser,
- other_args,
- )
- if ns_parser:
- if ns_parser.option == "on":
- setup.HOLD = True
- setup.COMMAND_ON_CHART = False
- if ns_parser.axes:
- setup.set_same_axis()
- else:
- setup.set_new_axis()
- if ns_parser.option == "off":
- setup.HOLD = False
- if setup.get_current_figure() is not None:
- # create a subplot
- fig = setup.get_current_figure()
- if fig is None:
- return
- if not fig.has_subplots and not setup.make_new_axis():
- fig.set_subplots(1, 1, specs=[[{"secondary_y": True}]])
-
- if setup.make_new_axis():
- for i, trace in enumerate(fig.select_traces()):
- trace.yaxis = f"y{i+1}"
-
- if i != 0:
- fig.update_layout(
- {
- f"yaxis{i+1}": dict(
- side="left",
- overlaying="y",
- showgrid=True,
- showline=False,
- zeroline=False,
- automargin=True,
- ticksuffix=(
- " " * (i - 1) if i > 1 else ""
- ),
- tickfont=dict(
- size=18,
- ),
- title=dict(
- font=dict(
- size=15,
- ),
- standoff=0,
- ),
- ),
- }
- )
- # pylint: disable=undefined-loop-variable
- fig.update_layout(margin=dict(l=30 * i))
-
- else:
- fig.update_yaxes(title="")
-
- if any(setup.get_legends()):
- for trace, new_name in zip(
- fig.select_traces(), setup.get_legends()
- ):
- if new_name:
- trace.name = new_name
-
- fig.update_layout(title=" ".join(ns_parser.title))
- fig.show()
- setup.COMMAND_ON_CHART = True
-
- setup.set_current_figure(None)
- setup.reset_legend()
-
def save_class(self) -> None:
"""Save the current instance of the class to be loaded later."""
if session.settings.REMEMBER_CONTEXTS:
@@ -832,16 +722,6 @@ class BaseController(metaclass=ABCMeta):
"-h", "--help", action="store_true", help="show this help message"
)
- if setup.HOLD:
- parser.add_argument(
- "--legend",
- type=str,
- dest="hold_legend_str",
- default="",
- nargs="+",
- help="Label for legend when hold is on.",
- )
-
if export_allowed != "no_export":
choices_export = []
help_export = "Does not export!"
@@ -925,10 +805,6 @@ class BaseController(metaclass=ABCMeta):
return None
- # This protects against the hidden loads in stocks/fa
- if parser.prog != "load" and setup.HOLD:
- setup.set_last_legend(" ".join(ns_parser.hold_legend_str))
-
if l_unknown_args:
session.console.print(
f"The following args couldn't be interpreted: {l_unknown_args}"
diff --git a/cli/openbb_cli/controllers/cli_controller.py b/cli/openbb_cli/controllers/cli_controller.py
index 5f16f070229..2a98389067b 100644
--- a/cli/openbb_cli/controllers/cli_controller.py
+++ b/cli/openbb_cli/controllers/cli_controller.py
@@ -160,8 +160,6 @@ class CLIController(BaseController):
if session.prompt_session and session.settings.USE_PROMPT_TOOLKIT:
# choices: dict = self.choices_default
choices: dict = {c: {} for c in self.controller_choices} # type: ignore
- choices["hold"] = {c: None for c in ["on", "off", "-s", "--sameaxis"]}
- choices["hold"]["off"] = {"--title": None}
self.ROUTINE_FILES = {
filepath.name: filepath # type: ignore
@@ -199,8 +197,6 @@ class CLIController(BaseController):
"-d": "--description",
"--public": None,
"-p": "--public",
- "--local": None,
- "-l": "--local",
"--tag1": {c: None for c in constants.SCRIPT_TAGS},
"--tag2": {c: None for c in constants.SCRIPT_TAGS},
"--tag3": {c: None for c in constants.SCRIPT_TAGS},
@@ -481,7 +477,7 @@ class CLIController(BaseController):
except FileNotFoundError:
session.console.print(
- f"[red]File '{routine_path}' doesn't exist.[/red]\n"
+ f"[red]File '{routine_path}' doesn't exist.[/red]"
)
return