Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/move package #5374

Merged
merged 15 commits into from
Aug 25, 2023
6 changes: 3 additions & 3 deletions openbb_sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,13 @@ When developing a specific extension `cd` into the extension directory and run:

`pip install -U -e .`

While we're still developing, it is required to create the static python interface:
While we're still developing, it is often required to reinstall extensions:

```python
python -c "import openbb; openbb._rebuild_python_interface()"
python -c "import openbb; openbb.build()"
```

Currently you need to do this before the first launch and every time you install or uninstall a new extension.
You need to do this every time you install or uninstall a new extension or to reinstall all extensions.

### Import time

Expand Down
30 changes: 25 additions & 5 deletions openbb_sdk/openbb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,23 @@

from openbb_core.app.static.app_factory import create_app as __create_app

sdk = __create_app()
obb = sdk
try:
# pylint: disable=import-outside-toplevel
from openbb.package.__extensions__ import Extensions

obb = sdk = __create_app(Extensions)
except (ImportError, ModuleNotFoundError):
print(
"Failed to import extensions." " Run `openbb.build()` to build extensions code."
)
obb = sdk = __create_app()

def _rebuild_python_interface(

def build(
modules: Optional[Union[str, List[str]]] = None,
lint: bool = True,
) -> None:
"""Rebuild the Python SDK.
"""Build extension modules.

Parameters
----------
Expand All @@ -25,6 +33,18 @@ def _rebuild_python_interface(
lint : bool, optional
Whether to lint the code, by default True
"""
import os
from pathlib import Path
from multiprocessing import Pool
from openbb_core.app.static.package_builder import PackageBuilder

PackageBuilder.build(modules=modules, lint=lint)
current_dir = Path(os.path.dirname(os.path.realpath(__file__)))

# `build` is run in a separate process to avoid consecutive runs in the same
# interpreter to reuse methods already in memory. This was causing docstrings
# to have repeated lines.
with Pool(processes=1) as pool:
pool.apply(
PackageBuilder(current_dir).build,
args=(modules, lint),
)
Original file line number Diff line number Diff line change
Expand Up @@ -22,54 +22,54 @@ def __repr__(self) -> str:

@property
def crypto(self): # route = "/crypto"
from openbb_core.app.static.package import crypto
from openbb.package import crypto

return crypto.CLASS_crypto(command_runner=self._command_runner)

@property
def economy(self): # route = "/economy"
from openbb_core.app.static.package import economy
from openbb.package import economy

return economy.CLASS_economy(command_runner=self._command_runner)

@property
def fixedincome(self): # route = "/fixedincome"
from openbb_core.app.static.package import fixedincome
from openbb.package import fixedincome

return fixedincome.CLASS_fixedincome(command_runner=self._command_runner)

@property
def forex(self): # route = "/forex"
from openbb_core.app.static.package import forex
from openbb.package import forex

return forex.CLASS_forex(command_runner=self._command_runner)

@property
def futures(self): # route = "/futures"
from openbb_core.app.static.package import futures
from openbb.package import futures

return futures.CLASS_futures(command_runner=self._command_runner)

@property
def news(self): # route = "/news"
from openbb_core.app.static.package import news
from openbb.package import news

return news.CLASS_news(command_runner=self._command_runner)

@property
def qa(self): # route = "/qa"
from openbb_core.app.static.package import qa
from openbb.package import qa

return qa.CLASS_qa(command_runner=self._command_runner)

@property
def stocks(self): # route = "/stocks"
from openbb_core.app.static.package import stocks
from openbb.package import stocks

return stocks.CLASS_stocks(command_runner=self._command_runner)

@property
def ta(self): # route = "/ta"
from openbb_core.app.static.package import ta
from openbb.package import ta

return ta.CLASS_ta(command_runner=self._command_runner)
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
import datetime
from typing import List, Literal, Optional, Union

from pydantic import validate_arguments
from typing_extensions import Annotated

from openbb_core.app.model.custom_parameter import OpenBBCustomParameter
from openbb_core.app.model.obbject import OBBject
from openbb_core.app.static.container import Container
from openbb_core.app.static.filters import filter_inputs
from pydantic import validate_arguments
from typing_extensions import Annotated


class CLASS_crypto(Container):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@
import datetime
from typing import List, Literal, Optional, Union

from pydantic import validate_arguments
from typing_extensions import Annotated

import openbb_core.app.model.command_context
import openbb_core.app.model.results.empty
from openbb_core.app.model.custom_parameter import OpenBBCustomParameter
from openbb_core.app.model.obbject import OBBject
from openbb_core.app.static.container import Container
from openbb_core.app.static.filters import filter_inputs
from pydantic import validate_arguments
from typing_extensions import Annotated


class CLASS_economy(Container):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
import datetime
from typing import List, Literal, Optional, Union

from pydantic import validate_arguments
from typing_extensions import Annotated

from openbb_core.app.model.custom_parameter import OpenBBCustomParameter
from openbb_core.app.model.obbject import OBBject
from openbb_core.app.static.container import Container
from openbb_core.app.static.filters import filter_inputs
from pydantic import validate_arguments
from typing_extensions import Annotated


class CLASS_fixedincome(Container):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
import datetime
from typing import List, Literal, Optional, Union

from pydantic import validate_arguments
from typing_extensions import Annotated

from openbb_core.app.model.custom_parameter import OpenBBCustomParameter
from openbb_core.app.model.obbject import OBBject
from openbb_core.app.static.container import Container
from openbb_core.app.static.filters import filter_inputs
from pydantic import validate_arguments
from typing_extensions import Annotated


class CLASS_forex(Container):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
import datetime
from typing import List, Literal, Optional, Union

from pydantic import validate_arguments
from typing_extensions import Annotated

from openbb_core.app.model.custom_parameter import OpenBBCustomParameter
from openbb_core.app.model.obbject import OBBject
from openbb_core.app.static.container import Container
from openbb_core.app.static.filters import filter_inputs
from pydantic import validate_arguments
from typing_extensions import Annotated


class CLASS_futures(Container):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,38 +31,6 @@
"qa_summary": "/qa/summary",
"crypto_load": "/crypto/load",
"crypto": "/crypto",
"ta_atr": "/ta/atr",
"ta": "/ta",
"ta_fib": "/ta/fib",
"ta_obv": "/ta/obv",
"ta_fisher": "/ta/fisher",
"ta_adosc": "/ta/adosc",
"ta_tv": "/ta/tv",
"ta_bbands": "/ta/bbands",
"ta_multi": "/ta/multi",
"ta_zlma": "/ta/zlma",
"ta_aroon": "/ta/aroon",
"ta_sma": "/ta/sma",
"ta_demark": "/ta/demark",
"ta_vwap": "/ta/vwap",
"ta_recom": "/ta/recom",
"ta_macd": "/ta/macd",
"ta_hma": "/ta/hma",
"ta_donchian": "/ta/donchian",
"ta_ichimoku": "/ta/ichimoku",
"ta_clenow": "/ta/clenow",
"ta_ad": "/ta/ad",
"ta_adx": "/ta/adx",
"ta_wma": "/ta/wma",
"ta_cci": "/ta/cci",
"ta_rsi": "/ta/rsi",
"ta_summary": "/ta/summary",
"ta_stoch": "/ta/stoch",
"ta_rsp": "/ta/rsp",
"ta_kc": "/ta/kc",
"ta_cg": "/ta/cg",
"ta_cones": "/ta/cones",
"ta_ema": "/ta/ema",
"news_globalnews": "/news/globalnews",
"news": "/news",
"news_sectornews": "/news/sectornews",
Expand Down Expand Up @@ -208,6 +176,38 @@
"stocks_search": "/stocks/search",
"stocks_quote": "/stocks/quote",
"stocks_info": "/stocks/info",
"ta_atr": "/ta/atr",
"ta": "/ta",
"ta_fib": "/ta/fib",
"ta_obv": "/ta/obv",
"ta_fisher": "/ta/fisher",
"ta_adosc": "/ta/adosc",
"ta_tv": "/ta/tv",
"ta_bbands": "/ta/bbands",
"ta_multi": "/ta/multi",
"ta_zlma": "/ta/zlma",
"ta_aroon": "/ta/aroon",
"ta_sma": "/ta/sma",
"ta_demark": "/ta/demark",
"ta_vwap": "/ta/vwap",
"ta_recom": "/ta/recom",
"ta_macd": "/ta/macd",
"ta_hma": "/ta/hma",
"ta_donchian": "/ta/donchian",
"ta_ichimoku": "/ta/ichimoku",
"ta_clenow": "/ta/clenow",
"ta_ad": "/ta/ad",
"ta_adx": "/ta/adx",
"ta_wma": "/ta/wma",
"ta_cci": "/ta/cci",
"ta_rsi": "/ta/rsi",
"ta_summary": "/ta/summary",
"ta_stoch": "/ta/stoch",
"ta_rsp": "/ta/rsp",
"ta_kc": "/ta/kc",
"ta_cg": "/ta/cg",
"ta_cones": "/ta/cones",
"ta_ema": "/ta/ema",
"economy_corecpi": "/economy/corecpi",
"economy": "/economy",
"economy_const": "/economy/const",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@

from typing import List, Literal, Optional

import pydantic
from pydantic import validate_arguments
from typing_extensions import Annotated

import openbb_core.app.model.command_context
import openbb_core.app.model.results.empty
import pydantic
from openbb_core.app.model.custom_parameter import OpenBBCustomParameter
from openbb_core.app.model.obbject import OBBject
from openbb_core.app.static.container import Container
from openbb_core.app.static.filters import filter_inputs
from pydantic import validate_arguments
from typing_extensions import Annotated


class CLASS_news(Container):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@

from typing import List, Literal, Union

import openbb_core.app.model.results.empty
import openbb_provider
import openbb_qa.qa_models
import pandas
import pydantic
import pydantic.types
from pydantic import validate_arguments

import openbb_core.app.model.results.empty
from openbb_core.app.model.obbject import OBBject
from openbb_core.app.static.container import Container
from openbb_core.app.static.filters import filter_inputs
from pydantic import validate_arguments


class CLASS_qa(Container):
Expand Down
Loading