From ce5b93ae4e45f788575267ae6be7a7fd1c66afa9 Mon Sep 17 00:00:00 2001 From: James Maslek Date: Thu, 3 Aug 2023 19:59:51 -0400 Subject: [PATCH] Custom args to package builder (#5282) --- openbb_sdk/openbb/__init__.py | 5 +++-- .../sdk/core/openbb_core/app/static/package_builder.py | 9 ++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/openbb_sdk/openbb/__init__.py b/openbb_sdk/openbb/__init__.py index 0e24835e31f0..fcb01a25b338 100644 --- a/openbb_sdk/openbb/__init__.py +++ b/openbb_sdk/openbb/__init__.py @@ -1,14 +1,15 @@ # flake8: noqa +from typing import List from openbb_core.app.static.app_factory import create_app as __create_app sdk = __create_app() obb = sdk -def _rebuild_python_interface() -> None: +def _rebuild_python_interface(*args, lint=True) -> None: """Rebuild the Python SDK.""" from openbb_core.app.static.package_builder import ( # pylint: disable=import-outside-toplevel PackageBuilder, ) - PackageBuilder.build() + PackageBuilder.build(modules=list(args), lint = lint) diff --git a/openbb_sdk/sdk/core/openbb_core/app/static/package_builder.py b/openbb_sdk/sdk/core/openbb_core/app/static/package_builder.py index 1018dd4346c3..f557763e7ed0 100644 --- a/openbb_sdk/sdk/core/openbb_core/app/static/package_builder.py +++ b/openbb_sdk/sdk/core/openbb_core/app/static/package_builder.py @@ -31,11 +31,11 @@ class PackageBuilder: """Build the extension package for the SDK.""" @classmethod - def build(cls, lint: bool = True) -> None: + def build(cls, modules:Optional[List[str]]=None, lint: bool = True) -> None: """Build the extensions for the SDK.""" print("\nBuilding extensions package...\n") cls.save_module_map() - cls.save_modules() + cls.save_modules(modules) cls.save_package() if lint: cls.run_linters() @@ -56,7 +56,7 @@ def save_module_map(cls): ) @classmethod - def save_modules(cls): + def save_modules(cls, modules:Optional[List[str]] = None): """Save the modules.""" print("\nWriting modules...") route_map = PathHandler.build_route_map() @@ -68,6 +68,9 @@ def save_modules(cls): MAX_LEN = max([len(path) for path in path_list if path != "/"]) + if modules: + path_list = [path for path in path_list if path in modules] + for path in path_list: route = PathHandler.get_route(path=path, route_map=route_map) if route is None: