mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-27 12:40:35 +00:00
Rebrand sdk to platform in code (#5496)
* Relink sdk/sdk -> platform/platform * Relink sdk -> platform * Rename folders * Fix dev_install script * Fix test generators * Fix test generators * Fix test generators * Organize imports
This commit is contained in:
committed by
GitHub
parent
b570102ab0
commit
009699928f
2
.github/workflows/sdkv4-core.yml
vendored
2
.github/workflows/sdkv4-core.yml
vendored
@@ -33,7 +33,7 @@ jobs:
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.cache/pip
|
||||
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('openbb_sdk/poetry.lock') }}
|
||||
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('openbb_platform/poetry.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-pip-
|
||||
|
||||
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -77,7 +77,7 @@ cache/
|
||||
lightning_logs/
|
||||
|
||||
# user script to install all extensions and providers
|
||||
openbb_sdk/sdk/core/tests/app/model/charts/test_chart_settings.py
|
||||
openbb_platform/platform/core/tests/app/model/charts/test_chart_settings.py
|
||||
*/mocked_path
|
||||
|
||||
# CA certificates
|
||||
|
||||
6
.pre-commit-config.yaml
vendored
6
.pre-commit-config.yaml
vendored
@@ -25,8 +25,8 @@ repos:
|
||||
entry: pydocstyle
|
||||
language: python
|
||||
types: [python]
|
||||
files: '^openbb_sdk/.*\.py$'
|
||||
exclude: 'tests/.*\.py|openbb_sdk/test_.*\.py'
|
||||
files: '^openbb_platform/.*\.py$'
|
||||
exclude: 'tests/.*\.py|openbb_platform/test_.*\.py'
|
||||
args: ["--config=pyproject.toml"]
|
||||
- repo: https://github.com/codespell-project/codespell
|
||||
rev: v2.2.5
|
||||
@@ -72,7 +72,7 @@ repos:
|
||||
"--baseline",
|
||||
".secrets.baseline",
|
||||
"--exclude-files",
|
||||
"cassettes/.*|record/.*|website/content/api/.*|openbb_sdk/extensions/charting/openbb_charting/infrastructure/assets/.*\\.js|openbb_sdk/extensions/charting/openbb_charting/infrastructure/.*\\.html",
|
||||
"cassettes/.*|record/.*|website/content/api/.*|openbb_platform/extensions/charting/openbb_charting/infrastructure/assets/.*\\.js|openbb_platform/extensions/charting/openbb_charting/infrastructure/.*\\.html",
|
||||
]
|
||||
exclude: package.lock.json
|
||||
- repo: local
|
||||
|
||||
2
CONTRIBUTING.md
vendored
2
CONTRIBUTING.md
vendored
@@ -511,7 +511,7 @@ In order to add a command to the SDK, follow these steps:
|
||||
|
||||
### Add SDK endpoint (V4)
|
||||
|
||||
Refer to the documentation [here](openbb_sdk\CONTRIBUTING.md).
|
||||
Refer to the documentation [here](openbb_platform\CONTRIBUTING.md).
|
||||
|
||||
### Add Unit Tests
|
||||
|
||||
|
||||
4
build/docker/api.dockerfile
vendored
4
build/docker/api.dockerfile
vendored
@@ -19,10 +19,10 @@ FROM base AS builder
|
||||
|
||||
WORKDIR /openbb
|
||||
|
||||
COPY ./openbb_sdk ./openbb_sdk
|
||||
COPY ./openbb_platform ./openbb_platform
|
||||
|
||||
# Install the SDK
|
||||
RUN pip install /openbb/openbb_sdk
|
||||
RUN pip install /openbb/openbb_platform
|
||||
|
||||
# ---- Copy Files ----
|
||||
FROM base
|
||||
|
||||
12
noxfile.py
12
noxfile.py
@@ -1,16 +1,18 @@
|
||||
import nox
|
||||
|
||||
test_locations = [
|
||||
"openbb_sdk/tests",
|
||||
"openbb_sdk/sdk",
|
||||
"openbb_sdk/providers",
|
||||
"openbb_platform/tests",
|
||||
"openbb_platform/platform",
|
||||
"openbb_platform/providers",
|
||||
]
|
||||
|
||||
|
||||
@nox.session(python=["3.8", "3.9", "3.10", "3.11"])
|
||||
def tests(session):
|
||||
session.install("poetry", "toml")
|
||||
session.run("python", "./openbb_sdk/dev_install.py", "-e", "all", external=True)
|
||||
session.run(
|
||||
"python", "./openbb_platform/dev_install.py", "-e", "all", external=True
|
||||
)
|
||||
session.install("pytest")
|
||||
session.install("pytest-cov")
|
||||
session.run("pytest", *test_locations, "--cov=openbb_sdk/")
|
||||
session.run("pytest", *test_locations, "--cov=openbb_platform/")
|
||||
|
||||
@@ -58,8 +58,8 @@ Saying that, we recommend following the standardization framework, as it will ma
|
||||
|
||||
When standardizing, all data is defined using two different pydantic models:
|
||||
|
||||
1. Define the [query parameters](openbb_sdk\sdk\provider\openbb_provider\abstract\query_params.py) model.
|
||||
2. Define the resulting [data schema](openbb_sdk\sdk\provider\openbb_provider\abstract\data.py) model.
|
||||
1. Define the [query parameters](openbb_platform\platform\provider\openbb_provider\abstract\query_params.py) model.
|
||||
2. Define the resulting [data schema](openbb_platform\platform\provider\openbb_provider\abstract\data.py) model.
|
||||
|
||||
> The models can be entirely custom, or inherit from the OpenBB standardized models.
|
||||
> They enforce a safe and consistent data structure, validation and type checking.
|
||||
@@ -72,9 +72,9 @@ After you've defined both models, you'll need to define a `Fetcher` class which
|
||||
2. `extract_data` - makes the request to the API endpoint and returns the raw data.
|
||||
3. `transform_data` - transforms the raw data into the defined data model.
|
||||
|
||||
> Note that the `Fetcher` should inherit from the [`Fetcher`](openbb_sdk\sdk\provider\openbb_provider\abstract\`Fetcher`.py) class, which is a generic class that receives the query parameters and the data model as type parameters.
|
||||
> Note that the `Fetcher` should inherit from the [`Fetcher`](openbb_platform\platform\provider\openbb_provider\abstract\`Fetcher`.py) class, which is a generic class that receives the query parameters and the data model as type parameters.
|
||||
|
||||
After finalizing your models you need to make them visible to the SDK. This is done by adding the `Fetcher` to the `__init__.py` file of the `<your_package_name>/<your_module_name>` folder as part of the [`Provider`](openbb_sdk\sdk\provider\openbb_provider\abstract\provider.py).
|
||||
After finalizing your models you need to make them visible to the SDK. This is done by adding the `Fetcher` to the `__init__.py` file of the `<your_package_name>/<your_module_name>` folder as part of the [`Provider`](openbb_platform\platform\provider\openbb_provider\abstract\provider.py).
|
||||
|
||||
Any command using the `Fetcher` class you've just defined, will be calling the `transform_query`, `extract_data` and `transform_data` methods under the hood in order to get the data and output it do the end user.
|
||||
|
||||
@@ -122,7 +122,7 @@ You only need to change the `model` parameter to the name of the `Fetcher` dicti
|
||||
|
||||
In the above section, we've seen how to get started with a template.
|
||||
|
||||
In this section, we'll be adding a new data point to the SDK. We will add a new provider with an existing [standard data](openbb_sdk\sdk\provider\openbb_provider\standard_models) model.
|
||||
In this section, we'll be adding a new data point to the SDK. We will add a new provider with an existing [standard data](openbb_platform\platform\provider\openbb_provider\standard_models) model.
|
||||
|
||||
### Identify which type of data you want to add
|
||||
|
||||
@@ -135,7 +135,7 @@ Each router is categorized into different extensions (stocks, forex, crypto, etc
|
||||
|
||||
The Standardization Framework is a set of tools and guidelines that enable the user to query and obtain data in a consistent way across several providers.
|
||||
|
||||
Each data model should inherit from a [standard data](openbb_sdk\sdk\provider\openbb_provider\standard_models) that is already defined in the SDK. This will unlock a set of perks that are only available to standardized data, namely:
|
||||
Each data model should inherit from a [standard data](openbb_platform\platform\provider\openbb_provider\standard_models) that is already defined in the SDK. This will unlock a set of perks that are only available to standardized data, namely:
|
||||
|
||||
- Can query and output data in a standardized way.
|
||||
- Can expect extensions that follow standardization to work out-of-the-box.
|
||||
@@ -143,9 +143,9 @@ Each data model should inherit from a [standard data](openbb_sdk\sdk\provider\op
|
||||
- Can expect consistent data types and validation.
|
||||
- Will work seamlessly with other providers that implement the same standard model.
|
||||
|
||||
The standard models are defined under the `./sdk/core/provider/openbb_provider/standard_models/` directory.
|
||||
The standard models are defined under the `./platform/core/provider/openbb_provider/standard_models/` directory.
|
||||
|
||||
They implement the [`QueryParams`](openbb_sdk\sdk\provider\openbb_provider\abstract\query_params.py) and [`Data`](openbb_sdk\sdk\provider\openbb_provider\abstract\data.py) models, which are the models that are used to query and output data, respectively. They are pydantic models under the hood, so you can leverage all the pydantic features such as validators.
|
||||
They implement the [`QueryParams`](openbb_platform\platform\provider\openbb_provider\abstract\query_params.py) and [`Data`](openbb_platform\platform\provider\openbb_provider\abstract\data.py) models, which are the models that are used to query and output data, respectively. They are pydantic models under the hood, so you can leverage all the pydantic features such as validators.
|
||||
|
||||
#### Standardization Caveats
|
||||
|
||||
@@ -195,7 +195,7 @@ The `Data` class is an abstract class that tells us the expected output data. He
|
||||
|
||||
Given the fact that there's already an endpoint for OHLCV stock data, we can check if the standard exists.
|
||||
|
||||
In this case, it's `StockEOD` which can be found inside the `./sdk/core/provider/openbb_provider/standard_models/` directory.
|
||||
In this case, it's `StockEOD` which can be found inside the `./platform/core/provider/openbb_provider/standard_models/` directory.
|
||||
|
||||
If the standard model doesn't exist:
|
||||
|
||||
@@ -321,7 +321,7 @@ from openbb_<provider_name>.models.stock_eod import <ProviderName>StockEODFetche
|
||||
|
||||
If the provider does not require any credentials, you can simply omit it. On the other hand if it requires more than 2 items to authenticate, you can simply add a list of all the required items to the `required_credentials` list.
|
||||
|
||||
After running `pip install .` on `openbb_sdk/providers/<provider_name>` your provider should be ready for usage, both from the Python interface and the API.
|
||||
After running `pip install .` on `openbb_platform/providers/<provider_name>` your provider should be ready for usage, both from the Python interface and the API.
|
||||
|
||||
## Using other extension as a dependency
|
||||
|
||||
@@ -378,12 +378,12 @@ Then execute the command `poetry install` in the root of your extension to insta
|
||||
|
||||
#### Add a visualization to an existing SDK command
|
||||
|
||||
One should first ensure that the already implemented endpoint is available in the [charting router](openbb_sdk/extensions/charting/openbb_charting/charting_router.py).
|
||||
One should first ensure that the already implemented endpoint is available in the [charting router](openbb_platform/extensions/charting/openbb_charting/charting_router.py).
|
||||
|
||||
To do so, you can run:
|
||||
`python openbb_sdk/extensions/charting/openbb_charting/builder.py` - which will read all the available endpoints and add them to the charting router.
|
||||
`python openbb_platform/extensions/charting/openbb_charting/builder.py` - which will read all the available endpoints and add them to the charting router.
|
||||
|
||||
Afterwards, you'll need to add the visualization to the [charting router](openbb_sdk/extensions/charting/openbb_charting/charting_router.py). The convention to match the endpoint with the respective charting function is the following:
|
||||
Afterwards, you'll need to add the visualization to the [charting router](openbb_platform/extensions/charting/openbb_charting/charting_router.py). The convention to match the endpoint with the respective charting function is the following:
|
||||
|
||||
- `stocks/load` -> `stocks_load`
|
||||
- `ta/ema` -> `ta_ema`
|
||||
@@ -402,7 +402,7 @@ The returned tuple contains a `OpenBBFigure` that is an interactive plotly figur
|
||||
|
||||
After you're done implementing the charting function, you can simply use either the Python interface or the API to get the chart. To do so, you'll only need to set the already available `chart` argument to `True`.
|
||||
|
||||
Refer to the charting extension [documentation](openbb_sdk/extensions/charting/README.md) for more information on usage.
|
||||
Refer to the charting extension [documentation](openbb_platform/extensions/charting/README.md) for more information on usage.
|
||||
|
||||
#### Using the `to_chart` OBBject method
|
||||
|
||||
@@ -413,7 +413,7 @@ The `to_chart` function should be taken as an advanced feature, as it requires t
|
||||
|
||||
The user can use any number of `**kwargs` that will be passed to the `PlotlyTA` class in order to build custom visualizations with custom indicators and similar.
|
||||
|
||||
Refer to the [`to_chart` implementation](openbb_sdk/extensions/charting/openbb_charting/core/to_chart.py) for further details.
|
||||
Refer to the [`to_chart` implementation](openbb_platform/extensions/charting/openbb_charting/core/to_chart.py) for further details.
|
||||
|
||||
> Note that, this method will only work to some limited extent with data that is not standardized.
|
||||
> Also, it is designed only to handle time series data.
|
||||
@@ -454,14 +454,14 @@ Please refer to [OpenBBTerminal docs](https://docs.openbb.co/terminal/installati
|
||||
4. Install the `openbb-core`:
|
||||
|
||||
```bash
|
||||
cd OpenBBTerminal/openbb_sdk/sdk/core/
|
||||
cd OpenBBTerminal/openbb_platform/platform/core/
|
||||
poetry install
|
||||
```
|
||||
|
||||
5. Install dependencies:
|
||||
|
||||
```bash
|
||||
cd OpenBBTerminal/openbb_sdk/extensions/stocks/ # or any other extension
|
||||
cd OpenBBTerminal/openbb_platform/extensions/stocks/ # or any other extension
|
||||
poetry install
|
||||
```
|
||||
|
||||
@@ -472,7 +472,7 @@ Please refer to [OpenBBTerminal docs](https://docs.openbb.co/terminal/installati
|
||||
|
||||
For development purposes, one can install every available extension by running a custom shell script:
|
||||
|
||||
Navigate to `/OpenBBTerminal/openbb_sdk`
|
||||
Navigate to `/OpenBBTerminal/openbb_platform`
|
||||
|
||||
Run `python dev_install.py`.
|
||||
</details>
|
||||
@@ -507,7 +507,7 @@ We aim to have a short import time for the package. To measure that we use `tuna
|
||||
- https://pypi.org/project/tuna/
|
||||
|
||||
To visualize the import time breakdown by module and find potential bottlenecks, run the
|
||||
following commands from `openbb_sdk` directory:
|
||||
following commands from `openbb_platform` directory:
|
||||
|
||||
```bash
|
||||
pip install tuna
|
||||
@@ -74,13 +74,13 @@ Set your keys at [OpenBB Hub](https://my.openbb.co/app/sdk/api-keys) and get you
|
||||
>>> obb.user.credentials.fmp_api_key = "REPLACE_ME"
|
||||
>>> obb.user.credentials.polygon_api_key = "REPLACE_ME"
|
||||
|
||||
>>> # Persist changes in ~/.openbb_sdk/user_settings.json
|
||||
>>> # Persist changes in ~/.openbb_platform/user_settings.json
|
||||
>>> obb.account.save()
|
||||
```
|
||||
|
||||
### 3. Local file
|
||||
|
||||
You can specify the keys directly in the `~/.openbb_sdk/user_settings.json` file.
|
||||
You can specify the keys directly in the `~/.openbb_platform/user_settings.json` file.
|
||||
|
||||
Populate this file with the following template and replace the values with your keys:
|
||||
|
||||
@@ -117,5 +117,5 @@ To develop the OpenBB Platform you need to have the following:
|
||||
How to install the platform in editable mode?
|
||||
|
||||
1. Activate your virtual environment
|
||||
1. Navigate into the `openbb_sdk` folder
|
||||
1. Navigate into the `openbb_platform` folder
|
||||
1. Run `python dev_install.py` to install the packages in editable mode
|
||||
@@ -13,8 +13,8 @@ PYPROJECT = SDK_PATH / "pyproject.toml"
|
||||
LOCAL_DEPS = """
|
||||
[tool.poetry.dependencies]
|
||||
python = ">=3.8,<3.12"
|
||||
openbb-provider = { path = "./sdk/provider", develop = true }
|
||||
openbb-core = { path = "./sdk/core", develop = true }
|
||||
openbb-provider = { path = "./platform/provider", develop = true }
|
||||
openbb-core = { path = "./platform/core", develop = true }
|
||||
|
||||
openbb-benzinga = { path = "./providers/benzinga", develop = true }
|
||||
openbb-fmp = { path = "./providers/fmp", develop = true }
|
||||
@@ -6,7 +6,9 @@ from openbb_core.app.router import RouterLoader
|
||||
|
||||
# refers to the root of the repo, not the root of the extension
|
||||
# this script should be run from the root of the repo
|
||||
CHARTING_ROUTER = "openbb_sdk/extensions/charting/openbb_charting/charting_router.py"
|
||||
CHARTING_ROUTER = (
|
||||
"openbb_platform/extensions/charting/openbb_charting/charting_router.py"
|
||||
)
|
||||
|
||||
|
||||
def get_routes() -> List[str]:
|
||||
|
Before Width: | Height: | Size: 409 KiB After Width: | Height: | Size: 409 KiB |
@@ -10,6 +10,6 @@ To install the extension, run the following command in this folder:
|
||||
pip install openbb-crypto
|
||||
```
|
||||
|
||||
For development please check [Contribution Guidelines](https://github.com/OpenBB-finance/OpenBBTerminal/blob/feature/openbb-sdk-v4/openbb_sdk/CONTRIBUTING.md).
|
||||
For development please check [Contribution Guidelines](https://github.com/OpenBB-finance/OpenBBTerminal/blob/feature/openbb-sdk-v4/openbb_platform/CONTRIBUTING.md).
|
||||
|
||||
Documentation available [here](https://docs.openbb.co/sdk).
|
||||
@@ -10,6 +10,6 @@ To install the extension, run the following command in this folder:
|
||||
pip install openbb-econometrics
|
||||
```
|
||||
|
||||
For development please check [Contribution Guidelines](https://github.com/OpenBB-finance/OpenBBTerminal/blob/feature/openbb-sdk-v4/openbb_sdk/CONTRIBUTING.md).
|
||||
For development please check [Contribution Guidelines](https://github.com/OpenBB-finance/OpenBBTerminal/blob/feature/openbb-sdk-v4/openbb_platform/CONTRIBUTING.md).
|
||||
|
||||
Documentation available [here](https://docs.openbb.co/sdk).
|
||||
@@ -10,6 +10,6 @@ To install the extension, run the following command in this folder:
|
||||
pip install openbb-economy
|
||||
```
|
||||
|
||||
For development please check [Contribution Guidelines](https://github.com/OpenBB-finance/OpenBBTerminal/blob/feature/openbb-sdk-v4/openbb_sdk/CONTRIBUTING.md).
|
||||
For development please check [Contribution Guidelines](https://github.com/OpenBB-finance/OpenBBTerminal/blob/feature/openbb-sdk-v4/openbb_platform/CONTRIBUTING.md).
|
||||
|
||||
Documentation available [here](https://docs.openbb.co/sdk).
|
||||
@@ -12,6 +12,6 @@ To install the extension, run the following command in this folder:
|
||||
pip install openbb-fixedincome
|
||||
```
|
||||
|
||||
For development please check [Contribution Guidelines](https://github.com/OpenBB-finance/OpenBBTerminal/blob/feature/openbb-sdk-v4/openbb_sdk/CONTRIBUTING.md).
|
||||
For development please check [Contribution Guidelines](https://github.com/OpenBB-finance/OpenBBTerminal/blob/feature/openbb-sdk-v4/openbb_platform/CONTRIBUTING.md).
|
||||
|
||||
Documentation available [here](https://docs.openbb.co/sdk).
|
||||
@@ -10,6 +10,6 @@ To install the extension, run the following command in this folder:
|
||||
pip install openbb-forex
|
||||
```
|
||||
|
||||
For development please check [Contribution Guidelines](https://github.com/OpenBB-finance/OpenBBTerminal/blob/feature/openbb-sdk-v4/openbb_sdk/CONTRIBUTING.md).
|
||||
For development please check [Contribution Guidelines](https://github.com/OpenBB-finance/OpenBBTerminal/blob/feature/openbb-sdk-v4/openbb_platform/CONTRIBUTING.md).
|
||||
|
||||
Documentation available [here](https://docs.openbb.co/sdk).
|
||||
@@ -10,6 +10,6 @@ To install the extension, run the following command in this folder:
|
||||
pip install openbb-futures
|
||||
```
|
||||
|
||||
For development please check [Contribution Guidelines](https://github.com/OpenBB-finance/OpenBBTerminal/blob/feature/openbb-sdk-v4/openbb_sdk/CONTRIBUTING.md).
|
||||
For development please check [Contribution Guidelines](https://github.com/OpenBB-finance/OpenBBTerminal/blob/feature/openbb-sdk-v4/openbb_platform/CONTRIBUTING.md).
|
||||
|
||||
Documentation available [here](https://docs.openbb.co/sdk).
|
||||
@@ -10,6 +10,6 @@ To install the extension, run the following command in this folder:
|
||||
pip install openbb-news
|
||||
```
|
||||
|
||||
For development please check [Contribution Guidelines](https://github.com/OpenBB-finance/OpenBBTerminal/blob/feature/openbb-sdk-v4/openbb_sdk/CONTRIBUTING.md).
|
||||
For development please check [Contribution Guidelines](https://github.com/OpenBB-finance/OpenBBTerminal/blob/feature/openbb-sdk-v4/openbb_platform/CONTRIBUTING.md).
|
||||
|
||||
Documentation available [here](https://docs.openbb.co/sdk).
|
||||
0
openbb_sdk/extensions/news/poetry.lock → openbb_platform/extensions/news/poetry.lock
generated
vendored
0
openbb_sdk/extensions/news/poetry.lock → openbb_platform/extensions/news/poetry.lock
generated
vendored
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user