Skip to content

Commit

Permalink
Merge pull request #15 from Ultima-Insights/develop
Browse files Browse the repository at this point in the history
Sync
  • Loading branch information
AdiSai authored Nov 29, 2023
2 parents 49bdd76 + dc81f6c commit 966e1af
Show file tree
Hide file tree
Showing 327 changed files with 176,911 additions and 150,937 deletions.
1 change: 1 addition & 0 deletions .codespell.ignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ vai
varian
vie
welp
wew
yeld
zar
zlot
5 changes: 3 additions & 2 deletions .github/workflows/platform-api-integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,15 @@ jobs:
"intrinio_api_key": "${{ secrets.INTRINIO_API_KEY }}",
"tradingeconomics_api_key": "${{ secrets.TRADINGECONOMICS_API_KEY }}",
"quandl_api_key": "${{ secrets.QUANDL_API_KEY }}",
"biztoc_api_key": "${{ secrets.BIZTOC_API_KEY }}"
"biztoc_api_key": "${{ secrets.BIZTOC_API_KEY }}",
"nasdaq_api_key": "${{ secrets.NASDAQ_API_KEY }}",
"tiingo_token": "${{ secrets.TIINGO_TOKEN }}"
}
}' > ~/.openbb_platform/user_settings.json
- name: Launch the Uvicorn Process
run: |
source runner_env/bin/activate
pip list
uvicorn openbb_core.api.rest_api:app --host 0.0.0.0 --port 8000 --reload &
- name: Wait for 42 seconds
Expand Down
8 changes: 4 additions & 4 deletions build/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ In this section we detail the steps necessary to construct an installer locally
### MacOS Steps
1. `brew install create-dmg`

This installs create-dmg and it’s dependencies onto your system through brew.
This installs create-dmg and its dependencies onto your system through brew.

1. `poetry install -E installer`

This install pyinstaller and it’s dependencies onto your environment.
This install pyinstaller and its dependencies onto your environment.

3. `build/pyinstaller/build4mac.sh`

Expand All @@ -27,7 +27,7 @@ In this section we detail the steps necessary to construct an installer locally
### Windows Steps
1. `poetry install -E installer`

This install pyinstaller and it’s dependencies onto your environment.
This install pyinstaller and its dependencies onto your environment.

2. `pyinstaller build/pyinstaller/terminal.spec`

Expand All @@ -49,7 +49,7 @@ In this section we detail the steps necessary to construct an installer locally
## Github
In order to utilize the automated build workflow on the OpenBBTerminal repo, the branch in which you would like to build an installer from must already be a branch on the repo. You can also utilize the automated build workflow on a PR that is from a branch on the repo. You cannot run an automated build on a forked branch or even a PR from a forked branch.

If you are using this method to create an installer, there is a limitation where only one build automation can occur at a time per workflow. For example if there is already an installer being created on the the ‘Intel MacOS Build’ workflow, any subsequent requests for building will be queued. Additionally, the ‘Windows10 Build’ workflow runs relatively slowly because of the size of the EC2 instance it is currently on. As such, if you are interested in a quick build, then I would suggest building locally. Furthermore, building an installer this way also automatically runs integration tests on the installer.
If you are using this method to create an installer, there is a limitation where only one build automation can occur at a time per workflow. For example if there is already an installer being created on the ‘Intel MacOS Build’ workflow, any subsequent requests for building will be queued. Additionally, the ‘Windows10 Build’ workflow runs relatively slowly because of the size of the EC2 instance it is currently on. As such, if you are interested in a quick build, then I would suggest building locally. Furthermore, building an installer this way also automatically runs integration tests on the installer.

If you run into a circumstance where a requested build is queued for a long period of time, this might mean that the EC2 instance is not connected to github. If something like this arises, please create an issue.

Expand Down
2 changes: 1 addition & 1 deletion build/pypi/openbb_platform/publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

PLATFORM_PATH = Path(__file__).parent.parent.parent.parent.resolve() / "openbb_platform"

CORE_PACKAGES = ["platform/provider", "platform/core"]
CORE_PACKAGES = ["core"]
EXTENSION_PACKAGES = ["extensions", "providers"]

CMD = [sys.executable, "-m", "poetry"]
Expand Down
13 changes: 11 additions & 2 deletions openbb_platform/core/openbb_core/app/model/credentials.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import traceback
import warnings
from typing import Dict, Optional, Set, Tuple

from importlib_metadata import entry_points
Expand All @@ -12,8 +13,10 @@
from pydantic.functional_serializers import PlainSerializer
from typing_extensions import Annotated

from openbb_core.app.model.abstract.warning import OpenBBWarning
from openbb_core.app.model.extension import Extension
from openbb_core.app.provider_interface import ProviderInterface
from openbb_core.env import Env


class LoadingError(Exception):
Expand Down Expand Up @@ -64,8 +67,14 @@ def from_obbject(self) -> None:
for c in entry.credentials:
self.credentials["obbject"].add(c)
except Exception as e:
traceback.print_exception(type(e), e, e.__traceback__)
raise LoadingError(f"Invalid extension '{entry_point.name}'") from e
msg = f"Error loading extension: {entry_point.name}\n"
if Env().DEBUG_MODE:
traceback.print_exception(type(e), e, e.__traceback__)
raise LoadingError(msg + f"\033[91m{e}\033[0m") from e
warnings.warn(
message=msg,
category=OpenBBWarning,
)

def from_providers(self) -> None:
"""Load credentials from providers"""
Expand Down
6 changes: 5 additions & 1 deletion openbb_platform/core/openbb_core/app/model/user_settings.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"""User settings model."""
from pydantic import Field

from openbb_core.app.model.abstract.tagged import Tagged
Expand All @@ -8,14 +9,17 @@


class UserSettings(Tagged):
"""User settings."""

profile: Profile = Field(default_factory=Profile)
credentials: Credentials = Field(default_factory=Credentials)
preferences: Preferences = Field(default_factory=Preferences)
defaults: Defaults = Field(default_factory=Defaults)

def __repr__(self) -> str:
"""Human readable representation of the object."""
# We use the __dict__ because Credentials.model_dump() will use the serializer
# and unmask the credentials
return f"{self.__class__.__name__}\n\n" + "\n".join(
f"{k}: {v}" for k, v in self.__dict__.items()
f"{k}: {v}" for k, v in self.model_dump().items()
)
11 changes: 7 additions & 4 deletions openbb_platform/core/openbb_core/app/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -565,10 +565,13 @@ def from_extensions() -> Router:
if isinstance(entry, Router):
router.include_router(router=entry, prefix=f"/{entry_point.name}")
except Exception as e:
traceback.print_exception(type(e), e, e.__traceback__)
raise LoadingError(
f"Error loading extension: {entry_point.name}\n"
f"\033[91m{e}\033[0m"
msg = f"Error loading extension: {entry_point.name}\n"
if Env().DEBUG_MODE:
traceback.print_exception(type(e), e, e.__traceback__)
raise LoadingError(msg + f"\033[91m{e}\033[0m") from e
warnings.warn(
message=msg,
category=OpenBBWarning,
)

return router
19 changes: 10 additions & 9 deletions openbb_platform/core/openbb_core/provider/query_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

from pydantic import SecretStr

from openbb_core.app.model.abstract.error import OpenBBError
from openbb_core.provider.abstract.fetcher import Fetcher
from openbb_core.provider.abstract.provider import Provider
from openbb_core.provider.registry import Registry, RegistryLoader
from openbb_core.provider.utils.errors import ProviderError


class QueryExecutor:
Expand All @@ -20,7 +20,7 @@ def get_provider(self, provider_name: str) -> Provider:
"""Get a provider from the registry."""
name = provider_name.lower()
if name not in self.registry.providers:
raise ProviderError(
raise OpenBBError(
f"Provider '{name}' not found in the registry."
f"Available providers: {list(self.registry.providers.keys())}"
)
Expand All @@ -29,7 +29,7 @@ def get_provider(self, provider_name: str) -> Provider:
def get_fetcher(self, provider: Provider, model_name: str) -> Type[Fetcher]:
"""Get a fetcher from a provider."""
if model_name not in provider.fetcher_dict:
raise ProviderError(
raise OpenBBError(
f"Fetcher not found for model '{model_name}' in provider '{provider.name}'."
)
return provider.fetcher_dict[model_name]
Expand All @@ -48,14 +48,15 @@ def filter_credentials(
credentials = {}

for c in provider.credentials:
credential_value = credentials.get(c)
if c not in credentials or credential_value is None:
v = credentials.get(c)
secret = v.get_secret_value() if v else None
if c not in credentials or not secret:
if require_credentials:
website = provider.website or ""
extra_msg = f"Check {website} to get it." if website else ""
raise ProviderError(f"Missing credential '{c}'. {extra_msg}")
extra_msg = f" Check {website} to get it." if website else ""
raise OpenBBError(f"Missing credential '{c}'.{extra_msg}")
else:
filtered_credentials[c] = credential_value.get_secret_value()
filtered_credentials[c] = secret

return filtered_credentials

Expand Down Expand Up @@ -95,4 +96,4 @@ async def execute(
try:
return await fetcher.fetch_data(params, filtered_credentials, **kwargs)
except Exception as e:
raise ProviderError(e) from e
raise OpenBBError(e) from e
18 changes: 14 additions & 4 deletions openbb_platform/core/openbb_core/provider/registry.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
"""Provider Registry Module."""

import traceback
import warnings
from functools import lru_cache
from typing import Dict

from importlib_metadata import entry_points

from openbb_core.app.model.abstract.warning import OpenBBWarning
from openbb_core.env import Env
from openbb_core.provider.abstract.provider import Provider


Expand Down Expand Up @@ -40,9 +43,16 @@ def from_extensions() -> Registry:
registry = Registry()
for entry_point in sorted(entry_points(group="openbb_provider_extension")):
try:
registry.include_provider(provider=entry_point.load())
entry = entry_point.load()
if isinstance(entry, Provider):
registry.include_provider(provider=entry)
except Exception as e:
traceback.print_exception(type(e), e, e.__traceback__)
raise LoadingError(f"Invalid provider '{entry_point.name}': {e}") from e

msg = f"Error loading extension: {entry_point.name}\n"
if Env().DEBUG_MODE:
traceback.print_exception(type(e), e, e.__traceback__)
raise LoadingError(msg + f"\033[91m{e}\033[0m") from e
warnings.warn(
message=msg,
category=OpenBBWarning,
)
return registry
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ class BalanceSheetData(Data):
)
date: dateType = Field(description=DATA_DESCRIPTIONS.get("date", ""))
cik: Optional[str] = Field(
default=None, description="Central Index Key (CIK) of the company."
default=None,
description=DATA_DESCRIPTIONS.get("cik", ""),
)
currency: Optional[str] = Field(default=None, description="Reporting currency.")
filling_date: Optional[dateType] = Field(default=None, description="Filling date.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
)


class DividendCalendarQueryParams(QueryParams):
class CalendarDividendQueryParams(QueryParams):
"""Dividend Calendar Query."""

start_date: Optional[dateType] = Field(
Expand All @@ -25,14 +25,17 @@ class DividendCalendarQueryParams(QueryParams):
)


class DividendCalendarData(Data):
class CalendarDividendData(Data):
"""Dividend Calendar Data."""

date: dateType = Field(
description=DATA_DESCRIPTIONS.get("date", "") + " (Ex-Dividend)"
)
symbol: str = Field(description=DATA_DESCRIPTIONS.get("symbol", ""))
name: Optional[str] = Field(description="Name of the entity.", default=None)
amount: Optional[float] = Field(
default=None, description="Dividend amount, per-share."
)
name: Optional[str] = Field(default=None, description="Name of the entity.")
record_date: Optional[dateType] = Field(
default=None,
description="The record date of ownership for eligibility.",
Expand All @@ -45,6 +48,3 @@ class DividendCalendarData(Data):
default=None,
description="Declaration date of the dividend.",
)
amount: Optional[float] = Field(
default=None, description="Dividend amount, per-share."
)
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ class CashFlowStatementData(Data):
default=None, description="Reporting period of the statement."
)
cik: Optional[str] = Field(
default=None, description="Central Index Key (CIK) of the company."
default=None,
description=DATA_DESCRIPTIONS.get("cik", ""),
)

net_income: Optional[StrictFloat] = Field(default=None, description="Net income.")
Expand Down
Loading

0 comments on commit 966e1af

Please sign in to comment.