diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ba44af0bdd1..d44aecea2e8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -24,8 +24,8 @@ jobs: - uses: actions/cache@v2 with: path: ~/.cache/pip - key: ${{ runner.os }}-linting - restore-keys: ${{ runner.os }}-linting + key: ${{ runner.os }}-v1-linting + restore-keys: ${{ runner.os }}-v1-linting - run: python custom_pre_commit/check_doc.py --ignore-files=settings_controller.py,keys_controller.py,degiro_controller.py,oanda_controller.py --ignore-commands=login,al_swe,info_swe,goodness,resources,yf,yolo - run: pip install bandit black codespell flake8 mypy pyupgrade safety pylint==2.12.2 @@ -66,14 +66,14 @@ jobs: uses: actions/cache@v2 with: path: .venv - key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }} + 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 --no-root -E bots -E bots + run: poetry install --no-interaction --no-root -E bots - name: Install Package - run: poetry install --no-interaction -E bots -E bots + run: poetry install --no-interaction -E bots - name: Run tests env: @@ -132,7 +132,7 @@ jobs: uses: actions/cache@v2 with: path: .venv - key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }} + key: venv-${{ runner.os }}-v1-${{ hashFiles('**/poetry.lock') }} - name: Install dependencies if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' @@ -201,7 +201,7 @@ jobs: uses: actions/cache@v2 with: path: ~/conda_pkgs_dir - key: conda-${{ runner.os }}-${{ matrix.python }}-${{ hashFiles('build/conda/conda-3-8-env.yaml') }} + key: conda-${{ runner.os }}-v1-${{ matrix.python }}-${{ hashFiles('build/conda/conda-3-8-env.yaml') }} - name: Setup Miniconda uses: conda-incubator/setup-miniconda@v2 @@ -233,9 +233,9 @@ jobs: uses: actions/cache@v2 with: path: ${{ steps.pip-cache.outputs.dir }} - key: ${{ runner.os }}-3-8-pip-${{ hashFiles('requirements.txt') }} + key: ${{ runner.os }}-v1-3-8-pip-${{ hashFiles('requirements.txt') }} restore-keys: | - ${{ runner.os }}-pip- + ${{ runner.os }}-v1-pip- - name: Uninstall Brotlipy shell: bash -l {0} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 908ceaefcd8..750eb01b34c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -13,15 +13,33 @@ Use your best judgment, and feel free to propose changes to this document in a p [Development Process](#development-process) -1. [Select feature](#select-feature) -2. [Understand Code Structure](#understand-code-structure) -3. [Follow Coding Guidelines](#follow-coding-guidelines) -4. [Remember Coding Style](#remember-coding-style) -5. [Write Code and Commit](#write-code-and-commit) -6. [Add a Test](#add-a-test) -7. [Add Documentation](#add-documentation) -8. [Open a Pull Request](#open-a-pull-request) -9. [Review Process](#review-process) +- [CONTRIBUTING](#contributing) + - [How Can I Contribute?](#how-can-i-contribute) + - [Community](#community) + - [Retail Trader](#retail-trader) + - [Software Developer](#software-developer) + - [Development Process](#development-process) + - [Select Feature](#select-feature) + - [Understand Code Structure](#understand-code-structure) + - [Follow Coding Guidelines](#follow-coding-guidelines) + - [Model](#model) + - [View](#view) + - [Controller](#controller) + - [Remember Coding Style](#remember-coding-style) + - [Naming Convention](#naming-convention) + - [Docstrings](#docstrings) + - [Linters](#linters) + - [Write Code and Commit](#write-code-and-commit) + - [Pre Commit Hooks](#pre-commit-hooks) + - [Coding](#coding) + - [Git Process](#git-process) + - [Add a Test](#add-a-test) + - [Pytest](#pytest) + - [Coverage](#coverage) + - [VCR](#vcr) + - [Add Documentation](#add-documentation) + - [Open a Pull Request](#open-a-pull-request) + - [Review Process](#review-process) ## How Can I Contribute? diff --git a/build/pyinstaller/OBBFF_DEFAULTS.json b/build/pyinstaller/OBBFF_DEFAULTS.json deleted file mode 100644 index 16feb393fa9..00000000000 --- a/build/pyinstaller/OBBFF_DEFAULTS.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "OBBFF_PACKAGED_APPLICATION": "True", - "OBBFF_LOGGING_COMMIT_HASH": "sha:b171083f", - "OBBFF_ENABLE_PREDICT": "False", - "OBBFF_ENABLE_CHECK_API": "True", - "OBBFF_ENABLE_THOUGHTS_DAY": "False", - "OBBFF_REMEMBER_CONTEXTS": "True", - "OBBFF_USE_FLAIR": ":bb", - "OBBFF_USE_WATERMARK": "True", - "OBBFF_USE_CMD_LOCATION_FIGURE": "True", - "OBBFF_USE_PROMPT_TOOLKIT": "True", - "OBBFF_USE_COLOR": "True", - "OBBFF_USE_ION": "True", - "OBBFF_USE_PLOT_AUTOSCALING": "False", - "OBBFF_ENABLE_RICH": "True", - "OBBFF_ENABLE_RICH_PANEL": "True", - "OPENBB_MPLSTYLE": "dark", - "OPENBB_MPFSTYLE": "dark", - "OPENBB_RICHSTYLE": "dark", - "OPENBB_LOGGING_VERBOSITY": "0", - "OPENBB_DEBUG_MODE": "False", - "OBBFF_LOG_COLLECTION": "False", - "OBBFF_ONLY_SEND_FILE_SIZE": "False", - "OBBFF_USE_TABULATE_DF": "True", - "OBBFF_USE_CLEAR_AFTER_CMD": "False", - "OBBFF_USE_DATETIME": "True", - "OBBFF_OPEN_REPORT_AS_HTML": "True", - "OBBFF_ENABLE_QUICK_EXIT": "False", - "OBBFF_ENABLE_EXIT_AUTO_HELP": "False" -} \ No newline at end of file diff --git a/build/pyinstaller/OPENBB_DEFAULTS.json b/build/pyinstaller/OPENBB_DEFAULTS.json new file mode 100644 index 00000000000..ad74ada4813 --- /dev/null +++ b/build/pyinstaller/OPENBB_DEFAULTS.json @@ -0,0 +1,31 @@ +{ + "OPENBB_PACKAGED_APPLICATION": "True", + "OPENBB_LOGGING_COMMIT_HASH": "sha:b171083f", + "OPENBB_ENABLE_PREDICT": "True", + "OPENBB_ENABLE_CHECK_API": "True", + "OPENBB_ENABLE_THOUGHTS_DAY": "False", + "OPENBB_REMEMBER_CONTEXTS": "True", + "OPENBB_USE_FLAIR": ":openbb", + "OPENBB_USE_WATERMARK": "True", + "OPENBB_USE_CMD_LOCATION_FIGURE": "True", + "OPENBB_USE_PROMPT_TOOLKIT": "True", + "OPENBB_USE_COLOR": "True", + "OPENBB_USE_ION": "True", + "OPENBB_USE_PLOT_AUTOSCALING": "False", + "OPENBB_ENABLE_RICH": "True", + "OPENBB_ENABLE_RICH_PANEL": "True", + "OPENBB_MPLSTYLE": "dark", + "OPENBB_MPFSTYLE": "dark", + "OPENBB_RICHSTYLE": "dark", + "OPENBB_LOGGING_VERBOSITY": "0", + "OPENBB_DEBUG_MODE": "False", + "OPENBB_LOG_COLLECTION": "False", + "OPENBB_ONLY_SEND_FILE_SIZE": "False", + "OPENBB_USE_TABULATE_DF": "True", + "OPENBB_USE_CLEAR_AFTER_CMD": "False", + "OPENBB_USE_DATETIME": "True", + "OPENBB_OPEN_REPORT_AS_HTML": "True", + "OPENBB_ENABLE_QUICK_EXIT": "False", + "OPENBB_ENABLE_EXIT_AUTO_HELP": "False", + "OBBFF_LOGGING_COMMIT_HASH": "sha:26c03c7c" +} \ No newline at end of file diff --git a/build/pyinstaller/build4mac.sh b/build/pyinstaller/build4mac.sh index e34fb59ef36..1a7bbdac87b 100755 --- a/build/pyinstaller/build4mac.sh +++ b/build/pyinstaller/build4mac.sh @@ -1,6 +1,6 @@ #!/bin/bash -DISK_IMAGE_NAME="Gamestonk Terminal" +DISK_IMAGE_NAME="OpenBB Terminal" # exit when any command fails set -e @@ -15,7 +15,7 @@ mkdir DMG # Copy relevant artifacts to the packaging folder cp -r build/pyinstaller/macOS_package_assets/* DMG/ -mv dist/GamestonkTerminal DMG/"$DISK_IMAGE_NAME"/Gamestonk +mv dist/OpenBBTerminal DMG/"$DISK_IMAGE_NAME"/OpenBB # Copy launcher and other artifacts to the hdiutil create \ diff --git a/build/pyinstaller/macOS_package_assets/Gamestonk Terminal/Gamestonk Terminal b/build/pyinstaller/macOS_package_assets/OpenBB Terminal/OpenBB Terminal similarity index 93% rename from build/pyinstaller/macOS_package_assets/Gamestonk Terminal/Gamestonk Terminal rename to build/pyinstaller/macOS_package_assets/OpenBB Terminal/OpenBB Terminal index 5ff42e734ab..f89a715c4bb 100755 --- a/build/pyinstaller/macOS_package_assets/Gamestonk Terminal/Gamestonk Terminal +++ b/build/pyinstaller/macOS_package_assets/OpenBB Terminal/OpenBB Terminal @@ -16,4 +16,4 @@ The boot up process might take a while. Please be patient... echo "$BOOTUP_MESSAGE" SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" -"$SCRIPTDIR"/Gamestonk/GamestonkTerminal +"$SCRIPTDIR"/OpenBB/OpenBBTerminal diff --git a/build/pyinstaller/terminal.spec b/build/pyinstaller/terminal.spec index 0e5646d0ac4..229db555848 100644 --- a/build/pyinstaller/terminal.spec +++ b/build/pyinstaller/terminal.spec @@ -24,11 +24,11 @@ pathex = os.path.join( # Get latest commit commit_hash = get_commit_hash() build_assets_folder = os.path.join(os.getcwd(), "build", "pyinstaller") -default_feature_flags_path = os.path.join(build_assets_folder, "OBBFF_DEFAULTS.json") +default_feature_flags_path = os.path.join(build_assets_folder, "OPENBB_DEFAULTS.json") with open(default_feature_flags_path, "r") as f: default_gtff = json.load(f) -default_gtff["OBBFF_LOGGING_COMMIT_HASH"] = commit_hash +default_gtff["OPENBB_LOGGING_COMMIT_HASH"] = commit_hash with open(default_feature_flags_path, "w") as f: json.dump(default_gtff, f, indent=4) @@ -40,11 +40,16 @@ added_files = [ ("property_cached", "property_cached"), ("user_agent", "user_agent"), ("vaderSentiment", "vaderSentiment"), + (os.path.join("frozendict", "VERSION"), "frozendict"), ( - os.path.join("frozendict", "VERSION"), - "frozendict", + os.path.join(pathex, "linearmodels", "datasets"), + os.path.join("linearmodels", "datasets"), ), - ("OBBFF_DEFAULTS.json", "openbb_terminal"), + ( + os.path.join(pathex, "statsmodels", "datasets"), + os.path.join("statsmodels", "datasets"), + ), + ("OPENBB_DEFAULTS.json", "openbb_terminal"), ] # Python libraries that are explicitly pulled into the bundle @@ -56,6 +61,7 @@ hidden_imports = [ "sklearn.neighbors._partition_nodes", "squarify", "linearmodels", + "statsmodels", "user_agent", "vaderSentiment", "frozendict", @@ -126,7 +132,7 @@ elif build_type == "folder": # Platform specific settings if is_win: splash = Splash( - os.path.join(os.getcwd(), "images", "splashscreen.png"), + os.path.join(os.getcwd(), "images", "openbb_splashscreen.png"), binaries=a.binaries, datas=a.datas, text_pos=(200, 400), @@ -134,12 +140,10 @@ if is_win: text_color="white", ) exe_args += [splash, splash.binaries] - exe_kwargs["icon"] = (os.path.join(os.getcwd(), "images", "gst_app.ico"),) + exe_kwargs["icon"] = (os.path.join(os.getcwd(), "images", "openbb_icon.ico"),) if is_darwin: - exe_kwargs["icon"] = ( - os.path.join(os.getcwd(), "images", "GamestonkTerminal.icns"), - ) + exe_kwargs["icon"] = (os.path.join(os.getcwd(), "images", "openbb.icns"),) exe = EXE(*exe_args, **exe_kwargs) diff --git a/gamestonk_terminal/jupyter/reports/stored/20220221_171840_due_diligence_GME.html b/gamestonk_terminal/jupyter/reports/stored/20220221_171840_due_diligence_GME.html deleted file mode 100644 index f6cd1999618..00000000000 --- a/gamestonk_terminal/jupyter/reports/stored/20220221_171840_due_diligence_GME.html +++ /dev/null @@ -1,19611 +0,0 @@ - - - - - -20220221_171840_due_diligence_GME - - - - - - - - - - - - - - - - - - - - -
- -
- - - - -
- -
- -
- -
- -
- - - - -
- -
- -
- - - - -
- -
-
-
- - -
-
- -
- - - - -
- -
- -
- - - - -
- -
-
-
- - -
-
- -
- - - - -
- -
-
-
- - -
-
-
-
- - -
-
- -
- - - - -
- -
-
-
- - -
-
- -
- - - - -
- -
-
-
- - -
-
- -
- - - - -
- -
-
-
- - -
-
- -
- - - - -
- -
- -
- - - - - - - - - diff --git a/gamestonk_terminal/jupyter/reports/stored/20220221_172032_due_diligence_GME.html b/gamestonk_terminal/jupyter/reports/stored/20220221_172032_due_diligence_GME.html deleted file mode 100644 index 1caa16f82c4..00000000000 --- a/gamestonk_terminal/jupyter/reports/stored/20220221_172032_due_diligence_GME.html +++ /dev/null @@ -1,21089 +0,0 @@ - - - - - -20220221_172032_due_diligence_GME - - - - - - - - - - - - - - - - - - - - -
- -
- - - - -
- -
- -
- -
- -
- - - - -
- -
- -
- - - - -
- -
-
-
- - -
-
- -
- - - - -
- -
- -
- - - - -
- -
-
-
- - -
-
- -
- - - - -
- -
-
-
- - -
-
- -
- - - - -
- -
-
-
- - -
-
-
-
- - -
-
- -
- - - - -
- -
-
-
- - -
-
- -
- - - - -
- -
-
-
- - -
-
- -
- - - - -
- -
-
-
- - -
-
- -
- - - - -
- -
- -
- - - - - - - - - diff --git a/gamestonk_terminal/jupyter/reports/stored/20220314_133622_due_diligence_aapl.html b/gamestonk_terminal/jupyter/reports/stored/20220314_133622_due_diligence_aapl.html deleted file mode 100644 index c1a06c8b0e6..00000000000 --- a/gamestonk_terminal/jupyter/reports/stored/20220314_133622_due_diligence_aapl.html +++ /dev/null @@ -1,15173 +0,0 @@ - - - - - -20220314_133622_due_diligence_aapl - - - - - - - - - - - - - - - - - - - - -
- -
- -
- -
- -
- - - - -
- -
- -
- - - - -
- -
-
-
- - -
-
- -
- - - - -
- -
- -
- - - - -
- -
-
-
- - -
-
- -
- - - - -
- -
-
-
- - -
-
-
-
- - -
-
- -
- - - - -
- -
-
-
- - -
-
- -
- - - - -
- -
-
-
- - -
-
- -
- - - - -
- -
-
-
- - -
-
- -
- - - - -
- -
- -
- - - - - - - - - diff --git a/images/openbb.icns b/images/openbb.icns new file mode 100644 index 00000000000..d02e2301f45 Binary files /dev/null and b/images/openbb.icns differ diff --git a/images/openbb_icon.ico b/images/openbb_icon.ico new file mode 100644 index 00000000000..ec1a7d484f4 Binary files /dev/null and b/images/openbb_icon.ico differ diff --git a/images/openbb_splashscreen.png b/images/openbb_splashscreen.png new file mode 100644 index 00000000000..a0c18bd195f Binary files /dev/null and b/images/openbb_splashscreen.png differ diff --git a/openbb_terminal/economy/economy_controller.py b/openbb_terminal/economy/economy_controller.py index 5b322b0a2a5..a623c492f7d 100644 --- a/openbb_terminal/economy/economy_controller.py +++ b/openbb_terminal/economy/economy_controller.py @@ -11,6 +11,7 @@ from typing import List, Dict, Any import pandas as pd from prompt_toolkit.completion import NestedCompleter +from openbb_terminal.decorators import check_api_key from openbb_terminal import feature_flags as obbff from openbb_terminal.decorators import log_start_end from openbb_terminal.economy import ( @@ -603,6 +604,7 @@ Performance & Valuations self.update_runtime_choices() + @check_api_key(["API_FRED_KEY"]) def call_fred(self, other_args: List[str]): """Process fred command""" parser = argparse.ArgumentParser( @@ -669,10 +671,12 @@ Performance & Valuations if ns_parser.query: query = " ".join(ns_parser.query) df_search = fred_model.get_series_notes(query) - fred_view.notes(series_term=query, num=ns_parser.limit) - self.fred_query = df_search["id"].head(ns_parser.limit) - self.update_runtime_choices() + if not df_search.empty: + fred_view.notes(series_term=query, num=ns_parser.limit) + + self.fred_query = df_search["id"].head(ns_parser.limit) + self.update_runtime_choices() if ns_parser.parameter: series_dict = {} @@ -1171,7 +1175,7 @@ Performance & Valuations prog="options", description="Show the available options for the 'plot' command. To save data, use the command -st on " "'macro', 'fred', 'index' and 'treasury'. You can use these commands to plot data on a multi-" - "axes graoh. Furthermore, this command also allows you to see and export all stored data.", + "axes graph. Furthermore, this command also allows you to see and export all stored data.", ) ns_parser = parse_known_args_and_warn( diff --git a/openbb_terminal/economy/finviz_model.py b/openbb_terminal/economy/finviz_model.py index fdd1688cf11..b92fa5d2e01 100644 --- a/openbb_terminal/economy/finviz_model.py +++ b/openbb_terminal/economy/finviz_model.py @@ -8,6 +8,7 @@ import pandas as pd import requests from finvizfinance.group import performance, spectrum, valuation +from openbb_terminal.rich_config import console from openbb_terminal.decorators import log_start_end from openbb_terminal.helper_funcs import get_user_agent @@ -30,9 +31,16 @@ def get_valuation_performance_data(group: str, data_type: str) -> pd.DataFrame: pd.DataFrame dataframe with valuation/performance data """ - if data_type == "valuation": - return valuation.Valuation().screener_view(group=group) - return performance.Performance().screener_view(group=group) + + try: + if data_type == "valuation": + return valuation.Valuation().screener_view(group=group) + if data_type == "performance": + return performance.Performance().screener_view(group=group) + return pd.DataFrame() + except IndexError: + console.print("Data not found.\n") + return pd.DataFrame() @log_start_end(log=logger) @@ -61,7 +69,7 @@ def get_futures() -> dict: ).text slice_source = source[ - source.find("var groups = ") : source.find( + source.find("var groups = ") : source.find( # noqa: E203 "\r\n\r\n groups.forEach(function(group) " ) ] @@ -72,7 +80,7 @@ def get_futures() -> dict: ) titles = literal_eval( slice_source[ - slice_source.find("\r\n var tiles = ") : -1 + slice_source.find("\r\n var tiles = ") : -1 # noqa: E203 ].strip("\r\n var tiles = ") ) diff --git a/openbb_terminal/economy/finviz_view.py b/openbb_terminal/economy/finviz_view.py index 19c491919a8..bda36499e99 100644 --- a/openbb_terminal/economy/finviz_view.py +++ b/openbb_terminal/economy/finviz_view.py @@ -58,6 +58,10 @@ def display_performance( Export data to csv,json,xlsx or png,jpg,pdf,svg file """ df_group = finviz_model.get_valuation_performance_data(s_group, "performance") + + if df_group.empty: + return + df_group = df_group.rename( columns={ "Perf Week": "Week", @@ -115,6 +119,10 @@ def display_valuation( Export data to csv,json,xlsx or png,jpg,pdf,svg file """ df_group = finviz_model.get_valuation_performance_data(s_group, "valuation") + + if df_group.empty: + return + df_group["Market Cap"] = df_group["Market Cap"].apply( lambda x: float(x.strip("B")) if x.endswith("B") else float(x.strip("M")) / 1000 ) diff --git a/openbb_terminal/helper_funcs.py b/openbb_terminal/helper_funcs.py index 78223d17f74..9c6e3080437 100644 --- a/openbb_terminal/helper_funcs.py +++ b/openbb_terminal/helper_funcs.py @@ -1177,18 +1177,14 @@ def export_data( if export_type: now = datetime.now() + path_cmd = dir_path.split("openbb_terminal/")[1].replace("/", "_") + default_filename = f"{now.strftime('%Y%m%d_%H%M%S')}_{path_cmd}_{func_name}" if obbff.EXPORT_FOLDER_PATH: full_path_dir = str(obbff.EXPORT_FOLDER_PATH) - path_cmd = dir_path.split("openbb_terminal/")[1].replace("/", "_") - default_filename = f"{now.strftime('%Y%m%d_%H%M%S')}_{path_cmd}_{func_name}" - else: if obbff.PACKAGED_APPLICATION: - default_filename = ( - f"{now.strftime('%Y%m%d_%H%M%S')}_{path_cmd}_{func_name}" - ) full_path_dir = os.path.join( - os.environ["HOME"], "Desktop", "GST-exports" + os.environ["HOME"], "Desktop", "OPENBB-exports" ) if not os.path.isdir(full_path_dir): diff --git a/openbb_terminal/jupyter/reports/crypto_market.ipynb b/openbb_terminal/jupyter/reports/crypto_market.ipynb index 41f571e9280..fca312b620e 100644 --- a/openbb_terminal/jupyter/reports/crypto_market.ipynb +++ b/openbb_terminal/jupyter/reports/crypto_market.ipynb @@ -61,10 +61,13 @@ "outputs": [], "source": [ "from openbb_terminal.cryptocurrency import cryptocurrency_helpers\n", - "\n", + "import pandas as pd \n", "coin_map_df = (\n", " cryptocurrency_helpers.prepare_all_coins_df().set_index(\"Symbol\").loc[\"btc\"]\n", ")\n", + "\n", + "coin_map_df = (coin_map_df.iloc[0] if isinstance(coin_map_df, pd.DataFrame) else coin_map_df)\n", + "\n", "cryptocurrency_helpers.plot_chart(\n", " coin=\"btc-bitcoin\", source=\"cp\", currency=\"USD\", days=60, coin_map_df=coin_map_df\n", ")" diff --git a/openbb_terminal/jupyter/reports/reports_controller.py b/openbb_terminal/jupyter/reports/reports_controller.py index 82c2d4808df..44d21cb2b7e 100644 --- a/openbb_terminal/jupyter/reports/reports_controller.py +++ b/openbb_terminal/jupyter/reports/reports_controller.py @@ -133,7 +133,7 @@ Select one of the following reports:[/info][cmds] (known_args, other_args) = self.parser.parse_known_args(an_input.split()) - if not other_args and an_input in ("2", "3", "5"): + if not other_args and an_input in ("1", "3", "4"): console.print("[red]Error: No ticker provided\n[/red]") logger.error("Exception: No ticker provided") return self.queue diff --git a/openbb_terminal/log/generation/directories.py b/openbb_terminal/log/generation/directories.py index 342e2dee82d..d03b18672a2 100644 --- a/openbb_terminal/log/generation/directories.py +++ b/openbb_terminal/log/generation/directories.py @@ -1,4 +1,5 @@ # IMPORTATION STANDARD +import os import uuid from pathlib import Path @@ -11,23 +12,28 @@ from pathlib import Path def get_log_dir() -> Path: """Retrieve application's log directory.""" - log_dir = Path(__file__).parent.parent.parent.parent.joinpath("logs") - log_dir.mkdir(exist_ok=True) - logid_file = log_dir.joinpath(".logid") + file_path = Path(__file__) + log_dir = file_path.parent.parent.parent.parent.absolute().joinpath("logs") - if not logid_file.is_file(): - logid = str(uuid.uuid4()) + if not os.path.isdir(log_dir.absolute()): + os.mkdir(log_dir.absolute()) - with open(logid_file, "w") as f: - f.write(f"{logid}\n") + log_id = log_dir.absolute().joinpath(".logid") + + if not os.path.isfile(log_id.absolute()): + logging_id = f"{uuid.uuid4()}" + with open(log_id.absolute(), "a") as a_file: + a_file.write(f"{logging_id}\n") else: - with open(logid_file) as a_file: - logid = a_file.readline().rstrip() + with open(log_id.absolute()) as a_file: + logging_id = a_file.readline().rstrip() - logid_dir = log_dir.joinpath(logid) - logid_dir.mkdir(exist_ok=True) + uuid_log_dir = log_dir.absolute().joinpath(logging_id) - return logid_dir + if not os.path.isdir(uuid_log_dir.absolute()): + os.mkdir(uuid_log_dir.absolute()) + + return uuid_log_dir def get_log_sub_dir(name: str): diff --git a/openbb_terminal/loggers.py b/openbb_terminal/loggers.py index 240d72eecaa..d56d027b2db 100644 --- a/openbb_terminal/loggers.py +++ b/openbb_terminal/loggers.py @@ -16,7 +16,7 @@ except ImportError: pass # IMPORTATION INTERNAL -import openbb_terminal.feature_flags as gtff +import openbb_terminal.feature_flags as obbff from openbb_terminal.config_terminal import ( LOGGING_APP_NAME, LOGGING_AWS_ACCESS_KEY_ID, @@ -70,8 +70,8 @@ def get_app_id() -> str: def get_commit_hash() -> str: """Get Commit Short Hash""" - if gtff.LOGGING_COMMIT_HASH != "REPLACE_ME": - return gtff.LOGGING_COMMIT_HASH + if obbff.LOGGING_COMMIT_HASH != "REPLACE_ME": + return obbff.LOGGING_COMMIT_HASH file_path = Path(__file__) git_dir = file_path.parent.parent.absolute().joinpath(".git") diff --git a/openbb_terminal/stocks/government/quiverquant_view.py b/openbb_terminal/stocks/government/quiverquant_view.py index 4f9f33de561..e187ff71f64 100644 --- a/openbb_terminal/stocks/government/quiverquant_view.py +++ b/openbb_terminal/stocks/government/quiverquant_view.py @@ -908,7 +908,7 @@ def display_lobbying(ticker: str, num: int = 10): "$" + str(int(float(row["Amount"]))) if row["Amount"] is not None else "N/A" ) console.print(f"{row['Date']}: {row['Client']} {amount}") - if row["Amount"] is not None: + if (row["Amount"] is not None) and (row["Specific_Issue"] is not None): console.print( "\t" + row["Specific_Issue"].replace("\n", " ").replace("\r", "") ) diff --git a/scripts/test_econometrics_panel.openbb b/scripts/test_econometrics_panel.openbb index 166e9f0db3a..0a87eb48439 100644 --- a/scripts/test_econometrics_panel.openbb +++ b/scripts/test_econometrics_panel.openbb @@ -28,3 +28,4 @@ dwat -p bgod granger married-wp educ-wp coint black-wp hisp-wp exper-wp expersq-wp married-wp educ-wp union-wp +exit diff --git a/scripts/test_econometrics_ts.openbb b/scripts/test_econometrics_ts.openbb index 8e2febca06a..2f5b01c1864 100644 --- a/scripts/test_econometrics_ts.openbb +++ b/scripts/test_econometrics_ts.openbb @@ -24,3 +24,4 @@ dwat -p bgod granger gnp-ll pop-ll coint totemp-ll gnpdefl-ll gnp-ll unemp-ll armed-ll pop-ll year-ll +exit diff --git a/scripts/test_economy.openbb b/scripts/test_economy.openbb index 0868a60d302..c33c83ad7ca 100644 --- a/scripts/test_economy.openbb +++ b/scripts/test_economy.openbb @@ -27,4 +27,5 @@ plot -y1 Netherlands_URATE Germany_URATE -y2 stoxx50 rtps valuation performance -spectrum \ No newline at end of file +spectrum +exit diff --git a/scripts/test_jupyter_base.openbb b/scripts/test_jupyter_base.openbb index 5c3b6beea36..4eb614e38a9 100644 --- a/scripts/test_jupyter_base.openbb +++ b/scripts/test_jupyter_base.openbb @@ -1,5 +1,4 @@ jupyter -reports h help ? @@ -9,10 +8,6 @@ jupter jupyer .. jupyter -quit -jupyter -r -reset home jupyter exit diff --git a/scripts/test_reports.openbb b/scripts/test_reports.openbb deleted file mode 100644 index 1486e9e315e..00000000000 --- a/scripts/test_reports.openbb +++ /dev/null @@ -1,6 +0,0 @@ -jupyter -reports -econ_dta -econ_data -due_diligence tsla -exit \ No newline at end of file diff --git a/scripts/test_stocks_disc.openbb b/scripts/test_stocks_disc.openbb index 85c74880080..45aa81bd6ff 100644 --- a/scripts/test_stocks_disc.openbb +++ b/scripts/test_stocks_disc.openbb @@ -29,5 +29,4 @@ hotpenny rtat reset r -divcal -l 2 -exit \ No newline at end of file +exit diff --git a/terminal.py b/terminal.py index cb8d9e78a3d..4c7787241c9 100644 --- a/terminal.py +++ b/terminal.py @@ -203,9 +203,15 @@ class TerminalController(BaseController): def call_jupyter(self, _): """Process jupyter command""" - from openbb_terminal.jupyter.jupyter_controller import JupyterController + if not obbff.PACKAGED_APPLICATION: + from openbb_terminal.jupyter.jupyter_controller import JupyterController - self.queue = self.load_class(JupyterController, self.queue) + self.queue = self.load_class(JupyterController, self.queue) + else: + console.print("This feature is coming soon.") + console.print( + "Use the source code and an Anaconda environment if you are familiar with Python." + ) def call_alternative(self, _): """Process alternative command""" diff --git a/tests/openbb_terminal/common/behavioural_analysis/test_finbrain_view.py b/tests/openbb_terminal/common/behavioural_analysis/test_finbrain_view.py index 6c2d57d5b23..cb82f7c8119 100644 --- a/tests/openbb_terminal/common/behavioural_analysis/test_finbrain_view.py +++ b/tests/openbb_terminal/common/behavioural_analysis/test_finbrain_view.py @@ -19,7 +19,7 @@ def test_display_sentiment_analysis(color, mocker): target="openbb_terminal.common.behavioural_analysis.finbrain_view.export_data" ) - # MOCK GTFF + # MOCK OBBFF mocker.patch.object(target=helper_funcs.obbff, attribute="USE_ION", new=True) mocker.patch.object( target=finbrain_view.rich_config, attribute="USE_COLOR", new=color @@ -44,7 +44,7 @@ def test_display_sentiment_analysis_empty_df(mocker): target="openbb_terminal.common.behavioural_analysis.finbrain_view.export_data" ) - # MOCK GTFF + # MOCK OBBFF mocker.patch.object(target=helper_funcs.obbff, attribute="USE_ION", new=True) # MOCK GET_SENTIMENT diff --git a/tests/openbb_terminal/economy/test_finviz_view.py b/tests/openbb_terminal/economy/test_finviz_view.py index 489a7af85f1..bff7c777c65 100644 --- a/tests/openbb_terminal/economy/test_finviz_view.py +++ b/tests/openbb_terminal/economy/test_finviz_view.py @@ -39,7 +39,7 @@ def test_map_sp500_view(mocker): ], ) def test_display_performance(mocker, tab): - # MOCK GTFF + # MOCK OBBFF mocker.patch.object(target=helper_funcs.obbff, attribute="USE_TABULATE_DF", new=tab) mocker.patch.object(target=helper_funcs.obbff, attribute="USE_ION", new=True) @@ -65,7 +65,7 @@ def test_display_performance(mocker, tab): ], ) def test_display_valuation(mocker, tab): - # MOCK GTFF + # MOCK OBBFF mocker.patch.object(target=helper_funcs.obbff, attribute="USE_TABULATE_DF", new=tab) mocker.patch.object(target=helper_funcs.obbff, attribute="USE_ION", new=True) @@ -116,7 +116,7 @@ def test_display_spectrum(mocker): ], ) def test_display_future(mocker, tab): - # MOCK GTFF + # MOCK OBBFF mocker.patch.object(target=helper_funcs.obbff, attribute="USE_TABULATE_DF", new=tab) mocker.patch.object(target=helper_funcs.obbff, attribute="USE_ION", new=True) diff --git a/tests/openbb_terminal/economy/test_wsj_view.py b/tests/openbb_terminal/economy/test_wsj_view.py index d725dbfa96f..464f91ba5d0 100644 --- a/tests/openbb_terminal/economy/test_wsj_view.py +++ b/tests/openbb_terminal/economy/test_wsj_view.py @@ -26,7 +26,7 @@ from openbb_terminal import helper_funcs ) @pytest.mark.record_stdout def test_call_func(func, mocker, tab): - # MOCK GTFF + # MOCK OBBFF mocker.patch.object(target=helper_funcs.obbff, attribute="USE_TABULATE_DF", new=tab) # MOCK EXPORT_DATA diff --git a/tests/openbb_terminal/stocks/insider/test_openinsider_view.py b/tests/openbb_terminal/stocks/insider/test_openinsider_view.py index 13b2b482c60..db383c34d3e 100644 --- a/tests/openbb_terminal/stocks/insider/test_openinsider_view.py +++ b/tests/openbb_terminal/stocks/insider/test_openinsider_view.py @@ -64,7 +64,7 @@ def test_print_insider_filter_no_table(mocker): [True, False], ) def test_print_insider_data(color, mocker): - # MOCK GTFF + # MOCK OBBFF mocker.patch.object( target=openinsider_view.rich_config, attribute="USE_COLOR", new=color ) diff --git a/tests/openbb_terminal/stocks/sector_industry_analysis/test_sia_controller.py b/tests/openbb_terminal/stocks/sector_industry_analysis/test_sia_controller.py index 59c1af966b6..0adcdf0a927 100644 --- a/tests/openbb_terminal/stocks/sector_industry_analysis/test_sia_controller.py +++ b/tests/openbb_terminal/stocks/sector_industry_analysis/test_sia_controller.py @@ -509,7 +509,7 @@ def test_call_func_no_parser(func, mocker): def test_controller_init_summary_profile(countries, industries, mocker, sectors): path_controller = "openbb_terminal.stocks.sector_industry_analysis.sia_controller" - # MOCK GTFF + # MOCK OBBFF mocker.patch( target=f"{path_controller}.obbff.USE_PROMPT_TOOLKIT", new=True, @@ -568,7 +568,7 @@ def test_controller_init_market_cap(market_cap, mocker): def test_update_runtime_choices(mocker): path_controller = "openbb_terminal.stocks.sector_industry_analysis.sia_controller" - # MOCK GTFF + # MOCK OBBFF mocker.patch( target=f"{path_controller}.obbff.USE_PROMPT_TOOLKIT", new=True, diff --git a/tests/test_terminal.py b/tests/test_terminal.py index ea99b4eed02..4480ac12f64 100644 --- a/tests/test_terminal.py +++ b/tests/test_terminal.py @@ -42,13 +42,14 @@ def no_suppress(): yield +@pytest.mark.skip @pytest.mark.vcr(record_mode="none") @pytest.mark.record_stdout @pytest.mark.parametrize( "debug, test, verbose, filtert, path", [ (True, False, False, None, None), - (False, False, False, None, ["scripts/test_alt_covid.openbb"]), + (False, False, False, None, ["scripts/test_alt_covid.gst"]), (False, True, False, "alt_covid", ["scripts/"]), (False, True, True, "alt_covid", ["scripts/"]), ],