Skip to content

Commit 65902cf

Browse files
committed
remove account module
1 parent 9f0d592 commit 65902cf

File tree

26 files changed

+68
-1632
lines changed

26 files changed

+68
-1632
lines changed

cli/README.md

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -36,32 +36,6 @@ Which should result in the following output:
3636

3737
![image](https://github.com/OpenBB-finance/OpenBB/assets/48914296/f606bb6e-fa00-4fc8-bad2-8269bb4fc38e)
3838

39-
## API keys
39+
## Documentation
4040

41-
To fully leverage the OpenBB Platform you need to get some API keys to connect with data providers. Here are the 3 options on where to set them:
42-
43-
1. OpenBB Hub
44-
2. Local file
45-
46-
### 1. OpenBB Hub
47-
48-
Set your keys at [OpenBB Hub](https://my.openbb.co/app/platform/credentials) and get your personal access token from <https://my.openbb.co/app/platform/pat> to connect with your account.
49-
50-
> Once you log in, on the Platform CLI (through the `/account` menu, all your credentials will be in sync with the OpenBB Hub.)
51-
52-
### 2. Local file
53-
54-
You can specify the keys directly in the `~/.openbb_platform/user_settings.json` file.
55-
56-
Populate this file with the following template and replace the values with your keys:
57-
58-
```json
59-
{
60-
"credentials": {
61-
"fmp_api_key": "REPLACE_ME",
62-
"polygon_api_key": "REPLACE_ME",
63-
"benzinga_api_key": "REPLACE_ME",
64-
"fred_api_key": "REPLACE_ME"
65-
}
66-
}
67-
```
41+
View the user documentation for this package [here](https://docs.openbb.co/cli)

cli/integration/test_integration_hub_service.py

Lines changed: 0 additions & 60 deletions
This file was deleted.

cli/openbb_cli/controllers/base_controller.py

Lines changed: 44 additions & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,12 @@
1414
from openbb_cli.config.completer import NestedCompleter
1515
from openbb_cli.config.constants import SCRIPT_TAGS
1616
from openbb_cli.controllers.choices import build_controller_choice_map
17-
from openbb_cli.controllers.hub_service import upload_routine
1817
from openbb_cli.controllers.utils import (
1918
check_file_type_saved,
2019
check_positive,
2120
get_flair_and_username,
2221
handle_obbject_display,
2322
parse_unknown_args_to_dict,
24-
print_guest_block_msg,
2523
print_rich_table,
2624
remove_file,
2725
system_clear,
@@ -40,7 +38,6 @@
4038

4139
# TODO: We should try to avoid these global variables
4240
RECORD_SESSION = False
43-
RECORD_SESSION_LOCAL_ONLY = False
4441
SESSION_RECORDED = list()
4542
SESSION_RECORDED_NAME = ""
4643
SESSION_RECORDED_DESCRIPTION = ""
@@ -65,7 +62,6 @@ class BaseController(metaclass=ABCMeta):
6562
"r",
6663
"reset",
6764
"stop",
68-
"whoami",
6965
"results",
7066
]
7167

@@ -271,11 +267,6 @@ def call_exit(self, _) -> None:
271267
for _ in range(self.PATH.count("/")):
272268
self.queue.insert(0, "quit")
273269

274-
if not session.is_local():
275-
remove_file(
276-
Path(session.user.preferences.export_directory, "routines", "hub")
277-
)
278-
279270
def call_reset(self, _) -> None:
280271
"""Process reset command.
281272
@@ -398,17 +389,6 @@ def call_record(self, other_args) -> None:
398389
)
399390
return
400391

401-
if session.is_local():
402-
session.console.print(
403-
"[red]Recording session to the OpenBB Hub is not supported in guest mode.[/red]"
404-
)
405-
session.console.print(
406-
"\n[yellow]Visit the OpenBB Hub to register: http://my.openbb.co[/yellow]"
407-
)
408-
session.console.print(
409-
"\n[yellow]Your routine will be saved locally.[/yellow]\n"
410-
)
411-
412392
# Check if title has a valid format
413393
title = " ".join(ns_parser.name) if ns_parser.name else ""
414394
pattern = re.compile(r"^[a-zA-Z0-9\s]+$")
@@ -419,13 +399,11 @@ def call_record(self, other_args) -> None:
419399
return
420400

421401
global RECORD_SESSION # noqa: PLW0603
422-
global RECORD_SESSION_LOCAL_ONLY # noqa: PLW0603
423402
global SESSION_RECORDED_NAME # noqa: PLW0603
424403
global SESSION_RECORDED_DESCRIPTION # noqa: PLW0603
425404
global SESSION_RECORDED_TAGS # noqa: PLW0603
426405
global SESSION_RECORDED_PUBLIC # noqa: PLW0603
427406

428-
RECORD_SESSION_LOCAL_ONLY = session.is_local()
429407
RECORD_SESSION = True
430408
SESSION_RECORDED_NAME = title
431409
SESSION_RECORDED_DESCRIPTION = (
@@ -471,135 +449,64 @@ def call_stop(self, other_args) -> None:
471449
)
472450
else:
473451
current_user = session.user
452+
title_for_local_storage = (
453+
SESSION_RECORDED_NAME.replace(" ", "_") + ".openbb"
454+
)
474455

475-
# Check if the user just wants to store routine locally
476-
# This works regardless of whether they are logged in or not
477-
if RECORD_SESSION_LOCAL_ONLY:
478-
# Whitespaces are replaced by underscores and an .openbb extension is added
479-
title_for_local_storage = (
480-
SESSION_RECORDED_NAME.replace(" ", "_") + ".openbb"
481-
)
456+
routine_file = os.path.join(
457+
f"{current_user.preferences.export_directory}/routines",
458+
title_for_local_storage,
459+
)
482460

483-
routine_file = os.path.join(
484-
f"{current_user.preferences.export_directory}/routines",
485-
title_for_local_storage,
461+
# If file already exists, add a timestamp to the name
462+
if os.path.isfile(routine_file):
463+
i = session.console.input(
464+
"A local routine with the same name already exists, do you want to override it? (y/n): "
486465
)
487-
488-
# If file already exists, add a timestamp to the name
489-
if os.path.isfile(routine_file):
490-
i = session.console.input(
491-
"A local routine with the same name already exists, do you want to override it? (y/n): "
492-
)
466+
session.console.print("")
467+
while i.lower() not in ["y", "yes", "n", "no"]:
468+
i = session.console.input("Select 'y' or 'n' to proceed: ")
493469
session.console.print("")
494-
while i.lower() not in ["y", "yes", "n", "no"]:
495-
i = session.console.input("Select 'y' or 'n' to proceed: ")
496-
session.console.print("")
497-
498-
if i.lower() in ["n", "no"]:
499-
new_name = (
500-
datetime.now().strftime("%Y%m%d_%H%M%S_")
501-
+ title_for_local_storage
502-
)
503-
routine_file = os.path.join(
504-
current_user.preferences.export_directory,
505-
"routines",
506-
new_name,
507-
)
508-
session.console.print(
509-
f"[yellow]The routine name has been updated to '{new_name}'[/yellow]\n"
510-
)
511470

512-
# Writing to file
513-
Path(os.path.dirname(routine_file)).mkdir(
514-
parents=True, exist_ok=True
515-
)
516-
517-
with open(routine_file, "w") as file1:
518-
lines = ["# OpenBB Platform CLI - Routine", "\n"]
519-
520-
username = getattr(
521-
session.user.profile.hub_session, "username", "local"
471+
if i.lower() in ["n", "no"]:
472+
new_name = (
473+
datetime.now().strftime("%Y%m%d_%H%M%S_")
474+
+ title_for_local_storage
522475
)
523-
524-
lines += (
525-
[f"# Author: {username}", "\n\n"] if username else ["\n"]
476+
routine_file = os.path.join(
477+
current_user.preferences.export_directory,
478+
"routines",
479+
new_name,
480+
)
481+
session.console.print(
482+
f"[yellow]The routine name has been updated to '{new_name}'[/yellow]\n"
526483
)
527-
lines += [
528-
f"# Title: {SESSION_RECORDED_NAME}",
529-
"\n",
530-
f"# Tags: {SESSION_RECORDED_TAGS}",
531-
"\n\n",
532-
f"# Description: {SESSION_RECORDED_DESCRIPTION}",
533-
"\n\n",
534-
]
535-
lines += [c + "\n" for c in SESSION_RECORDED[:-1]]
536-
# Writing data to a file
537-
file1.writelines(lines)
538484

539-
session.console.print(
540-
f"[green]Your routine has been recorded and saved here: {routine_file}[/green]\n"
541-
)
485+
# Writing to file
486+
Path(os.path.dirname(routine_file)).mkdir(parents=True, exist_ok=True)
487+
488+
with open(routine_file, "w") as file1:
489+
lines = ["# OpenBB Platform CLI - Routine", "\n"]
490+
lines += [
491+
f"# Title: {SESSION_RECORDED_NAME}",
492+
"\n",
493+
f"# Tags: {SESSION_RECORDED_TAGS}",
494+
"\n\n",
495+
f"# Description: {SESSION_RECORDED_DESCRIPTION}",
496+
"\n\n",
497+
]
498+
lines += [c + "\n" for c in SESSION_RECORDED[:-1]]
499+
# Writing data to a file
500+
file1.writelines(lines)
542501

543-
# If user doesn't specify they want to store routine locally
544-
# Confirm that the user is logged in
545-
elif not session.is_local():
546-
routine = "\n".join(SESSION_RECORDED[:-1])
547-
hub_session = current_user.profile.hub_session
548-
549-
if routine is not None:
550-
auth_header = (
551-
f"{hub_session.token_type} {hub_session.access_token.get_secret_value()}"
552-
if hub_session
553-
else None
554-
)
555-
kwargs = {
556-
"auth_header": auth_header,
557-
"name": SESSION_RECORDED_NAME,
558-
"description": SESSION_RECORDED_DESCRIPTION,
559-
"routine": routine,
560-
"tags": SESSION_RECORDED_TAGS,
561-
"public": SESSION_RECORDED_PUBLIC,
562-
}
563-
response = upload_routine(**kwargs) # type: ignore
564-
if response is not None and response.status_code == 409:
565-
i = session.console.input(
566-
"A routine with the same name already exists, do you want to replace it? (y/n): "
567-
)
568-
session.console.print("")
569-
if i.lower() in ["y", "yes"]:
570-
kwargs["override"] = True # type: ignore
571-
response = upload_routine(**kwargs) # type: ignore
572-
else:
573-
session.console.print("[info]Aborted.[/info]")
502+
session.console.print(
503+
f"[green]Your routine has been recorded and saved here: {routine_file}[/green]\n"
504+
)
574505

575506
# Clear session to be recorded again
576507
RECORD_SESSION = False
577508
SESSION_RECORDED = list()
578509

579-
def call_whoami(self, other_args: list[str]) -> None:
580-
"""Process whoami command."""
581-
parser = argparse.ArgumentParser(
582-
add_help=False,
583-
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
584-
prog="whoami",
585-
description="Show current user",
586-
)
587-
ns_parser, _ = self.parse_simple_args(parser, other_args)
588-
589-
if ns_parser:
590-
current_user = session.user
591-
local_user = session.is_local()
592-
if not local_user:
593-
hub_session = current_user.profile.hub_session
594-
session.console.print(
595-
f"[info]email:[/info] {hub_session.email if hub_session else 'N/A'}"
596-
)
597-
session.console.print(
598-
f"[info]uuid:[/info] {hub_session.user_uuid if hub_session else 'N/A'}"
599-
)
600-
else:
601-
print_guest_block_msg()
602-
603510
def call_results(self, other_args: list[str]):
604511
"""Process results command."""
605512
parser = argparse.ArgumentParser(

cli/openbb_cli/controllers/cli_controller.py

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
for d in dir(obb)
5656
if "_" not in d
5757
}
58-
NON_DATA_ROUTERS = ["coverage", "account", "reference", "system", "user"]
58+
NON_DATA_ROUTERS = ["coverage", "reference", "system", "user"]
5959
DATA_PROCESSING_ROUTERS = ["technical", "quantitative", "econometrics"]
6060
env_file = str(ENV_FILE_SETTINGS)
6161
session = Session()
@@ -216,23 +216,7 @@ def update_runtime_choices(self):
216216
def print_help(self):
217217
"""Print help."""
218218
mt = MenuText("")
219-
220-
mt.add_info("Configure the platform and manage your account")
221-
for router, value in PLATFORM_ROUTERS.items():
222-
if router not in NON_DATA_ROUTERS or router in ["reference", "coverage"]:
223-
continue
224-
if value == "menu":
225-
menu_description = (
226-
obb.reference["routers"].get(f"{self.PATH}{router}", {}).get("description") # type: ignore
227-
) or ""
228-
mt.add_menu(
229-
name=router,
230-
description=menu_description.split(".")[0].lower(),
231-
)
232-
else:
233-
mt.add_cmd(router)
234-
235-
mt.add_info("\nConfigure your CLI")
219+
mt.add_info("\nConfigure CLI")
236220
mt.add_menu(
237221
"settings",
238222
description="enable and disable feature flags, preferences and settings",

0 commit comments

Comments
 (0)