comment debug stuff

This commit is contained in:
hjoaquim
2024-03-15 11:22:21 +00:00
parent 4a10f395e2
commit f0a86f04a8
5 changed files with 59 additions and 10 deletions

View File

@@ -503,16 +503,16 @@ class ArgparseTranslator:
return wrapper_func
from openbb import obb
# from openbb import obb
ref_processor = ReferenceToCustomArgumentsProcessor(obb.coverage.reference)
# ref_processor = ReferenceToCustomArgumentsProcessor(obb.coverage.reference)
ref_equity_price_historical = ref_processor.custom_groups["/equity/price/historical"]
# ref_equity_price_historical = ref_processor.custom_groups["/equity/price/historical"]
translator = ArgparseTranslator(
obb.equity.price.historical, ref_equity_price_historical
)
equity_historical_price = translator.translate()
result = equity_historical_price()
print(result)
# translator = ArgparseTranslator(
# obb.equity.price.historical, ref_equity_price_historical
# )
# equity_historical_price = translator.translate()
# result = equity_historical_price()
# print(result)

View File

@@ -2,7 +2,6 @@
from pathlib import Path
ASSETS_DIRECTORY = Path(__file__).parent / "assets"
HOME_DIRECTORY = Path.home()
OPENBB_DIRECTORY = Path(HOME_DIRECTORY, ".openbb_platform")
USER_SETTINGS_PATH = Path(OPENBB_DIRECTORY, "user_settings.json")

View File

@@ -5,6 +5,7 @@ from typing import TYPE_CHECKING, Any, Dict, List, Optional
from openbb_core.api.router.helpers.coverage_helpers import get_route_schema_map
from openbb_core.app.provider_interface import ProviderInterface
from openbb_core.app.router import CommandMap
from openbb_core.app.static.reference_loader import ReferenceLoader
if TYPE_CHECKING:
from openbb_core.app.static.app_factory import BaseApp
@@ -26,6 +27,7 @@ class Coverage:
self._app = app
self._command_map = CommandMap(coverage_sep=".")
self._provider_interface = ProviderInterface()
self._reference_loader = ReferenceLoader()
def __repr__(self) -> str:
"""Return docstring."""
@@ -49,6 +51,11 @@ class Coverage:
for command, value in self._command_map.commands_model.items()
}
@property
def reference(self) -> Dict[str, Dict]:
"""Return reference data."""
return self._reference_loader.reference
def command_schemas(self, filter_by_provider: Optional[str] = None):
"""Return route schema for a command."""
return get_route_schema_map(

View File

@@ -0,0 +1,41 @@
"""ReferenceLoader class for loading reference data from a file."""
import json
from pathlib import Path
from typing import Dict, Optional
from openbb_core.app.model.abstract.singleton import SingletonMeta
class ReferenceLoader(metaclass=SingletonMeta):
def __init__(self, directory: Optional[Path] = None):
"""
Initialize the ReferenceLoader with a specific directory.
If no directory is provided, a default directory will be used.
Attributes
----------
directory : Optional[Path]
The directory from which to load the assets where the reference file lives.
"""
self.directory = directory or directory or self._get_default_directory()
self._reference = self._load(self.directory / "assets" / "reference.json")
@property
def reference(self) -> Dict[str, Dict]:
"""Get the reference data."""
return self._reference
def _get_default_directory(self) -> Path:
"""Get the default directory for loading references."""
return Path(__file__).parents[4].resolve() / "openbb"
def _load(self, file_path: Path):
"""Load the reference data from a file."""
try:
with open(file_path) as f:
data = json.load(f)
except FileNotFoundError:
data = {}
return data

View File

@@ -10,6 +10,7 @@ from openbb_core.app.static.app_factory import (
create_app as _create_app,
)
from openbb_core.app.static.package_builder import PackageBuilder as _PackageBuilder
from openbb_core.app.static.reference_loader import ReferenceLoader as _ReferenceLoader
_this_dir = Path(__file__).parent.resolve()
@@ -36,6 +37,7 @@ def build(
_PackageBuilder(_this_dir).auto_build()
_ReferenceLoader(_this_dir)
try:
# pylint: disable=import-outside-toplevel