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] Fix OECD Unemployment Age Brackets & Fix No module named 'pkg_resources' #6563

Merged
merged 4 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions openbb_platform/core/openbb_core/app/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,28 @@

import shutil
import subprocess
from importlib.metadata import (
PackageNotFoundError,
version as pkg_version,
)
from pathlib import Path

import pkg_resources

PACKAGE = "openbb"


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:
Expand Down Expand Up @@ -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"
23 changes: 14 additions & 9 deletions openbb_platform/openbb/assets/reference.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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",
Expand All @@ -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
Expand Down Expand Up @@ -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+"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion openbb_platform/openbb/package/economy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
19 changes: 5 additions & 14 deletions openbb_platform/providers/oecd/openbb_oecd/models/unemployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -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+",
]


Expand All @@ -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.",
Expand All @@ -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.",
Expand Down Expand Up @@ -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"

Expand Down
Loading