mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-30 22:11:55 +00:00
Merge branch 'feature/openbb-sdk-v4' into feature/integration-testing
This commit is contained in:
113
.github/workflows/api-integration-test.yml
vendored
113
.github/workflows/api-integration-test.yml
vendored
@@ -17,65 +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 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.8
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: "3.8"
|
||||
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 and TOML
|
||||
run: |
|
||||
pip install toml
|
||||
- name: Setup Python 3.9
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: "3.9"
|
||||
architecture: x64
|
||||
|
||||
- name: Install Poetry
|
||||
uses: snok/install-poetry@v1
|
||||
with:
|
||||
version: 1.4.0
|
||||
virtualenvs-create: true
|
||||
virtualenvs-in-project: true
|
||||
- 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 Python Dependencies
|
||||
run: |
|
||||
pip install toml pytest uvicorn importlib-metadata
|
||||
|
||||
- name: Install obb Dependencies
|
||||
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 Setting Files
|
||||
run: |
|
||||
touch $HOME/openbb_platform/user_settings.json
|
||||
echo '{"log_collect":false}' > $HOME/openbb_platform/user_settings.json
|
||||
- name: Install obb Dependencies
|
||||
# if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
|
||||
run: |
|
||||
python openbb_platform/dev_install.py -e
|
||||
|
||||
- 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
|
||||
|
||||
@@ -187,22 +187,21 @@ 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:
|
||||
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)
|
||||
try:
|
||||
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:
|
||||
pass
|
||||
|
||||
return implemented_functions
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user