From 4afff79e4421a148916047f7c940cd29e81e9db6 Mon Sep 17 00:00:00 2001 From: Danglewood <85772166+deeleeramone@users.noreply.github.com> Date: Wed, 3 Jul 2024 11:47:00 -0700 Subject: [PATCH 1/2] fix pkg_resources not in Python 3.9 --- .../core/openbb_core/app/version.py | 20 ++++++++-------- openbb_platform/openbb/assets/reference.json | 23 +++++++++++-------- openbb_platform/openbb/package/economy.py | 2 +- .../oecd/openbb_oecd/models/unemployment.py | 19 ++++----------- 4 files changed, 31 insertions(+), 33 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/version.py b/openbb_platform/core/openbb_core/app/version.py index 39872d98a1c2..c49232ed6e64 100644 --- a/openbb_platform/core/openbb_core/app/version.py +++ b/openbb_platform/core/openbb_core/app/version.py @@ -2,10 +2,12 @@ import shutil import subprocess +from importlib.metadata import ( + PackageNotFoundError, + version as pkg_version, +) from pathlib import Path -import pkg_resources - PACKAGE = "openbb" @@ -13,15 +15,15 @@ def get_package_version(package: str): """Retrieve the version of a package from installed pip packages.""" is_nightly = False try: - version = pkg_resources.get_distribution(package).version - except pkg_resources.DistributionNotFound: + version = pkg_version(package) + except PackageNotFoundError: package += "-nightly" is_nightly = True try: - version = pkg_resources.get_distribution(package).version - except pkg_resources.DistributionNotFound: + version = pkg_version(package) + except PackageNotFoundError: package = "openbb-core" - version = pkg_resources.get_distribution(package).version + version = pkg_version(package) version += "core" if is_git_repo(Path(__file__).parent.resolve()) and not is_nightly: @@ -56,10 +58,10 @@ def get_major_minor(version: str) -> tuple[int, int]: try: VERSION = get_package_version(PACKAGE) -except pkg_resources.DistributionNotFound: +except PackageNotFoundError: VERSION = "unknown" try: CORE_VERSION = get_package_version("openbb-core") -except pkg_resources.DistributionNotFound: +except PackageNotFoundError: CORE_VERSION = "unknown" diff --git a/openbb_platform/openbb/assets/reference.json b/openbb_platform/openbb/assets/reference.json index 9139dd5420c1..28947a0e5980 100644 --- a/openbb_platform/openbb/assets/reference.json +++ b/openbb_platform/openbb/assets/reference.json @@ -3,7 +3,7 @@ "info": { "title": "OpenBB Platform (Python)", "description": "Investment research for everyone, anywhere.", - "core": "1.2.7", + "core": "1.2.9", "extensions": { "openbb_core_extension": [ "commodity@1.1.3", @@ -2443,8 +2443,8 @@ }, { "name": "date", - "type": "Union[date, str]", - "description": "A specific date to get data for.", + "type": "Union[Union[Union[str, date], str], List[Union[Union[str, date], str]]]", + "description": "A specific date to get data for. Multiple items allowed for provider(s): yfinance.", "default": null, "optional": true, "choices": null @@ -2490,6 +2490,14 @@ }, "data": { "standard": [ + { + "name": "date", + "type": "date", + "description": "The date of the data.", + "default": null, + "optional": true, + "choices": null + }, { "name": "expiration", "type": "str", @@ -2501,7 +2509,7 @@ { "name": "price", "type": "float", - "description": "The close price.", + "description": "The price of the futures contract.", "default": null, "optional": true, "choices": null @@ -5374,17 +5382,14 @@ }, { "name": "age", - "type": "Literal['total', '15-24', '25-54', '55-64', '15-64', '15-74']", + "type": "Literal['total', '15-24', '25+']", "description": "Age group to get unemployment for. Total indicates 15 years or over", "default": "total", "optional": true, "choices": [ "total", "15-24", - "25-54", - "55-64", - "15-64", - "15-74" + "25+" ] }, { diff --git a/openbb_platform/openbb/package/economy.py b/openbb_platform/openbb/package/economy.py index e6719909149e..65befb797d20 100644 --- a/openbb_platform/openbb/package/economy.py +++ b/openbb_platform/openbb/package/economy.py @@ -2187,7 +2187,7 @@ def unemployment( The provider to use, by default None. If None, the priority list configured in the settings is used. Default priority: oecd. sex : Literal['total', 'male', 'female'] Sex to get unemployment for. (provider: oecd) - age : Literal['total', '15-24', '25-54', '55-64', '15-64', '15-74'] + age : Literal['total', '15-24', '25+'] Age group to get unemployment for. Total indicates 15 years or over (provider: oecd) seasonal_adjustment : bool Whether to get seasonally adjusted unemployment. Defaults to False. (provider: oecd) diff --git a/openbb_platform/providers/oecd/openbb_oecd/models/unemployment.py b/openbb_platform/providers/oecd/openbb_oecd/models/unemployment.py index 236513430d2b..e7219e92ac05 100644 --- a/openbb_platform/providers/oecd/openbb_oecd/models/unemployment.py +++ b/openbb_platform/providers/oecd/openbb_oecd/models/unemployment.py @@ -29,18 +29,12 @@ AGES = [ "total", "15-24", - "25-54", - "55-64", - "15-64", - "15-74", + "25+", ] AgesLiteral = Literal[ "total", "15-24", - "25-54", - "55-64", - "15-64", - "15-74", + "25+", ] @@ -55,7 +49,7 @@ class OECDUnemploymentQueryParams(UnemploymentQueryParams): country: str = Field( description=QUERY_DESCRIPTIONS.get("country", ""), default="united_states", - choices=CountriesList, + json_schema_extra={"choices":CountriesList}, # type: ignore ) sex: Literal["total", "male", "female"] = Field( description="Sex to get unemployment for.", @@ -65,7 +59,7 @@ class OECDUnemploymentQueryParams(UnemploymentQueryParams): age: Literal[AgesLiteral] = Field( description="Age group to get unemployment for. Total indicates 15 years or over", default="total", - json_schema_extra={"choices": AGES}, + json_schema_extra={"choices": AGES}, # type: ignore ) seasonal_adjustment: bool = Field( description="Whether to get seasonally adjusted unemployment. Defaults to False.", @@ -131,10 +125,7 @@ def extract_data( age = { "total": "Y_GE15", "15-24": "Y15T24", - "15-64": "Y15T64", - "15-74": "Y15T74", - "25-54": "Y25T54", - "55-64": "Y55T64", + "25+": "Y_GE25", }[query.age] seasonal_adjustment = "Y" if query.seasonal_adjustment else "N" From 65bb9874519a3164cbc276e3625f25a4583c064e Mon Sep 17 00:00:00 2001 From: Danglewood <85772166+deeleeramone@users.noreply.github.com> Date: Wed, 3 Jul 2024 11:57:11 -0700 Subject: [PATCH 2/2] black --- .../providers/oecd/openbb_oecd/models/unemployment.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openbb_platform/providers/oecd/openbb_oecd/models/unemployment.py b/openbb_platform/providers/oecd/openbb_oecd/models/unemployment.py index e7219e92ac05..5641c9671887 100644 --- a/openbb_platform/providers/oecd/openbb_oecd/models/unemployment.py +++ b/openbb_platform/providers/oecd/openbb_oecd/models/unemployment.py @@ -49,7 +49,7 @@ class OECDUnemploymentQueryParams(UnemploymentQueryParams): country: str = Field( description=QUERY_DESCRIPTIONS.get("country", ""), default="united_states", - json_schema_extra={"choices":CountriesList}, # type: ignore + json_schema_extra={"choices": CountriesList}, # type: ignore ) sex: Literal["total", "male", "female"] = Field( description="Sex to get unemployment for.",