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

[BugFix] Release fixes #6560

Merged
merged 13 commits into from
Jul 2, 2024
4 changes: 2 additions & 2 deletions .github/scripts/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
CLI_TESTS = CLI_DIR / "tests"


@nox.session(python=["3.9", "3.10", "3.11"])
@nox.session(python=["3.9", "3.10", "3.11", "3.12"])
def unit_test_platform(session):
"""Run the test suite."""
session.install("poetry", "toml")
Expand All @@ -31,7 +31,7 @@ def unit_test_platform(session):
)


@nox.session(python=["3.9", "3.10", "3.11"])
@nox.session(python=["3.9", "3.10", "3.11", "3.12"])
def unit_test_cli(session):
"""Run the test suite."""
session.install("poetry", "toml")
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-unit-cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:

matrix:
python_version:
["3.9", "3.10", "3.11"]
["3.9", "3.10", "3.11", "3.12"]
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-unit-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:

matrix:
python_version:
["3.9", "3.10", "3.11"]
["3.9", "3.10", "3.11", "3.12"]
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def wrapper(*f_args, **f_kwargs):
while tb.tb_next is not None:
tb = tb.tb_next

if isinstance(e, ValidationError):
if isinstance(e, ValidationError) and "Data" not in e.title:
error_list = []
validation_error = f"{e.error_count()} validations error(s)"
for err in e.errors(include_url=False):
Expand Down
17 changes: 7 additions & 10 deletions openbb_platform/core/tests/app/test_command_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,14 +254,12 @@ def test_parameters_builder_build(mock_func, execution_context):
}


@patch("openbb_core.app.command_runner.LoggingService")
def test_command_runner(_):
def test_command_runner():
"""Test command runner."""
assert CommandRunner()


@patch("openbb_core.app.command_runner.LoggingService")
def test_command_runner_properties(mock_logging_service):
def test_command_runner_properties():
"""Test properties."""
sys = SystemSettings()
user = UserSettings()
Expand All @@ -272,7 +270,6 @@ def test_command_runner_properties(mock_logging_service):
assert runner.system_settings == sys
assert runner.user_settings == user
assert runner.command_map == cmd_map
assert mock_logging_service.called_once()


@patch("openbb_core.app.command_runner.LoggingService")
Expand Down Expand Up @@ -353,14 +350,14 @@ def __init__(self, results):
mock_chart.return_value = None

result = await StaticCommandRunner._execute_func(
"mock/route", (1, 2, 3, 4), execution_context, mock_func, {}
"mock/route", (1, 2, 3, 4), execution_context, mock_func, {"chart": True}
)

assert result.results == [1, 2, 3, 4]
assert mock_logging_service.called_once()
assert mock_parameters_builder_build.called_once()
assert mock_command.called_once()
assert mock_chart.called_once()
mock_logging_service.assert_called_once()
mock_parameters_builder_build.assert_called_once()
mock_command.assert_called_once()
mock_chart.assert_called_once()


def test_static_command_runner_chart():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def test_derivatives_futures_historical(params, headers):
{
"provider": "cboe",
"symbol": "VX_EOD",
"date": None,
"date": "2024-06-25",
}
),
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def test_derivatives_futures_historical(params, obb):
"params",
[
({"provider": "yfinance", "symbol": "ES", "date": None}),
({"provider": "cboe", "symbol": "VX", "date": None}),
({"provider": "cboe", "symbol": "VX", "date": "2024-06-25"}),
],
)
@pytest.mark.integration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ async def historical(
@router.command(
model="FuturesCurve",
examples=[
APIEx(parameters={"symbol": "VX", "provider": "cboe"}),
APIEx(parameters={"symbol": "VX", "provider": "cboe", "date": "2024-06-25"}),
APIEx(
description="Enter a date to get the term structure from a historical date.",
parameters={"symbol": "NG", "provider": "yfinance", "date": "2023-01-01"},
Expand Down
35 changes: 29 additions & 6 deletions openbb_platform/extensions/tests/utils/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
import re
from ast import AsyncFunctionDef, Call, FunctionDef, Name, parse, unparse
from dataclasses import dataclass
from importlib.metadata import entry_points
from importlib.metadata import EntryPoint, entry_points
from inspect import getmembers, isfunction
from typing import Any, Dict, List, Optional, Set, Tuple
from sys import version_info
from typing import Any, Dict, List, Optional, Set, Tuple, Union

from importlib_metadata import EntryPoints
from openbb_core.app.provider_interface import ProviderInterface

pi = ProviderInterface()
Expand Down Expand Up @@ -68,12 +70,18 @@ def check_docstring_examples() -> List[str]:
return errors


def filter_eps(eps: Union[EntryPoints, dict], group: str) -> Tuple[EntryPoint, ...]:
if version_info[:2] == (3, 12):
return eps.select(group=group) or () # type: ignore[union-attr]
return eps.get(group, ()) # type: ignore[union-attr]


def list_openbb_extensions() -> Tuple[Set[str], Set[str], Set[str]]:
"""List installed openbb extensions and providers.

Returns
-------
Tuple[Set[str], Set[str]]
Tuple[Set[str], Set[str], Set[str]]
First element: set of installed core extensions.
Second element: set of installed provider extensions.
Third element: set of installed obbject extensions.
Expand All @@ -82,15 +90,30 @@ def list_openbb_extensions() -> Tuple[Set[str], Set[str], Set[str]]:
core_extensions = set()
provider_extensions = set()
obbject_extensions = set()

entry_points_dict = entry_points()

for entry_point in entry_points_dict.get("openbb_core_extension", []):
# Compatibility for different Python versions
if hasattr(entry_points_dict, "select"): # Python 3.12+
core_entry_points = entry_points_dict.select(group="openbb_core_extension")
provider_entry_points = entry_points_dict.select(
group="openbb_provider_extension"
)
obbject_entry_points = entry_points_dict.select(
group="openbb_obbject_extension"
)
else:
core_entry_points = entry_points_dict.get("openbb_core_extension", [])
provider_entry_points = entry_points_dict.get("openbb_provider_extension", [])
obbject_entry_points = entry_points_dict.get("openbb_obbject_extension", [])

for entry_point in core_entry_points:
core_extensions.add(f"{entry_point.name}")

for entry_point in entry_points_dict.get("openbb_provider_extension", []):
for entry_point in provider_entry_points:
provider_extensions.add(f"{entry_point.name}")

for entry_point in entry_points_dict.get("openbb_obbject_extension", []):
for entry_point in obbject_entry_points:
obbject_extensions.add(f"{entry_point.name}")

return core_extensions, provider_extensions, obbject_extensions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,7 @@ def test_charting_derivatives_futures_historical(params, obb):
{
"provider": "cboe",
"symbol": "VX",
"date": "2024-06-25",
}
),
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ def apply_contract_symbol(x):
strike = f"{front}{_strike[0]}{_strike[1]}{back}"
return symbol + exp + cp + strike

if symbols.str.contains("\.").any(): # noqa # pylint: disable=W1401
if symbols.str.contains(r"\.").any(): # noqa # pylint: disable=W1401
df["contract_symbol"] = df["contract_symbol"].apply(apply_contract_symbol)
else:
df["contract_symbol"] = symbols.str.replace("_", "")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,9 @@ def transform_data( # pylint: disable=too-many-locals, too-many-statements
for item in filtered_data:
new_item = {}
new_item["base_currency"] = item.get("base_currency")
new_item["counter_currency"] = item.get("counter_currency")
new_item["counter_currency"] = item.get("counter_currency") or item.get(
"index"
)
new_item["change"] = item.get("todaysChange", None)
change_percent = item.get("todaysChangePerc", None)
new_item["change_percent"] = (
Expand Down
Loading