summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Maslek <jmaslek11@gmail.com>2024-02-27 13:46:50 -0500
committerGitHub <noreply@github.com>2024-02-27 18:46:50 +0000
commit3d34e56ca7a4196913189c473c939b7f9a1385e0 (patch)
treea802408ba5e5e6192892bb89159bdea1f5b12d81
parentccdb246cda6611b2be031e76e8f0b141c123397a (diff)
Fix the v3 markdown generation workflow (#6138)
* fix workflow * debug time * see if the docs generate at least * ahhhh i found it * getting there * put the test first * some keys cleanup * small change to error message
-rw-r--r--.github/workflows/gh-pages.yml4
-rw-r--r--openbb_platform/core/openbb_core/app/model/hub/features_keys.py1
-rw-r--r--openbb_terminal/keys_controller.py60
-rw-r--r--openbb_terminal/keys_model.py153
-rw-r--r--openbb_terminal/miscellaneous/models/all_api_keys.json6
-rw-r--r--openbb_terminal/miscellaneous/models/hub_credentials.json1
6 files changed, 3 insertions, 222 deletions
diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml
index cfe3c436915..6798a1df4c2 100644
--- a/.github/workflows/gh-pages.yml
+++ b/.github/workflows/gh-pages.yml
@@ -36,7 +36,7 @@ jobs:
- name: Install Poetry
uses: snok/install-poetry@v1
with:
- version: 1.4.0
+ version: 1.8.1
virtualenvs-create: true
virtualenvs-in-project: true
@@ -68,7 +68,7 @@ jobs:
poetry run python openbb_platform/dev_install.py -e all
pip uninstall nbmake -y
poetry run python website/generate_platform_v4_markdown.py
-
+
- name: Generate Excel Docs
run: |
source .venv/bin/activate
diff --git a/openbb_platform/core/openbb_core/app/model/hub/features_keys.py b/openbb_platform/core/openbb_core/app/model/hub/features_keys.py
index 4cc31ced796..31f828017d9 100644
--- a/openbb_platform/core/openbb_core/app/model/hub/features_keys.py
+++ b/openbb_platform/core/openbb_core/app/model/hub/features_keys.py
@@ -33,7 +33,6 @@ class FeaturesKeys(BaseModel):
API_SHROOM_KEY: Optional[str] = Field(default=None)
API_SMARTSTAKE_KEY: Optional[str] = Field(default=None)
API_SMARTSTAKE_TOKEN: Optional[str] = Field(default=None)
- API_STOCKSERA_KEY: Optional[str] = Field(default=None)
API_TOKEN_TERMINAL_KEY: Optional[str] = Field(default=None)
API_TWITTER_BEARER_TOKEN: Optional[str] = Field(default=None)
API_TWITTER_KEY: Optional[str] = Field(default=None)
diff --git a/openbb_terminal/keys_controller.py b/openbb_terminal/keys_controller.py
index 10970861b3d..ba816f3c0ef 100644
--- a/openbb_terminal/keys_controller.py
+++ b/openbb_terminal/keys_controller.py
@@ -1139,36 +1139,6 @@ class KeysController(BaseController): # pylint: disable=too-many-public-methods
)
@log_start_end(log=logger)
- def call_stocksera(self, other_args: List[str]):
- """Process stocksera command"""
- parser = argparse.ArgumentParser(
- add_help=False,
- formatter_class=argparse.ArgumentDefaultsHelpFormatter,
- prog="stocksera",
- description="Set Stocksera API key.",
- )
- parser.add_argument(
- "-k",
- "--key",
- type=str,
- dest="key",
- help="key",
- )
- if not other_args:
- console.print(
- "For your API Key, https://stocksera.pythonanywhere.com/accounts/developers"
- )
- return
-
- if other_args and "-" not in other_args[0][0]:
- other_args.insert(0, "-k")
- ns_parser = self.parse_simple_args(parser, other_args)
- if ns_parser:
- self.status_dict["stocksera"] = keys_model.set_stocksera_key(
- key=ns_parser.key, persist=True, show_output=True
- )
-
- @log_start_end(log=logger)
def call_databento(self, other_args: List[str]):
"""Process databento command"""
parser = argparse.ArgumentParser(
@@ -1197,36 +1167,6 @@ class KeysController(BaseController): # pylint: disable=too-many-public-methods
)
@log_start_end(log=logger)
- def call_openai(self, other_args: List[str]):
- """Process openai command"""
- parser = argparse.ArgumentParser(
- add_help=False,
- formatter_class=argparse.ArgumentDefaultsHelpFormatter,
- prog="openai",
- description="Set OpenAI API key.",
- )
- parser.add_argument(
- "-k",
- "--key",
- type=str,
- dest="key",
- help="key",
- )
- if not other_args:
- console.print("For your API Key, https://openai.com")
- return
-
- if other_args and "-" not in other_args[0][0]:
- other_args.insert(0, "-k")
-
- ns_parser = self.parse_simple_args(parser, other_args)
-
- if ns_parser:
- self.status_dict["openai"] = keys_model.set_openai_key(
- key=ns_parser.key, persist=True, show_output=True
- )
-
- @log_start_end(log=logger)
def call_ultima(self, other_args: List[str]):
"""Process ultima command"""
parser = argparse.ArgumentParser(
diff --git a/openbb_terminal/keys_model.py b/openbb_terminal/keys_model.py
index a922695812d..18b09a77390 100644
--- a/openbb_terminal/keys_model.py
+++ b/openbb_terminal/keys_model.py
@@ -14,11 +14,9 @@ from typing import Dict, List, Union
import binance
import oandapyV20.endpoints.pricing
-import openai
import pandas as pd
import praw
import quandl
-import stocksera
from alpha_vantage.timeseries import TimeSeries
from coinmarketcapapi import CoinMarketCapAPI
from nixtlats import TimeGPT
@@ -82,10 +80,8 @@ API_DICT: Dict = {
"eodhd": "EODHD",
"santiment": "SANTIMENT",
"tokenterminal": "TOKEN_TERMINAL",
- "stocksera": "STOCKSERA",
"dappradar": "DAPPRADAR",
"companieshouse": "COMPANIES_HOUSE",
- "openai": "OPENAI",
"nixtla": "NIXTLA",
}
@@ -96,7 +92,7 @@ API_DICT = dict(sorted(API_DICT.items()))
class KeyStatus(str, Enum):
"""Class to handle status messages and colors"""
- DEFINED_TEST_FAILED = "Defined, test failed"
+ DEFINED_TEST_FAILED = "Defined, test failed. Data may still be accessible."
NOT_DEFINED = "Not defined"
DEFINED_TEST_PASSED = "Defined, test passed"
DEFINED_TEST_INCONCLUSIVE = "Defined, test inconclusive"
@@ -2409,70 +2405,6 @@ def check_tokenterminal_key(show_output: bool = False) -> str:
return str(status)
-def set_stocksera_key(key: str, persist: bool = False, show_output: bool = False):
- """Set Stocksera key.
-
- Parameters
- ----------
- key: str
- API key
- persist: bool, optional
- If False, api key change will be contained to where it was changed. For example, a Jupyter notebook session.
- If True, api key change will be global, i.e. it will affect terminal environment variables.
- By default, False.
- show_output: bool, optional
- Display status string or not. By default, False.
-
- Returns
- -------
- str
- Status of key set
-
- Examples
- --------
- >>> from openbb_terminal.sdk import openbb
- >>> openbb.keys.stocksera(key="example_key")
- """
- handle_credential("API_STOCKSERA_KEY", key, persist)
- return check_stocksera_key(show_output)
-
-
-def check_stocksera_key(show_output: bool = False):
- """Check Stocksera key
-
- Parameters
- ----------
- show_output: bool, optional
- Display status string or not. By default, False.
-
- Returns
- -------
- str
- Status of key set
- """
-
- if show_output:
- console.print("Checking status...")
-
- current_user = get_current_user()
-
- if current_user.credentials.API_STOCKSERA_KEY == "REPLACE_ME":
- status = KeyStatus.NOT_DEFINED
- else:
- client = stocksera.Client(api_key=current_user.credentials.API_STOCKSERA_KEY)
-
- try:
- client.borrowed_shares(ticker="AAPL")
- status = KeyStatus.DEFINED_TEST_PASSED
- except Exception as _: # noqa: F841
- logger.warning("Stocksera key defined, test failed")
- status = KeyStatus.DEFINED_TEST_FAILED
-
- if show_output:
- console.print(status.colorize())
- return str(status)
-
-
def set_intrinio_key(key: str, persist: bool = False, show_output: bool = False) -> str:
"""Set Intrinio key
@@ -2828,89 +2760,6 @@ def check_companieshouse_key(show_output: bool = False) -> str:
return str(status)
-# Set OpenAI key
-def set_openai_key(key: str, persist: bool = False, show_output: bool = False) -> str:
- """Set OpenAI key
-
- Parameters
- ----------
- key: str
- API key
- persist: bool, optional
- If False, api key change will be contained to where it was changed. For example, a Jupyter notebook session.
- If True, api key change will be global, i.e. it will affect terminal environment variables.
- By default, False.
- show_output: bool, optional
- Display status string or not. By default, False.
-
- Returns
- -------
- str
- Status of key set
-
- Examples
- --------
- >>> from openbb_terminal.sdk import openbb
- >>> openbb.keys.openai(key="example_key")
- """
-
- handle_credential("API_OPENAI_KEY", key, persist)
- return check_openai_key(show_output)
-
-
-def check_openai_key(show_output: bool = False) -> str:
- """Check OpenAI key
-
- Parameters
- ----------
- show_output: bool
- Display status string or not. By default, False.
-
- Returns
- -------
- str
- Status of key set
- """
-
- if show_output:
- console.print("Checking status...")
-
- current_user = get_current_user()
-
- if current_user.credentials.API_OPENAI_KEY == "REPLACE_ME":
- logger.info("OpenAI key not defined")
- status = KeyStatus.NOT_DEFINED
- else:
- # Set the endpoint URL and data to be sent
- data = {
- "prompt": "Hello, Open AI!",
- }
-
- # Make the API call and print the response
- try:
- openai.api_key = current_user.credentials.API_OPENAI_KEY
- # Make the API call and print the response
- openai.Completion.create(engine="davinci", prompt=data["prompt"])
- status = KeyStatus.DEFINED_TEST_PASSED
- logger.info("OpenAI key defined, test passed")
-
- except openai.error.AuthenticationError:
- # Handle authentication errors
- logger.warning("OpenAI key defined, test failed")
- status = KeyStatus.DEFINED_TEST_FAILED
-
- except openai.error.APIError as e:
- console.print(e)
- # Handle other API errors
- logger.warning("OpenAI key defined, test inclusive")
- status = KeyStatus.DEFINED_TEST_INCONCLUSIVE
-
- if show_output:
- console.print(status.colorize())
-
- return str(status)
-
-
def set_nixtla_key(key: str, persist: bool = False, show_output: bool = False) -> str:
"""Set Nixtla API key
diff --git a/openbb_terminal/miscellaneous/models/all_api_keys.json b/openbb_terminal/miscellaneous/models/all_api_keys.json
index a3672fe8c86..9989944f216 100644
--- a/openbb_terminal/miscellaneous/models/all_api_keys.json
+++ b/openbb_terminal/miscellaneous/models/all_api_keys.json
@@ -222,12 +222,6 @@
"markdown": "Go to: https://sdk.flipsidecrypto.xyz/shroomdk\n\n![ShroomDK](https://user-images.githubusercontent.com/46355364/207850122-b8cd225e-0a65-4ea8-8069-0b40fff1600e.png)\n\nClick \"Mint Your ShroomDK API Key\", and sign up for an account.\n\n![ShroomDK](https://user-images.githubusercontent.com/46355364/207850176-f29cc73b-2b55-46e8-bce3-62c9342b6599.png)\n\nOnce created, connect a wallet to complete minting the NFT license. The API key will be displayed under the account.\n\n![ShroomDK](https://user-images.githubusercontent.com/46355364/207850380-b59554af-1e65-4616-921d-e02c9ecf1aad.png)"
},
{
- "name": "API_STOCKSERA_KEY",
- "source": "Stocksera",
- "link": "https://stocksera.pythonanywhere.com/",
- "markdown": "Go to: https://stocksera.pythonanywhere.com\n\n![Stocksera](https://user-images.githubusercontent.com/46355364/207853896-ee233569-26bb-4244-b115-43ac8885757a.png)\n\nClick on, \"Log in\", and create an account.\n\n![Stocksera](https://user-images.githubusercontent.com/46355364/207853985-46a7a17f-b6b2-442b-886d-f68b3ba2ad5a.png)\n\nOnce logged in, navigate to the \"Developers\" tab and copy the API key.\n\n![Stocksera](https://user-images.githubusercontent.com/46355364/207854224-e5ddace0-15d1-491c-b616-263cca0bef02.png)"
- },
- {
"name": "API_TOKEN_TERMINAL_KEY",
"source": "Token Terminal",
"link": "https://tokenterminal.com/",
diff --git a/openbb_terminal/miscellaneous/models/hub_credentials.json b/openbb_terminal/miscellaneous/models/hub_credentials.json
index 10bdc74c068..dfc75bc8430 100644
--- a/openbb_terminal/miscellaneous/models/hub_credentials.json
+++ b/openbb_terminal/miscellaneous/models/hub_credentials.json
@@ -24,7 +24,6 @@
"API_SANTIMENT_KEY": "",
"API_EODHD_KEY": "",
"API_TOKEN_TERMINAL_KEY": "",
- "API_STOCKSERA_KEY": "",
"API_INTRINIO_KEY": "",
"API_GITHUB_KEY": "",
"API_REDDIT_CLIENT_ID": "",