make extension building more explicit

This commit is contained in:
Diogo Sousa
2023-07-22 13:22:26 +01:00
parent 29927e6973
commit 372bc883fb
6 changed files with 56 additions and 41 deletions

View File

@@ -313,7 +313,7 @@ class StaticCommandRunner:
# is added to the function signature and shared for jupyter and api
# We can check in the router decorator if the given function has a chart
# in the charting extension then we add it there. This way we can remove
# the chart parameter from the commands.py and packagebuilder, it will be
# the chart parameter from the commands.py and package_builder, it will be
# added to the function signature in the router decorator
chart = kwargs.pop("chart", False)

View File

@@ -9,9 +9,8 @@ from openbb_core.app.static.coverage import Coverage
def create_app():
try:
from openbb_core.app.static.package.root import ( # pylint: disable=import-outside-toplevel
Root,
)
# pylint: disable=import-outside-toplevel
from openbb_core.app.static.package.root import Root as Extensions
except ImportError as e:
raise Exception(
"If you are seeing this exception, you should probably be doing: "
@@ -19,8 +18,24 @@ def create_app():
"PackageBuilder.build()"
) from e
class App(Root):
"""App class."""
class App(Extensions):
"""Here you can access all the basic utility menus and extensions.
Basic utility menus:
- account
- settings
- system
- coverage
Built-in extensions:
- charting: utility extension common to all
- crypto
- economy
- fixedincome
- forex
- news
- stocks
"""
def __init__(self, command_runner_session):
self._command_runner_session = command_runner_session

View File

@@ -19,7 +19,7 @@ class CLASS_economy(Container):
def corecpi(
self,
chart: bool = False,
provider: Optional[Literal["polygon", "fred", "fmp", "benzinga"]] = None,
provider: Optional[Literal["fred", "fmp", "benzinga", "polygon"]] = None,
) -> CommandOutput[openbb_core.app.model.results.empty.Empty]:
"""CORECPI."""
inputs = filter_inputs(
@@ -248,7 +248,7 @@ class CLASS_economy(Container):
def cpi_options(
self,
chart: bool = False,
provider: Optional[Literal["polygon", "fred", "fmp", "benzinga"]] = None,
provider: Optional[Literal["fred", "fmp", "benzinga", "polygon"]] = None,
) -> CommandOutput[openbb_core.app.model.results.empty.Empty]:
"""Get the options for v3 cpi(options=True)"""
inputs = filter_inputs(
@@ -448,7 +448,7 @@ class CLASS_economy(Container):
def macro(
self,
chart: bool = False,
provider: Optional[Literal["polygon", "fred", "fmp", "benzinga"]] = None,
provider: Optional[Literal["fred", "fmp", "benzinga", "polygon"]] = None,
) -> CommandOutput[openbb_core.app.model.results.empty.Empty]:
"""Query EconDB for macro data."""
inputs = filter_inputs(
@@ -470,7 +470,7 @@ class CLASS_economy(Container):
def macro_countries(
self,
chart: bool = False,
provider: Optional[Literal["polygon", "fred", "fmp", "benzinga"]] = None,
provider: Optional[Literal["fred", "fmp", "benzinga", "polygon"]] = None,
) -> CommandOutput[openbb_core.app.model.results.empty.Empty]:
"""MACRO_COUNTRIES."""
inputs = filter_inputs(
@@ -492,7 +492,7 @@ class CLASS_economy(Container):
def macro_parameters(
self,
chart: bool = False,
provider: Optional[Literal["polygon", "fred", "fmp", "benzinga"]] = None,
provider: Optional[Literal["fred", "fmp", "benzinga", "polygon"]] = None,
) -> CommandOutput[openbb_core.app.model.results.empty.Empty]:
"""MACRO_PARAMETERS."""
inputs = filter_inputs(
@@ -514,7 +514,7 @@ class CLASS_economy(Container):
def balance(
self,
chart: bool = False,
provider: Optional[Literal["polygon", "fred", "fmp", "benzinga"]] = None,
provider: Optional[Literal["fred", "fmp", "benzinga", "polygon"]] = None,
) -> CommandOutput[openbb_core.app.model.results.empty.Empty]:
"""BALANCE."""
inputs = filter_inputs(
@@ -536,7 +536,7 @@ class CLASS_economy(Container):
def bigmac(
self,
chart: bool = False,
provider: Optional[Literal["polygon", "fred", "fmp", "benzinga"]] = None,
provider: Optional[Literal["fred", "fmp", "benzinga", "polygon"]] = None,
) -> CommandOutput[openbb_core.app.model.results.empty.Empty]:
"""BIGMAC."""
inputs = filter_inputs(
@@ -558,7 +558,7 @@ class CLASS_economy(Container):
def country_codes(
self,
chart: bool = False,
provider: Optional[Literal["polygon", "fred", "fmp", "benzinga"]] = None,
provider: Optional[Literal["fred", "fmp", "benzinga", "polygon"]] = None,
) -> CommandOutput[openbb_core.app.model.results.empty.Empty]:
"""COUNTRY_CODES."""
inputs = filter_inputs(
@@ -580,7 +580,7 @@ class CLASS_economy(Container):
def currencies(
self,
chart: bool = False,
provider: Optional[Literal["polygon", "fred", "fmp", "benzinga"]] = None,
provider: Optional[Literal["fred", "fmp", "benzinga", "polygon"]] = None,
) -> CommandOutput[openbb_core.app.model.results.empty.Empty]:
"""CURRENCIES."""
inputs = filter_inputs(
@@ -602,7 +602,7 @@ class CLASS_economy(Container):
def debt(
self,
chart: bool = False,
provider: Optional[Literal["polygon", "fred", "fmp", "benzinga"]] = None,
provider: Optional[Literal["fred", "fmp", "benzinga", "polygon"]] = None,
) -> CommandOutput[openbb_core.app.model.results.empty.Empty]:
"""DEBT."""
inputs = filter_inputs(
@@ -624,7 +624,7 @@ class CLASS_economy(Container):
def events(
self,
chart: bool = False,
provider: Optional[Literal["polygon", "fred", "fmp", "benzinga"]] = None,
provider: Optional[Literal["fred", "fmp", "benzinga", "polygon"]] = None,
) -> CommandOutput[openbb_core.app.model.results.empty.Empty]:
"""EVENTS."""
inputs = filter_inputs(
@@ -646,7 +646,7 @@ class CLASS_economy(Container):
def fgdp(
self,
chart: bool = False,
provider: Optional[Literal["polygon", "fred", "fmp", "benzinga"]] = None,
provider: Optional[Literal["fred", "fmp", "benzinga", "polygon"]] = None,
) -> CommandOutput[openbb_core.app.model.results.empty.Empty]:
"""FGDP."""
inputs = filter_inputs(
@@ -668,7 +668,7 @@ class CLASS_economy(Container):
def fred(
self,
chart: bool = False,
provider: Optional[Literal["polygon", "fred", "fmp", "benzinga"]] = None,
provider: Optional[Literal["fred", "fmp", "benzinga", "polygon"]] = None,
) -> CommandOutput[openbb_core.app.model.results.empty.Empty]:
"""FRED."""
inputs = filter_inputs(
@@ -690,7 +690,7 @@ class CLASS_economy(Container):
def fred_search(
self,
chart: bool = False,
provider: Optional[Literal["polygon", "fred", "fmp", "benzinga"]] = None,
provider: Optional[Literal["fred", "fmp", "benzinga", "polygon"]] = None,
) -> CommandOutput[openbb_core.app.model.results.empty.Empty]:
"""FRED Search (was fred_notes)."""
inputs = filter_inputs(
@@ -712,7 +712,7 @@ class CLASS_economy(Container):
def futures(
self,
chart: bool = False,
provider: Optional[Literal["polygon", "fred", "fmp", "benzinga"]] = None,
provider: Optional[Literal["fred", "fmp", "benzinga", "polygon"]] = None,
) -> CommandOutput[openbb_core.app.model.results.empty.Empty]:
"""FUTURES. 2 sources"""
inputs = filter_inputs(
@@ -734,7 +734,7 @@ class CLASS_economy(Container):
def gdp(
self,
chart: bool = False,
provider: Optional[Literal["polygon", "fred", "fmp", "benzinga"]] = None,
provider: Optional[Literal["fred", "fmp", "benzinga", "polygon"]] = None,
) -> CommandOutput[openbb_core.app.model.results.empty.Empty]:
"""GDP."""
inputs = filter_inputs(
@@ -756,7 +756,7 @@ class CLASS_economy(Container):
def glbonds(
self,
chart: bool = False,
provider: Optional[Literal["polygon", "fred", "fmp", "benzinga"]] = None,
provider: Optional[Literal["fred", "fmp", "benzinga", "polygon"]] = None,
) -> CommandOutput[openbb_core.app.model.results.empty.Empty]:
"""GLBONDS."""
inputs = filter_inputs(
@@ -778,7 +778,7 @@ class CLASS_economy(Container):
def indices(
self,
chart: bool = False,
provider: Optional[Literal["polygon", "fred", "fmp", "benzinga"]] = None,
provider: Optional[Literal["fred", "fmp", "benzinga", "polygon"]] = None,
) -> CommandOutput[openbb_core.app.model.results.empty.Empty]:
"""INDICES."""
inputs = filter_inputs(
@@ -800,7 +800,7 @@ class CLASS_economy(Container):
def overview(
self,
chart: bool = False,
provider: Optional[Literal["polygon", "fred", "fmp", "benzinga"]] = None,
provider: Optional[Literal["fred", "fmp", "benzinga", "polygon"]] = None,
) -> CommandOutput[openbb_core.app.model.results.empty.Empty]:
"""OVERVIEW."""
inputs = filter_inputs(
@@ -822,7 +822,7 @@ class CLASS_economy(Container):
def perfmap(
self,
chart: bool = False,
provider: Optional[Literal["polygon", "fred", "fmp", "benzinga"]] = None,
provider: Optional[Literal["fred", "fmp", "benzinga", "polygon"]] = None,
) -> CommandOutput[openbb_core.app.model.results.empty.Empty]:
"""PERFMAP."""
inputs = filter_inputs(
@@ -844,7 +844,7 @@ class CLASS_economy(Container):
def performance(
self,
chart: bool = False,
provider: Optional[Literal["polygon", "fred", "fmp", "benzinga"]] = None,
provider: Optional[Literal["fred", "fmp", "benzinga", "polygon"]] = None,
) -> CommandOutput[openbb_core.app.model.results.empty.Empty]:
"""PERFORMANCE."""
inputs = filter_inputs(
@@ -866,7 +866,7 @@ class CLASS_economy(Container):
def revenue(
self,
chart: bool = False,
provider: Optional[Literal["polygon", "fred", "fmp", "benzinga"]] = None,
provider: Optional[Literal["fred", "fmp", "benzinga", "polygon"]] = None,
) -> CommandOutput[openbb_core.app.model.results.empty.Empty]:
"""REVENUE."""
inputs = filter_inputs(
@@ -888,7 +888,7 @@ class CLASS_economy(Container):
def rgdp(
self,
chart: bool = False,
provider: Optional[Literal["polygon", "fred", "fmp", "benzinga"]] = None,
provider: Optional[Literal["fred", "fmp", "benzinga", "polygon"]] = None,
) -> CommandOutput[openbb_core.app.model.results.empty.Empty]:
"""RGDP."""
inputs = filter_inputs(
@@ -910,7 +910,7 @@ class CLASS_economy(Container):
def rtps(
self,
chart: bool = False,
provider: Optional[Literal["polygon", "fred", "fmp", "benzinga"]] = None,
provider: Optional[Literal["fred", "fmp", "benzinga", "polygon"]] = None,
) -> CommandOutput[openbb_core.app.model.results.empty.Empty]:
"""RTPS."""
inputs = filter_inputs(
@@ -932,7 +932,7 @@ class CLASS_economy(Container):
def search_index(
self,
chart: bool = False,
provider: Optional[Literal["polygon", "fred", "fmp", "benzinga"]] = None,
provider: Optional[Literal["fred", "fmp", "benzinga", "polygon"]] = None,
) -> CommandOutput[openbb_core.app.model.results.empty.Empty]:
"""SEARCH_INDEX."""
inputs = filter_inputs(
@@ -954,7 +954,7 @@ class CLASS_economy(Container):
def spending(
self,
chart: bool = False,
provider: Optional[Literal["polygon", "fred", "fmp", "benzinga"]] = None,
provider: Optional[Literal["fred", "fmp", "benzinga", "polygon"]] = None,
) -> CommandOutput[openbb_core.app.model.results.empty.Empty]:
"""SPENDING."""
inputs = filter_inputs(
@@ -976,7 +976,7 @@ class CLASS_economy(Container):
def trust(
self,
chart: bool = False,
provider: Optional[Literal["polygon", "fred", "fmp", "benzinga"]] = None,
provider: Optional[Literal["fred", "fmp", "benzinga", "polygon"]] = None,
) -> CommandOutput[openbb_core.app.model.results.empty.Empty]:
"""TRUST."""
inputs = filter_inputs(
@@ -998,7 +998,7 @@ class CLASS_economy(Container):
def usbonds(
self,
chart: bool = False,
provider: Optional[Literal["polygon", "fred", "fmp", "benzinga"]] = None,
provider: Optional[Literal["fred", "fmp", "benzinga", "polygon"]] = None,
) -> CommandOutput[openbb_core.app.model.results.empty.Empty]:
"""USBONDS."""
inputs = filter_inputs(
@@ -1020,7 +1020,7 @@ class CLASS_economy(Container):
def valuation(
self,
chart: bool = False,
provider: Optional[Literal["polygon", "fred", "fmp", "benzinga"]] = None,
provider: Optional[Literal["fred", "fmp", "benzinga", "polygon"]] = None,
) -> CommandOutput[openbb_core.app.model.results.empty.Empty]:
"""VALUATION."""
inputs = filter_inputs(

View File

@@ -18,7 +18,7 @@ class CLASS_fixedincome(Container):
def treasury(
self,
start_date: Optional[str] = None,
end_date: Optional[str] = "2023-07-21",
end_date: Optional[str] = "2023-07-22",
chart: bool = False,
provider: Optional[Literal["fmp"]] = None,
**kwargs

View File

@@ -206,8 +206,8 @@ class CLASS_stocks_fa(Container):
@validate_arguments
def cal(
self,
start_date: Union[datetime.date, None, str] = datetime.date(2023, 6, 20),
end_date: Union[datetime.date, None, str] = datetime.date(2023, 7, 20),
start_date: Union[datetime.date, None, str] = datetime.date(2023, 6, 21),
end_date: Union[datetime.date, None, str] = datetime.date(2023, 7, 21),
chart: bool = False,
provider: Optional[Literal["fmp"]] = None,
**kwargs

View File

@@ -29,12 +29,12 @@ from openbb_core.app.router import RouterLoader
class PackageBuilder:
"""Build the static packages for the SDK."""
"""Build the extension package for the SDK."""
@classmethod
def build(cls, lint: bool = True) -> None:
"""Build the static packages for the SDK."""
print("\nBuilding package...\n")
"""Build the extensions for the SDK."""
print("\nBuilding extension package...\n")
cls.save_module_map()
cls.save_modules()
cls.save_package()