From 72effc05d699bc874335f73d9d079be20a564c27 Mon Sep 17 00:00:00 2001 From: Luqman Date: Tue, 3 Oct 2023 15:33:57 +0100 Subject: [PATCH 1/9] minor fix --- .github/workflows/api-integration-test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/api-integration-test.yml b/.github/workflows/api-integration-test.yml index 3e4f2556345..ad2fc2dad27 100644 --- a/.github/workflows/api-integration-test.yml +++ b/.github/workflows/api-integration-test.yml @@ -62,8 +62,8 @@ jobs: - name: Populate Setting Files run: | - touch $HOME/openbb_platform/user_settings.json - echo '{"log_collect":false}' > $HOME/openbb_platform/user_settings.json + touch ${{ github.workspace }}/openbb_platform/user_settings.json + echo '{"log_collect":false}' > ${{ github.workspace }}/openbb_platform/user_settings.json - name: Launch the Uvicorn Process run: | From f0278890d7f7c5971a41470a5ddfc62d50a7c500 Mon Sep 17 00:00:00 2001 From: Henrique Joaquim Date: Tue, 3 Oct 2023 15:59:26 +0100 Subject: [PATCH 2/9] try except ftw (#5512) --- .../platform/core/openbb_core/app/charting_service.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openbb_platform/platform/core/openbb_core/app/charting_service.py b/openbb_platform/platform/core/openbb_core/app/charting_service.py index f067d167192..c7fc8d75e66 100644 --- a/openbb_platform/platform/core/openbb_core/app/charting_service.py +++ b/openbb_platform/platform/core/openbb_core/app/charting_service.py @@ -188,9 +188,9 @@ class ChartingService(metaclass=SingletonMeta): Given an extension name, it returns the implemented charting functions from its router. """ - module = cls._get_extension_router(extension_name) - - if not module: + try: + module = cls._get_extension_router(extension_name) + except ChartingServiceError: return [] implemented_functions = [] From daeb804107b96902fc9771b41db9ec315f7a3166 Mon Sep 17 00:00:00 2001 From: Luqman Date: Tue, 3 Oct 2023 16:06:32 +0100 Subject: [PATCH 3/9] fixes --- .github/workflows/api-integration-test.yml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/api-integration-test.yml b/.github/workflows/api-integration-test.yml index ad2fc2dad27..10e167b32ab 100644 --- a/.github/workflows/api-integration-test.yml +++ b/.github/workflows/api-integration-test.yml @@ -32,16 +32,12 @@ 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 + - name: Setup Python 3.9 uses: actions/setup-python@v4 with: - python-version: "3.8" + python-version: "3.9" architecture: x64 - - name: Install Poetry and TOML - run: | - pip install toml - - name: Install Poetry uses: snok/install-poetry@v1 with: @@ -49,14 +45,19 @@ jobs: virtualenvs-create: true virtualenvs-in-project: true + - name: Install Python Dependencies + run: | + pip install toml pytest uvicorn + - name: Load cached venv id: cached-poetry-dependencies uses: actions/cache@v3 with: path: .venv - key: venv-${{ runner.os }}-v1-${{ hashFiles('**/poetry.lock') }} + key: venv-${{ runner.os }}-v1-${{ hashFiles('**/poetry.lock', '**/dev_install.py') }} - name: Install obb Dependencies + if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' run: | python openbb_platform/dev_install.py -e From d834256ac5aa105a00c6bcc4d69f73b5cc3f3ab9 Mon Sep 17 00:00:00 2001 From: Luqman Date: Tue, 3 Oct 2023 16:42:13 +0100 Subject: [PATCH 4/9] Created system setting files --- .github/workflows/api-integration-test.yml | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/.github/workflows/api-integration-test.yml b/.github/workflows/api-integration-test.yml index 10e167b32ab..e865b85971a 100644 --- a/.github/workflows/api-integration-test.yml +++ b/.github/workflows/api-integration-test.yml @@ -61,11 +61,24 @@ jobs: run: | python openbb_platform/dev_install.py -e - - name: Populate Setting Files + - name: Populate System Setting Files + run: | + touch ${{ github.workspace }}/openbb_platform/system_settings.json + echo '{"log_collect":false}' > ${{ github.workspace }}/openbb_platform/system_settings.json + + - name: Create and Populate user_settings.json from GitHub Secrets run: | touch ${{ github.workspace }}/openbb_platform/user_settings.json - echo '{"log_collect":false}' > ${{ github.workspace }}/openbb_platform/user_settings.json - + echo '{ + "credentials": { + "benzinga_api_key": ${{ secrets.BENZINGA_API_KEY }}, + "fmp_api_key": "${{ secrets.FMP_API_KEY }}", + "polygon_api_key": "${{ secrets.POLYGON_API_KEY }}", + "alpha_vantage_api_key": "${{ secrets.ALPHA_VANTAGE_API_KEY }}", + "fred_api_key": "${{ secrets.FRED_API_KEY }}" + } + }' > ${{ github.workspace }}/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 & From 6fafb824e85b502f89f808e1f2186626b800a5fa Mon Sep 17 00:00:00 2001 From: Luqman Date: Tue, 3 Oct 2023 17:03:51 +0100 Subject: [PATCH 5/9] create system settings --- .github/workflows/api-integration-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/api-integration-test.yml b/.github/workflows/api-integration-test.yml index e865b85971a..fe4f5e6d935 100644 --- a/.github/workflows/api-integration-test.yml +++ b/.github/workflows/api-integration-test.yml @@ -22,7 +22,7 @@ jobs: with: status: starting channel: '#workflows' - message: Starting Integration Test... + message: Starting API Integration Test... if: always() - name: Checkout code From 438af3148c3ca7719a3150e3ced88a44d2c4be88 Mon Sep 17 00:00:00 2001 From: Luqman Date: Tue, 3 Oct 2023 18:25:36 +0100 Subject: [PATCH 6/9] fix trial --- .github/workflows/api-integration-test.yml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/api-integration-test.yml b/.github/workflows/api-integration-test.yml index fe4f5e6d935..4d0fbdf6635 100644 --- a/.github/workflows/api-integration-test.yml +++ b/.github/workflows/api-integration-test.yml @@ -49,26 +49,26 @@ jobs: run: | pip install toml pytest uvicorn - - name: Load cached venv - id: cached-poetry-dependencies - uses: actions/cache@v3 - with: - path: .venv - key: venv-${{ runner.os }}-v1-${{ hashFiles('**/poetry.lock', '**/dev_install.py') }} + # - name: Load cached venv + # id: cached-poetry-dependencies + # uses: actions/cache@v3 + # with: + # path: .venv + # key: venv-${{ runner.os }}-v1-${{ hashFiles('**/poetry.lock', '**/dev_install.py') }} - name: Install obb Dependencies - if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' + # if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' run: | python openbb_platform/dev_install.py -e - name: Populate System Setting Files run: | - touch ${{ github.workspace }}/openbb_platform/system_settings.json - echo '{"log_collect":false}' > ${{ github.workspace }}/openbb_platform/system_settings.json + touch ${{ github.workspace }}/.openbb_platform/system_settings.json + echo '{"log_collect":false}' > ${{ github.workspace }}/.openbb_platform/system_settings.json - name: Create and Populate user_settings.json from GitHub Secrets run: | - touch ${{ github.workspace }}/openbb_platform/user_settings.json + touch ${{ github.workspace }}/.openbb_platform/user_settings.json echo '{ "credentials": { "benzinga_api_key": ${{ secrets.BENZINGA_API_KEY }}, @@ -77,7 +77,7 @@ jobs: "alpha_vantage_api_key": "${{ secrets.ALPHA_VANTAGE_API_KEY }}", "fred_api_key": "${{ secrets.FRED_API_KEY }}" } - }' > ${{ github.workspace }}/openbb_platform/user_settings.json + }' > ${{ github.workspace }}/.openbb_platform/user_settings.json - name: Launch the Uvicorn Process run: | From 0394dc7d2fa17a28ac7aa2f0dd29791d5492f91f Mon Sep 17 00:00:00 2001 From: Luqman Date: Tue, 3 Oct 2023 18:33:00 +0100 Subject: [PATCH 7/9] created hidden directory --- .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 4d0fbdf6635..b84bcf4e1a3 100644 --- a/.github/workflows/api-integration-test.yml +++ b/.github/workflows/api-integration-test.yml @@ -63,6 +63,7 @@ jobs: - name: Populate System Setting Files run: | + mkdir -p ${{ github.workspace }}/.openbb_platform touch ${{ github.workspace }}/.openbb_platform/system_settings.json echo '{"log_collect":false}' > ${{ github.workspace }}/.openbb_platform/system_settings.json From 798b0496371643012e1e90dbd3d12df0f34ffa2e Mon Sep 17 00:00:00 2001 From: hjoaquim Date: Tue, 3 Oct 2023 18:37:42 +0100 Subject: [PATCH 8/9] fix charting_service tests --- .../core/openbb_core/app/charting_service.py | 25 +++++++++---------- .../core/tests/app/test_charting_service.py | 10 +++++--- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/openbb_platform/platform/core/openbb_core/app/charting_service.py b/openbb_platform/platform/core/openbb_core/app/charting_service.py index c7fc8d75e66..13a8d80999e 100644 --- a/openbb_platform/platform/core/openbb_core/app/charting_service.py +++ b/openbb_platform/platform/core/openbb_core/app/charting_service.py @@ -187,22 +187,21 @@ class ChartingService(metaclass=SingletonMeta): """ Given an extension name, it returns the implemented charting functions from its router. """ + implemented_functions = [] try: - module = cls._get_extension_router(extension_name) + if module := cls._get_extension_router(extension_name): + module_name = module.__name__ + + for name, obj in getmembers(module, isfunction): + if ( + obj.__module__ == module_name + and not name.startswith("_") + and "NotImplementedError" not in getsource(obj) + ): + implemented_functions.append(name) except ChartingServiceError: - return [] - - implemented_functions = [] - module_name = module.__name__ - - for name, obj in getmembers(module, isfunction): - if ( - obj.__module__ == module_name - and not name.startswith("_") - and "NotImplementedError" not in getsource(obj) - ): - implemented_functions.append(name) + pass return implemented_functions diff --git a/openbb_platform/platform/core/tests/app/test_charting_service.py b/openbb_platform/platform/core/tests/app/test_charting_service.py index 0f054cd5b97..3b1354a756f 100644 --- a/openbb_platform/platform/core/tests/app/test_charting_service.py +++ b/openbb_platform/platform/core/tests/app/test_charting_service.py @@ -272,17 +272,18 @@ def test_get_implemented_charting_functions( @pytest.mark.parametrize( - "charting_extension_installed, expected_result", - [(True, ...), (False, ChartingServiceError)], + "charting_extension_installed", + [(True), (False)], ) @patch("openbb_core.app.charting_service.ChartingService._handle_backend") @patch("openbb_core.app.charting_service.import_module") +@patch("openbb_core.app.charting_service.ChartingService._get_chart_format") def test_to_chart( + mock_get_chart_format, mock_import_module, mock_handle_backend, charting_service, charting_extension_installed, - expected_result, ): charting_service._charting_extension_installed = charting_extension_installed @@ -294,8 +295,9 @@ def test_to_chart( return ("mock_fig", {"content": "mock_content"}) mock_import_module.return_value = MockBackendModule() + mock_get_chart_format.return_value = "plotly" - if expected_result != ChartingServiceError: + if charting_extension_installed: result = charting_service.to_chart() assert isinstance(result, Chart) From 01c9c7478dd4c1da686118b3a8c1bbbb30801e71 Mon Sep 17 00:00:00 2001 From: hjoaquim Date: Tue, 3 Oct 2023 18:48:43 +0100 Subject: [PATCH 9/9] adding importlib-metadata to the pip install --- .github/workflows/api-integration-test.yml | 128 ++++++++++----------- 1 file changed, 64 insertions(+), 64 deletions(-) diff --git a/.github/workflows/api-integration-test.yml b/.github/workflows/api-integration-test.yml index b84bcf4e1a3..313b65ea060 100644 --- a/.github/workflows/api-integration-test.yml +++ b/.github/workflows/api-integration-test.yml @@ -17,80 +17,80 @@ jobs: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} steps: - - name: Slack Notification - Starting - uses: act10ns/slack@v1 - with: - status: starting - channel: '#workflows' - message: Starting API Integration Test... - if: always() + - name: Slack Notification - Starting + uses: act10ns/slack@v1 + with: + status: starting + channel: "#workflows" + message: Starting API Integration Test... + if: always() - - name: Checkout code - uses: actions/checkout@v3 + - 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.9 - uses: actions/setup-python@v4 - with: - python-version: "3.9" - architecture: x64 + - 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: Install Poetry - uses: snok/install-poetry@v1 - with: - version: 1.4.0 - virtualenvs-create: true - virtualenvs-in-project: true + - name: Setup Python 3.9 + uses: actions/setup-python@v4 + with: + python-version: "3.9" + architecture: x64 - - name: Install Python Dependencies - run: | - pip install toml pytest uvicorn + - 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', '**/dev_install.py') }} + - name: Install Python Dependencies + run: | + pip install toml pytest uvicorn importlib-metadata - - name: Install obb Dependencies - # if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' - run: | - python openbb_platform/dev_install.py -e + # - name: Load cached venv + # id: cached-poetry-dependencies + # uses: actions/cache@v3 + # with: + # path: .venv + # key: venv-${{ runner.os }}-v1-${{ hashFiles('**/poetry.lock', '**/dev_install.py') }} - - name: Populate System Setting Files - run: | - mkdir -p ${{ github.workspace }}/.openbb_platform - touch ${{ github.workspace }}/.openbb_platform/system_settings.json - echo '{"log_collect":false}' > ${{ github.workspace }}/.openbb_platform/system_settings.json + - name: Install obb Dependencies + # if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' + run: | + python openbb_platform/dev_install.py -e - - name: Create and Populate user_settings.json from GitHub Secrets - run: | - touch ${{ github.workspace }}/.openbb_platform/user_settings.json - echo '{ - "credentials": { - "benzinga_api_key": ${{ secrets.BENZINGA_API_KEY }}, - "fmp_api_key": "${{ secrets.FMP_API_KEY }}", - "polygon_api_key": "${{ secrets.POLYGON_API_KEY }}", - "alpha_vantage_api_key": "${{ secrets.ALPHA_VANTAGE_API_KEY }}", - "fred_api_key": "${{ secrets.FRED_API_KEY }}" - } - }' > ${{ github.workspace }}/.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: Populate System Setting Files + run: | + mkdir -p ${{ github.workspace }}/.openbb_platform + touch ${{ github.workspace }}/.openbb_platform/system_settings.json + echo '{"log_collect":false}' > ${{ github.workspace }}/.openbb_platform/system_settings.json - - name: Wait for 1 minute - run: | - sleep 60 + - name: Create and Populate user_settings.json from GitHub Secrets + run: | + touch ${{ github.workspace }}/.openbb_platform/user_settings.json + echo '{ + "credentials": { + "benzinga_api_key": ${{ secrets.BENZINGA_API_KEY }}, + "fmp_api_key": "${{ secrets.FMP_API_KEY }}", + "polygon_api_key": "${{ secrets.POLYGON_API_KEY }}", + "alpha_vantage_api_key": "${{ secrets.ALPHA_VANTAGE_API_KEY }}", + "fred_api_key": "${{ secrets.FRED_API_KEY }}" + } + }' > ${{ github.workspace }}/.openbb_platform/user_settings.json - - name: Run Integration Tests - run: | - pytest -m integration + - 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