[Feature] Improve OBBject Registry (#6364)

* registry belongs to the session instead

* help message on results

* abstract the update_completer a bit and also force the re-link of newly created obbjects so they're immidiatly available

* new settings to control the obbject registry

* new method to remove a certain index from the stack

* using the new flags to control messages on the registyr

* fix: add spaces to results --help

* Update cli/openbb_cli/controllers/feature_flags_controller.py

Co-authored-by: montezdesousa <79287829+montezdesousa@users.noreply.github.com>

* rename to settings_controller

* typo wrong attr

* better messages and actually removing the oldest obbject

---------

Co-authored-by: Diogo Sousa <montezdesousa@gmail.com>
Co-authored-by: montezdesousa <79287829+montezdesousa@users.noreply.github.com>
This commit is contained in:
Henrique Joaquim
2024-05-06 15:49:22 +01:00
committed by GitHub
parent ec7ff94707
commit 380891de4e
8 changed files with 139 additions and 46 deletions

View File

@@ -20,9 +20,7 @@ import certifi
import pandas as pd
import requests
from openbb import obb
from openbb_cli.argparse_translator.obbject_registry import Registry
from openbb_cli.config import constants
from openbb_cli.config.completer import NestedCompleter
from openbb_cli.config.constants import (
ASSETS_DIRECTORY,
ENV_FILE_SETTINGS,
@@ -217,7 +215,7 @@ class CLIController(BaseController):
"--tag3": {c: None for c in constants.SCRIPT_TAGS},
}
self.completer = NestedCompleter.from_nested_dict(choices)
self.update_completer(choices)
def print_help(self):
"""Print help."""
@@ -303,11 +301,11 @@ class CLIController(BaseController):
def call_settings(self, _):
"""Process feature flags command."""
from openbb_cli.controllers.feature_flags_controller import (
FeatureFlagsController,
from openbb_cli.controllers.settings_controller import (
SettingsController,
)
self.queue = self.load_class(FeatureFlagsController, self.queue)
self.queue = self.load_class(SettingsController, self.queue)
def call_exe(self, other_args: List[str]):
"""Process exe command."""
@@ -475,17 +473,6 @@ class CLIController(BaseController):
)
self.queue = self.queue[1:]
def call_results(self, _):
"""Process results command."""
results = Registry().all
if results:
df = pd.DataFrame.from_dict(results, orient="index")
print_rich_table(
df, show_index=True, index_name="stack index", title="OBBject Results"
)
else:
session.console.print("[info]No results found.[/info]")
def handle_job_cmds(jobs_cmds: Optional[List[str]]) -> Optional[List[str]]:
"""Handle job commands."""