[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
This commit is contained in:
Pratyush Shukla
2024-03-13 00:38:10 +05:30
committed by GitHub
parent a42c5604e3
commit d2fb4e1124
4 changed files with 26 additions and 229 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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():