summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPratyush Shukla <ps4534@nyu.edu>2024-03-13 00:38:10 +0530
committerGitHub <noreply@github.com>2024-03-13 00:38:10 +0530
commitd2fb4e11243a9207c355514a744e55b9ef4292a0 (patch)
treea5083c8b807739bdb7527b1aecf00a532e20b560
parenta42c5604e384a642302410a3e79464cf5ec46b90 (diff)
[HotFix] Fix obbject extensions not written to `extension_map.json` (#6195)
* fix obbject extensions not shown in extension_map.json * sort extensions in auto build * @jmaslek said delete it * delete the same action in manual unit test
-rw-r--r--.github/workflows/manual-unit-test.yml107
-rw-r--r--.github/workflows/unit-test.yml108
-rw-r--r--openbb_platform/core/openbb_core/app/extension_loader.py20
-rw-r--r--openbb_platform/core/openbb_core/app/static/package_builder.py20
4 files changed, 26 insertions, 229 deletions
diff --git a/.github/workflows/manual-unit-test.yml b/.github/workflows/manual-unit-test.yml
index 19c6e9f5fc5..5c9be9d89e5 100644
--- a/.github/workflows/manual-unit-test.yml
+++ b/.github/workflows/manual-unit-test.yml
@@ -147,110 +147,3 @@ jobs:
run: |
source $VENV
pytest tests/ --optimization --autodoc -n auto --timeout=30
-
- tests-conda:
- name: Anaconda Python Tests - (${{ matrix.python-version }}, ${{ matrix.os }})
- runs-on: ${{ matrix.os }}-latest
- strategy:
- fail-fast: false
- matrix:
- os: ["ubuntu", "windows", "macos"]
- python-version: ["3.9"]
- dependencies: [""]
- include:
- - os: ubuntu
- python: 3.9
- - os: windows
- python: 3.9
- env:
- OS: ${{ matrix.os }}
- PYTHON: ${{ matrix.python }}
- PYTHONNOUSERSITE: 1
-
- steps:
- - name: Set git to use LF
- if: runner.os == 'Windows'
- run: |
- git config --global core.autocrlf false
- git config --global core.eol lf
-
- - name: Setup sudo apt installs for ubuntu-latest
- if: runner.os == 'Linux'
- run: |
- sudo apt-get update
- sudo apt-get install -y \
- libgtk-3-dev \
- libwebkit2gtk-4.0-dev
-
- - name: Checkout
- uses: actions/checkout@v3
- with:
- # Need to fetch more than the last commit so that setuptools-scm can
- # create the correct version string. If the number of commits since
- # the last release is greater than this, the version still be wrong.
- # Increase if necessary.
- fetch-depth: 100
- # The GitHub token is preserved by default but this job doesn't need
- # to be able to push to GitHub.
- persist-credentials: false
-
- - name: Setup caching for conda packages
- uses: actions/cache@v3
- with:
- path: ~/conda_pkgs_dir
- key: conda-${{ runner.os }}-v1-${{ matrix.python }}-${{ hashFiles('build/conda/conda-3-9-env-full.yaml') }}
-
- - name: Setup Miniconda
- uses: conda-incubator/setup-miniconda@v2
- with:
- python-version: ${{ matrix.python }}
- miniconda-version: "latest"
- auto-update-conda: true
- channels: conda-forge,defaults
- show-channel-urls: true
- channel-priority: flexible
- environment-file: build/conda/conda-3-9-env.yaml
- activate-environment: testing
- # Needed for caching
- use-only-tar-bz2: true
-
- - name: Update Temp permissions on windows
- if: runner.os == 'Windows'
- shell: cmd /C CALL {0}
- run: >-
- c:\windows\system32\icacls C:\Users\runneradmin\AppData\Local\Temp /grant "everyone":F /t
-
- - name: Get pip cache dir
- shell: bash -l {0}
- id: pip-cache
- run: |
- echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
-
- - name: pip cache
- uses: actions/cache@v3
- with:
- path: ${{ steps.pip-cache.outputs.dir }}
- key: ${{ runner.os }}-v1-3-9-pip-${{ hashFiles('requirements-full.txt') }}
- restore-keys: |
- ${{ runner.os }}-v1-pip-
-
- - name: Install dependencies (Bash)
- shell: bash -l {0}
- run: |
- pip install --requirement requirements-full.txt
- pip uninstall Brotli -y
-
- - name: List installed packages (Bash)
- shell: bash -l {0}
- run: |
- conda list
- pip list
-
- - name: Run tests (Bash)
- env:
- MPLBACKEND: Agg
- shell: bash -l {0}
- run: pytest tests/ -m "not linux" --optimization -n auto --timeout=30
- - name: Start Terminal and exit
- shell: bash -l {0}
- run: python terminal.py
diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml
index 546edc785fd..f8426e9b28b 100644
--- a/.github/workflows/unit-test.yml
+++ b/.github/workflows/unit-test.yml
@@ -253,110 +253,4 @@ jobs:
MPLBACKEND: Agg
run: |
source $VENV
- pytest tests/ --optimization --autodoc -n auto --timeout=30
-
- tests-conda:
- name: Anaconda Python Tests - (${{ matrix.python-version }}, ${{ matrix.os }})
- runs-on: ${{ matrix.os }}-latest
- if: github.event_name == 'push' || github.event.pull_request.merged == true
- strategy:
- fail-fast: false
- matrix:
- os: ["ubuntu", "macos"]
- python-version: ["3.9"]
- dependencies: [""]
- include:
- - os: ubuntu
- python: 3.9
- env:
- OS: ${{ matrix.os }}
- PYTHON: ${{ matrix.python }}
- PYTHONNOUSERSITE: 1
-
- steps:
- - name: Set git to use LF
- if: runner.os == 'Windows'
- run: |
- git config --global core.autocrlf false
- git config --global core.eol lf
-
- - name: Setup sudo apt installs for ubuntu-latest
- if: runner.os == 'Linux'
- run: |
- sudo apt-get update
- sudo apt-get install -y \
- libgtk-3-dev \
- libwebkit2gtk-4.0-dev
-
- - name: Checkout
- uses: actions/checkout@v3
- with:
- # Need to fetch more than the last commit so that setuptools-scm can
- # create the correct version string. If the number of commits since
- # the last release is greater than this, the version still be wrong.
- # Increase if necessary.
- fetch-depth: 100
- # The GitHub token is preserved by default but this job doesn't need
- # to be able to push to GitHub.
- persist-credentials: false
-
- - name: Setup caching for conda packages
- uses: actions/cache@v3
- with:
- path: ~/conda_pkgs_dir
- key: conda-${{ runner.os }}-v1-${{ matrix.python }}-${{ hashFiles('build/conda/conda-3-9-env-full.yaml') }}
-
- - name: Setup Miniconda
- uses: conda-incubator/setup-miniconda@v2
- with:
- python-version: ${{ matrix.python }}
- miniconda-version: "latest"
- auto-update-conda: true
- channels: conda-forge,defaults
- show-channel-urls: true
- channel-priority: flexible
- environment-file: build/conda/conda-3-9-env.yaml
- activate-environment: testing
- # Needed for caching
- use-only-tar-bz2: true
-
- - name: Update Temp permissions on windows
- if: runner.os == 'Windows'
- shell: cmd /C CALL {0}
- run: >-
- c:\windows\system32\icacls C:\Users\runneradmin\AppData\Local\Temp /grant "everyone":F /t
-
- - name: Get pip cache dir
- shell: bash -l {0}
- id: pip-cache
- run: |
- echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
-
- - name: pip cache
- uses: actions/cache@v3
- with:
- path: ${{ steps.pip-cache.outputs.dir }}
- key: ${{ runner.os }}-v1-3-9-pip-${{ hashFiles('requirements-full.txt') }}
- restore-keys: |
- ${{ runner.os }}-v1-pip-
-
- - name: Install dependencies (Bash)
- shell: bash -l {0}
- run: |
- pip install --requirement requirements-full.txt
- pip uninstall Brotli -y
-
- - name: List installed packages (Bash)
- shell: bash -l {0}
- run: |
- conda list
- pip list
-
- - name: Run tests (Bash)
- env:
- MPLBACKEND: Agg
- shell: bash -l {0}
- run: pytest tests/ -m "not linux" --optimization -n auto --timeout=30
- - name: Start Terminal and exit
- shell: bash -l {0}
- run: python terminal.py
+ pytest tests/ --optimization --autodoc -n auto --timeout=30 \ No newline at end of file
diff --git a/openbb_platform/core/openbb_core/app/extension_loader.py b/openbb_platform/core/openbb_core/app/extension_loader.py
index 4381714f9aa..ea31e3cf7ca 100644
--- a/openbb_platform/core/openbb_core/app/extension_loader.py
+++ b/openbb_platform/core/openbb_core/app/extension_loader.py
@@ -2,7 +2,7 @@
from enum import Enum
from functools import lru_cache
-from typing import TYPE_CHECKING, Any, Dict, Optional
+from typing import TYPE_CHECKING, Any, Dict, List, Optional
from importlib_metadata import EntryPoint, EntryPoints, entry_points
@@ -21,6 +21,15 @@ class OpenBBGroups(Enum):
provider = "openbb_provider_extension"
obbject = "openbb_obbject_extension"
+ @staticmethod
+ def groups() -> List[str]:
+ """Return the OpenBBGroups."""
+ return [
+ OpenBBGroups.core.value,
+ OpenBBGroups.provider.value,
+ OpenBBGroups.obbject.value,
+ ]
+
class ExtensionLoader(metaclass=SingletonMeta):
"""Extension loader class."""
@@ -57,6 +66,15 @@ class ExtensionLoader(metaclass=SingletonMeta):
"""Return the provider entry points."""
return self._provider_entry_points
+ @property
+ def entry_points(self) -> List[EntryPoints]:
+ """Return the entry points."""
+ return [
+ self._core_entry_points,
+ self._provider_entry_points,
+ self._obbject_entry_points,
+ ]
+
@staticmethod
def _get_entry_point(
entry_points_: EntryPoints, ext_name: str
diff --git a/openbb_platform/core/openbb_core/app/static/package_builder.py b/openbb_platform/core/openbb_core/app/static/package_builder.py
index b6e08c83696..20b2fc433a8 100644
--- a/openbb_platform/core/openbb_core/app/static/package_builder.py
+++ b/openbb_platform/core/openbb_core/app/static/package_builder.py
@@ -92,11 +92,11 @@ class PackageBuilder:
self.directory / "assets" / "extension_map.json"
)
if add:
- a = ", ".join(add)
+ a = ", ".join(sorted(add))
print(f"Extensions to add: {a}") # noqa: T201
if remove:
- r = ", ".join(remove)
+ r = ", ".join(sorted(remove))
print(f"Extensions to remove: {r}") # noqa: T201
if add or remove:
@@ -132,18 +132,10 @@ class PackageBuilder:
def _get_extension_map(self) -> Dict[str, List[str]]:
"""Get map of extensions available at build time."""
el = ExtensionLoader()
+ og = OpenBBGroups.groups()
ext_map: Dict[str, List[str]] = {}
- groups = [
- OpenBBGroups.core.value,
- OpenBBGroups.provider.value,
- ]
- entry_points_ = [
- el.core_entry_points,
- el.provider_entry_points,
- ]
-
- for group, entry_point in zip(groups, entry_points_):
+ for group, entry_point in zip(og, el.entry_points):
ext_map[group] = [
f"{e.name}@{getattr(e.dist, 'version', '')}" for e in entry_point
]
@@ -252,7 +244,8 @@ class PackageBuilder:
add: Set[str] = set()
remove: Set[str] = set()
- groups = ("openbb_core_extension", "openbb_provider_extension")
+ groups = OpenBBGroups.groups()
+
for g in groups:
built = set(ext_map.get(g, {}))
installed = set(
@@ -556,7 +549,6 @@ class MethodDefinition:
path: str, parameter_map: Dict[str, Parameter]
) -> OrderedDict[str, Parameter]:
"""Format the params."""
-
parameter_map.pop("cc", None)
# we need to add the chart parameter here bc of the docstring generation
if CHARTING_INSTALLED and path.replace("/", "_")[1:] in Charting.functions():