Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…minal into develop
  • Loading branch information
deeleeramone committed Feb 17, 2023
2 parents 2e5e58f + 5e37b94 commit 606003c
Show file tree
Hide file tree
Showing 35 changed files with 1,144 additions and 574 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/code-coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Code Coverage Tests

on: workflow_dispatch

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
code-coverage:
runs-on: ubuntu-latest
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
steps:
- name: Checkout code
if: github.event_name == 'push'
uses: actions/checkout@v3

- name: Checkout specific ref
if: github.event_name == 'pull_request'
run: git fetch origin ${{ github.event.pull_request.head.ref }} && git checkout FETCH_HEAD

- name: Setup Python 3.9
uses: actions/setup-python@v4
with:
python-version: "3.9"
architecture: x64

- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: 1.3.2
virtualenvs-create: true
virtualenvs-in-project: true

- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-v1-${{ hashFiles('**/poetry.lock') }}

- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction -E optimization

- name: Run code coverage tests
run: |
source $VENV
pytest --cov --cov-fail-under=50
4 changes: 2 additions & 2 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,12 @@ jobs:
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction -E optimization

- name: Run tests
- name: Run tests and coverage test
env:
MPLBACKEND: Agg
run: |
source $VENV
pytest tests/ --optimization --autodoc
pytest tests/ --optimization --cov --cov-fail-under=50 --autodoc
- name: Start Terminal and exit
run: |
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
| OpenBB is committed to build the future of investment research by focusing on an open source infrastructure accessible to everyone, everywhere. |
|:--:|
| ![openbb.jpg](/images/openbb_gradient.png) |
| Check our website at [openbb.co](www.openbb.co) |
| Check our website at [openbb.co](https://openbb.co) |

<br />

Expand Down Expand Up @@ -126,11 +126,11 @@ If you have any questions about the terminal or anything OpenBB, feel free to em

If you want to say hi, or are interested in partnering with us, feel free to reach us at `[email protected]`

Any of our social media platforms: [openbb.co/links](www.openbb.co/links)
Any of our social media platforms: [openbb.co/links](https://openbb.co/links)

## 6. Star History

This is a proxyy of our growth and that we are just getting started. But for more metrics important to us check [openbb.co/open](www.openbb.co/open).
This is a proxy of our growth and that we are just getting started. But for more metrics important to us check [openbb.co/open](https://openbb.co/open).

[![Star History Chart](https://api.star-history.com/svg?repos=openbb-finance/OpenBBTerminal&type=Date)](https://star-history.com/#openbb-finance/OpenBBTerminal&Date)

Expand Down
2 changes: 1 addition & 1 deletion build/docker/compose.env
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
OPENBBTERMINAL_DOCKER_REGISTRY="ghcr.io"
OPENBBTERMINAL_DOCKER_RELEASE_VERSION="2.4.0"
OPENBBTERMINAL_DOCKER_RELEASE_VERSION="2.4.1"
2 changes: 1 addition & 1 deletion build/docker/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ services:
- ~/OpenBBUserData:/home/python/OpenBBUserData
- ~/.openbb_terminal:/home/python/.openbb_terminal
platform: linux/amd64
image: ghcr.io/openbb-finance/openbbterminal/openbb:2.4.0
image: ghcr.io/openbb-finance/openbbterminal/openbb:2.4.1
stdin_open: true # docker run -i
tty: true # docker run -t
2 changes: 1 addition & 1 deletion build/nsis/setup.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
!define NAME "OpenBB Terminal"
!define COMPANY "OpenBB"
!define APPFILE "OpenBBTerminal.exe"
!define VERSION "2.4.0"
!define VERSION "2.4.1"
!define SLUG "${NAME} v${VERSION}"

;--------------------------------
Expand Down
2 changes: 1 addition & 1 deletion build/pyinstaller/.env
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
OPENBB_LOGGING_APP_NAME=gst_packaged
OPENBB_LOGGING_COMMIT_HASH=sha:5705675
OPENBB_LOGGING_COMMIT_HASH=sha:bbeaef4
OPENBB_ENABLE_PREDICT=false
OPENBB_ENABLE_CHECK_API=true
OPENBB_ENABLE_THOUGHTS_DAY=false
Expand Down
111 changes: 109 additions & 2 deletions openbb_terminal/account/account_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@

from prompt_toolkit.completion import NestedCompleter

from openbb_terminal import feature_flags as obbff
from openbb_terminal import (
feature_flags as obbff,
keys_model,
)
from openbb_terminal.account.account_model import get_diff, get_routines_info
from openbb_terminal.account.account_view import display_routines_list
from openbb_terminal.core.config.paths import USER_ROUTINES_DIRECTORY
Expand Down Expand Up @@ -39,6 +42,9 @@ class AccountController(BaseController):
"upload",
"download",
"delete",
"generate",
"show",
"revoke",
]

PATH = "/account/"
Expand All @@ -53,7 +59,7 @@ def update_runtime_choices(self):
"""Update runtime choices"""
self.ROUTINE_FILES = self.get_routines()
if session and obbff.USE_PROMPT_TOOLKIT:
choices: dict = {c: {} for c in self.controller_choices}
choices: dict = {c: {} for c in self.controller_choices} # type: ignore
choices["sync"] = {"--on": {}, "--off": {}}
choices["upload"]["--file"] = {c: {} for c in self.ROUTINE_FILES}
choices["upload"]["-f"] = choices["upload"]["--file"]
Expand Down Expand Up @@ -91,6 +97,11 @@ def print_help(self):
mt.add_cmd("download")
mt.add_cmd("delete")
mt.add_raw("\n")
mt.add_info("_personal_access_token_")
mt.add_cmd("generate")
mt.add_cmd("show")
mt.add_cmd("revoke")
mt.add_raw("\n")
mt.add_info("_authentication_")
mt.add_cmd("logout")
console.print(text=mt.menu_text, menu="Account")
Expand Down Expand Up @@ -426,3 +437,99 @@ def call_delete(self, other_args: List[str]):
self.update_runtime_choices()
else:
console.print("[info]Aborted.[/info]")

@log_start_end(log=logger)
def call_generate(self, other_args: List[str]) -> None:
"""Process generate command."""
parser = argparse.ArgumentParser(
add_help=False,
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
prog="generate",
description="Generate an OpenBB Personal Access Token.",
)
parser.add_argument(
"-d",
"--days",
dest="days",
help="Number of days the token will be valid",
type=check_positive,
default=30,
)
parser.add_argument(
"-s",
"--save",
dest="save",
default=False,
help="Save the token to the keys",
action="store_true",
)
ns_parser = self.parse_known_args_and_warn(parser, other_args)
if ns_parser:
i = console.input(
"[bold yellow]This will revoke any token that was previously generated."
"\nThis action is irreversible.[/bold yellow]"
"\nAre you sure you want to generate a new token? (y/n): "
)
if i.lower() not in ["y", "yes"]:
console.print("\n[info]Aborted.[/info]")
return

response = Hub.generate_personal_access_token(
auth_header=User.get_auth_header(), days=ns_parser.days
)
if response and response.status_code == 200:
token = response.json().get("token", "")
if token:
console.print(f"\n[info]Token:[/info] {token}\n")

save_to_keys = False
if not ns_parser.save:
save_to_keys = console.input(
"Would you like to save the token to the keys? (y/n): "
).lower() in ["y", "yes"]

if save_to_keys or ns_parser.save:
keys_model.set_openbb_personal_access_token(
key=token, persist=True, show_output=True
)

@log_start_end(log=logger)
def call_show(self, other_args: List[str]) -> None:
"""Process show command."""
parser = argparse.ArgumentParser(
add_help=False,
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
prog="show",
description="Show your current OpenBB Personal Access Token.",
)
ns_parser = self.parse_known_args_and_warn(parser, other_args)
if ns_parser:
response = Hub.get_personal_access_token(auth_header=User.get_auth_header())
if response and response.status_code == 200:
token = response.json().get("token", "")
if token:
console.print(f"[info]Token:[/info] {token}")

@log_start_end(log=logger)
def call_revoke(self, other_args: List[str]) -> None:
"""Process revoke command."""
parser = argparse.ArgumentParser(
add_help=False,
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
prog="revoke",
description="Revoke your current OpenBB Personal Access Token.",
)
ns_parser = self.parse_known_args_and_warn(parser, other_args)
if ns_parser:
i = console.input(
"[bold red]This action is irreversible![/bold red]\n"
"Are you sure you want to revoke your token? (y/n): "
)
if i.lower() in ["y", "yes"]:
response = Hub.revoke_personal_access_token(
auth_header=User.get_auth_header()
)
if response and response.status_code in [200, 202]:
console.print("[info]Token revoked.[/info]")
else:
console.print("[info]Aborted.[/info]")
2 changes: 1 addition & 1 deletion openbb_terminal/core/log/collection/log_sender.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def run(self):
identifier = app_settings.identifier

while True:
item: QueueItem = queue.get()
item: QueueItem = queue.get() # type: ignore
file = item.path
last = item.last

Expand Down
6 changes: 3 additions & 3 deletions openbb_terminal/cryptocurrency/due_diligence/dd_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,6 @@ def call_eb(self, other_args: List[str]):
@log_start_end(log=logger)
def call_oi(self, other_args):
"""Process oi command"""
assert isinstance(self.symbol, str) # noqa: S101
parser = argparse.ArgumentParser(
add_help=False,
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
Expand All @@ -535,6 +534,7 @@ def call_oi(self, other_args):
)

if ns_parser:
assert isinstance(self.symbol, str) # noqa: S101
coinglass_view.display_open_interest(
symbol=self.symbol.upper(),
interval=ns_parser.interval,
Expand All @@ -547,7 +547,6 @@ def call_oi(self, other_args):
@log_start_end(log=logger)
def call_liquidations(self, other_args):
"""Process liquidations command"""
assert isinstance(self.symbol, str) # noqa: S101
parser = argparse.ArgumentParser(
add_help=False,
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
Expand All @@ -563,6 +562,7 @@ def call_liquidations(self, other_args):
)

if ns_parser:
assert isinstance(self.symbol, str) # noqa: S101
coinglass_view.display_liquidations(
symbol=self.symbol.upper(),
export=ns_parser.export,
Expand All @@ -574,7 +574,6 @@ def call_liquidations(self, other_args):
@log_start_end(log=logger)
def call_fundrate(self, other_args):
"""Process fundrate command"""
assert isinstance(self.symbol, str) # noqa: S101
parser = argparse.ArgumentParser(
add_help=False,
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
Expand All @@ -590,6 +589,7 @@ def call_fundrate(self, other_args):
)

if ns_parser:
assert isinstance(self.symbol, str) # noqa: S101
coinglass_view.display_funding_rate(
symbol=self.symbol.upper(),
export=ns_parser.export,
Expand Down
2 changes: 1 addition & 1 deletion openbb_terminal/economy/economy_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -1666,7 +1666,7 @@ def call_qa(self, _):
QaController,
)

data: Dict = {}
data: Dict = {} # type: ignore
for source, _ in self.DATASETS.items():
if not self.DATASETS[source].empty:
if len(self.DATASETS[source].columns) == 1:
Expand Down
2 changes: 1 addition & 1 deletion openbb_terminal/feature_flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
else:
raise Exception("Using git")
except Exception:
version = "2.4.0"
version = "2.4.1"
VERSION = str(os.getenv("OPENBB_VERSION", version))

# Select the terminal translation language
Expand Down
2 changes: 1 addition & 1 deletion openbb_terminal/forecast/forecast_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def update_runtime_choices(self):
# Load in any newly exported files
self.DATA_FILES = forecast_model.get_default_files()
if session and obbff.USE_PROMPT_TOOLKIT:
choices: dict = self.choices_default
choices: dict = self.choices_default # type: ignore

self.choices = choices
self.completer = NestedCompleter.from_nested_dict(choices)
Expand Down
4 changes: 4 additions & 0 deletions openbb_terminal/miscellaneous/i18n/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ en:
_main_menu_: Main menu
account/_authentication_: Authentication
account/logout: Log out from OpenBB account
account/_personal_access_token_: OpenBB Personal Access Token
account/generate: Generate a Personal Access Token
account/show: Shows the current Personal Access Token
account/revoke: Revoke the Personal Access Token
account/_info_: Cloud storage of keys, settings and feature flags
account/sync: Turns the cloud synchronization on/off
account/pull: Pull data from cloud
Expand Down
2 changes: 1 addition & 1 deletion openbb_terminal/reports/reports_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def update_choices(self):
)

if session and obbff.USE_PROMPT_TOOLKIT:
self.choices: dict = {c: {} for c in self.controller_choices}
self.choices: dict = {c: {} for c in self.controller_choices} # type: ignore
self.choices["run"] = {
"--file": {c: None for c in reports_model.USER_REPORTS},
"-f": "--file",
Expand Down
Loading

0 comments on commit 606003c

Please sign in to comment.