From 644912ff8a358a80097a4262d1f052cf40cda3a8 Mon Sep 17 00:00:00 2001 From: Igor Radovanovic <74266147+IgorWounds@users.noreply.github.com> Date: Tue, 3 Oct 2023 13:07:39 +0200 Subject: [PATCH 1/7] Fix demark --- .../extensions/ta/openbb_ta/ta_router.py | 23 +++++-------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/openbb_platform/extensions/ta/openbb_ta/ta_router.py b/openbb_platform/extensions/ta/openbb_ta/ta_router.py index eeb194dce95..364853cdc81 100644 --- a/openbb_platform/extensions/ta/openbb_ta/ta_router.py +++ b/openbb_platform/extensions/ta/openbb_ta/ta_router.py @@ -1,6 +1,7 @@ -from typing import List, Literal, Optional +from typing import List, Literal, Optional, Union import pandas as pd +import pandas_ta as ta from openbb_core.app.model.obbject import OBBject from openbb_core.app.router import Router from openbb_core.app.utils import ( @@ -10,12 +11,7 @@ from openbb_core.app.utils import ( get_target_columns, ) from openbb_provider.abstract.data import Data -from pydantic import ( - NonNegativeFloat, - NonNegativeInt, - PositiveFloat, - PositiveInt, -) +from pydantic import NonNegativeFloat, NonNegativeInt, PositiveFloat, PositiveInt from . import ta_helpers @@ -525,6 +521,7 @@ def demark( show_all: bool = False, asint: bool = False, offset: int = 0, + # fillna: Optional[Union[float, int]] = None, ) -> OBBject[List[Data]]: """ Demark sequential indicator @@ -555,18 +552,10 @@ def demark( >>> stock_data = obb.stocks.load(symbol="TSLA", start_date="2023-01-01", provider="fmp") >>> demark_data = obb.ta.demark(data=stock_data.results,offset=0) """ - df = basemodel_to_df(data, index=index) df_target = get_target_column(df, target).to_frame() - demark_df = pd.DataFrame( - df_target.ta.td_seq( - offset=offset, - show_all=show_all, - asint=asint, - close=target, - prefix=target, - ).dropna() - ) + demark = ta.td_seq(df_target[target], asint=True, show_all=True, offset=offset) + demark_df = pd.DataFrame(demark).set_index(df_target.index).dropna() results = df_to_basemodel(df_target.join(demark_df, how="left"), index=True) From 8e9d27ea8577bb5d8934d7e628d23492d1c50995 Mon Sep 17 00:00:00 2001 From: Igor Radovanovic <74266147+IgorWounds@users.noreply.github.com> Date: Tue, 3 Oct 2023 13:14:01 +0200 Subject: [PATCH 2/7] Lint --- openbb_platform/extensions/ta/openbb_ta/ta_router.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openbb_platform/extensions/ta/openbb_ta/ta_router.py b/openbb_platform/extensions/ta/openbb_ta/ta_router.py index 364853cdc81..cacc50e3aed 100644 --- a/openbb_platform/extensions/ta/openbb_ta/ta_router.py +++ b/openbb_platform/extensions/ta/openbb_ta/ta_router.py @@ -1,4 +1,4 @@ -from typing import List, Literal, Optional, Union +from typing import List, Literal, Optional import pandas as pd import pandas_ta as ta From 0e30ca2f6f21e021ca1a7ebfed81643f5d7bfde5 Mon Sep 17 00:00:00 2001 From: Igor Radovanovic <74266147+IgorWounds@users.noreply.github.com> Date: Tue, 3 Oct 2023 13:40:06 +0200 Subject: [PATCH 3/7] Fix --- openbb_platform/extensions/ta/openbb_ta/ta_router.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/openbb_platform/extensions/ta/openbb_ta/ta_router.py b/openbb_platform/extensions/ta/openbb_ta/ta_router.py index cacc50e3aed..b3f44601b50 100644 --- a/openbb_platform/extensions/ta/openbb_ta/ta_router.py +++ b/openbb_platform/extensions/ta/openbb_ta/ta_router.py @@ -521,7 +521,6 @@ def demark( show_all: bool = False, asint: bool = False, offset: int = 0, - # fillna: Optional[Union[float, int]] = None, ) -> OBBject[List[Data]]: """ Demark sequential indicator @@ -554,7 +553,7 @@ def demark( """ df = basemodel_to_df(data, index=index) df_target = get_target_column(df, target).to_frame() - demark = ta.td_seq(df_target[target], asint=True, show_all=True, offset=offset) + demark = ta.td_seq(df_target[target], asint=asint, show_all=show_all, offset=offset) demark_df = pd.DataFrame(demark).set_index(df_target.index).dropna() results = df_to_basemodel(df_target.join(demark_df, how="left"), index=True) From a19c60e031caa1cbd38e7d110816c7ee06f62660 Mon Sep 17 00:00:00 2001 From: Luqman Date: Tue, 3 Oct 2023 14:32:05 +0100 Subject: [PATCH 4/7] api integration test workflow --- .github/workflows/api-integration-test.yml | 79 ++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 .github/workflows/api-integration-test.yml diff --git a/.github/workflows/api-integration-test.yml b/.github/workflows/api-integration-test.yml new file mode 100644 index 00000000000..a50616a3463 --- /dev/null +++ b/.github/workflows/api-integration-test.yml @@ -0,0 +1,79 @@ +name: API Integration Tests + +on: + push: + branches: + - feature/openbb-sdk-v4 + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + api-integration-tests: + runs-on: ubuntu-latest + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + + steps: + - name: Slack Notification - Starting + uses: act10ns/slack@v1 + with: + status: starting + channel: '#workflows' + message: Starting Integration Test... + if: always() + + - name: Checkout code + uses: actions/checkout@v3 + + - name: Checkout specific ref + if: github.event_name == 'pull_request' + run: git fetch origin ${{ github.event.pull_request.head.ref }} && git checkout FETCH_HEAD + + - name: Setup Python 3.8 with venv + run: | + python -m venv obb-38 + source obb-38/bin/activate + + - name: Install Poetry and TOML + run: | + pip install poetry toml + + - name: Install obb Dependencies + run: | + python openbb_platform/dev_install.py -e + + - name: Populate Setting Files + run: | + echo '{"log_collect":false}' > ~/.openbb_platform/user_settings.json + + - name: Launch the Uvicorn Process + run: | + uvicorn openbb_core.api.rest_api:app --host 0.0.0.0 --port 8000 --reload & + + - name: Wait for 1 minute + run: | + sleep 60 + + - name: Run Integration Tests + run: | + pytest -m integration + + # - name: Upload summary to Slack + # uses: adrey/slack-file-upload-action@master + # with: + # token: ${{ secrets.SLACK_API_TOKEN }} + # initial_comment: "API Integration test summary" + # title: "Integration test summary" + # path: summary.txt + # channel: ${{ secrets.SLACK_CHANNEL_ID }} + + # - name: Slack Notification - Success/Failure + # uses: act10ns/slack@v1 + # with: + # status: ${{ job.status }} + # steps: ${{ toJson(steps) }} + # channel: '#workflows' + # if: always() From 2ccfa9a77edf466c6188a6b0ba1d6b784e85642f Mon Sep 17 00:00:00 2001 From: Luqman Date: Tue, 3 Oct 2023 14:36:20 +0100 Subject: [PATCH 5/7] minor corrections --- .github/workflows/api-integration-test.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/api-integration-test.yml b/.github/workflows/api-integration-test.yml index a50616a3463..110d8a02dd8 100644 --- a/.github/workflows/api-integration-test.yml +++ b/.github/workflows/api-integration-test.yml @@ -47,7 +47,8 @@ jobs: - name: Populate Setting Files run: | - echo '{"log_collect":false}' > ~/.openbb_platform/user_settings.json + touch ~/openbb_platform/user_settings.json + echo '{"log_collect":false}' > ~/openbb_platform/user_settings.json - name: Launch the Uvicorn Process run: | From 567010a20967e7ddd2104d11ccd963bd8cf2bee6 Mon Sep 17 00:00:00 2001 From: Luqman Date: Tue, 3 Oct 2023 14:42:39 +0100 Subject: [PATCH 6/7] Checking dir --- .github/workflows/api-integration-test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/api-integration-test.yml b/.github/workflows/api-integration-test.yml index 110d8a02dd8..0d74ad5370a 100644 --- a/.github/workflows/api-integration-test.yml +++ b/.github/workflows/api-integration-test.yml @@ -47,6 +47,7 @@ jobs: - name: Populate Setting Files run: | + pwd touch ~/openbb_platform/user_settings.json echo '{"log_collect":false}' > ~/openbb_platform/user_settings.json From 0c44b8b4e3b92afe8a7134198fdcce0d5ea234c9 Mon Sep 17 00:00:00 2001 From: Luqman Date: Tue, 3 Oct 2023 15:12:18 +0100 Subject: [PATCH 7/7] home path --- .github/workflows/api-integration-test.yml | 30 ++++++++++++++++------ 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/.github/workflows/api-integration-test.yml b/.github/workflows/api-integration-test.yml index 0d74ad5370a..3e4f2556345 100644 --- a/.github/workflows/api-integration-test.yml +++ b/.github/workflows/api-integration-test.yml @@ -32,14 +32,29 @@ jobs: if: github.event_name == 'pull_request' run: git fetch origin ${{ github.event.pull_request.head.ref }} && git checkout FETCH_HEAD - - name: Setup Python 3.8 with venv - run: | - python -m venv obb-38 - source obb-38/bin/activate + - name: Setup Python 3.8 + uses: actions/setup-python@v4 + with: + python-version: "3.8" + architecture: x64 - name: Install Poetry and TOML run: | - pip install poetry toml + pip install toml + + - name: Install Poetry + uses: snok/install-poetry@v1 + with: + version: 1.4.0 + virtualenvs-create: true + virtualenvs-in-project: true + + - name: Load cached venv + id: cached-poetry-dependencies + uses: actions/cache@v3 + with: + path: .venv + key: venv-${{ runner.os }}-v1-${{ hashFiles('**/poetry.lock') }} - name: Install obb Dependencies run: | @@ -47,9 +62,8 @@ jobs: - name: Populate Setting Files run: | - pwd - touch ~/openbb_platform/user_settings.json - echo '{"log_collect":false}' > ~/openbb_platform/user_settings.json + touch $HOME/openbb_platform/user_settings.json + echo '{"log_collect":false}' > $HOME/openbb_platform/user_settings.json - name: Launch the Uvicorn Process run: |