mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-28 13:01:38 +00:00
[V5] openbb-technical: Refactor for V5 & Add More Quick Win Endpoints (#7502)
* refactor openbb-technical for v5 * forward refs * linting * no python 3.15 in test matrix * reame * ty * move all params to body --------- Co-authored-by: deeleeramone <>
This commit is contained in:
17
.github/workflows/general-linting.yml
vendored
17
.github/workflows/general-linting.yml
vendored
@@ -62,6 +62,23 @@ jobs:
|
||||
pip install ./openbb_platform/extensions/devtools
|
||||
- name: Install openbb-core (so ty can resolve runtime deps)
|
||||
run: pip install -e "./openbb_platform/core[pandas]" numpy
|
||||
- name: Install changed packages (so ty resolves their declared deps)
|
||||
if: env.diff_files != ''
|
||||
run: |
|
||||
# Install each touched package so ty has the package's declared
|
||||
# third-party deps (pandas-ta, scipy, statsmodels, etc.) available
|
||||
# for type resolution. Optional cross-package peers (e.g.
|
||||
# openbb_charting) that aren't installed surface as `warn`-level
|
||||
# diagnostics under the repo-root ty.toml rather than build errors.
|
||||
touched=$(echo "${{ env.diff_files }}" | tr ' ' '\n' \
|
||||
| grep -oE '^(openbb_platform/(extensions|providers|obbject_extensions)|cli)/[^/]+' \
|
||||
| sort -u)
|
||||
for pkg in $touched; do
|
||||
if [ -f "$pkg/pyproject.toml" ]; then
|
||||
echo "Installing $pkg"
|
||||
pip install -e "./$pkg" || echo "skip $pkg (install failed)"
|
||||
fi
|
||||
done
|
||||
- run: codespell --ignore-words=.codespell.ignore --skip="$(tr '\n' ',' < .codespell.skip | sed 's/,$//')" --quiet-level=2
|
||||
- run: |
|
||||
# Run linters for openbb_platform | cli
|
||||
|
||||
175
.github/workflows/publish-openbb-technical.yml
vendored
Normal file
175
.github/workflows/publish-openbb-technical.yml
vendored
Normal file
@@ -0,0 +1,175 @@
|
||||
name: 📦 publish openbb-technical
|
||||
|
||||
# Triggers exclusively on the merge of a ``release/openbb-technical-v*``
|
||||
# branch into ``develop``. Four sequential jobs — version-check,
|
||||
# build, test, publish — with PyPI OIDC trusted publishing.
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [closed]
|
||||
branches: [develop, v5]
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
version-check:
|
||||
name: Verify version bump
|
||||
if: ${{ (github.event_name == 'pull_request' && github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release/openbb-technical-v')) || github.event_name == 'workflow_dispatch' }}
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
version: ${{ steps.parse.outputs.version }}
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
working-directory: openbb_platform/extensions/technical
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
ref: develop
|
||||
|
||||
- name: Parse [project].version from pyproject.toml
|
||||
id: parse
|
||||
run: |
|
||||
VERSION=$(grep -m1 -E '^version[[:space:]]*=' pyproject.toml | sed -E 's/^version[[:space:]]*=[[:space:]]*"([^"]+)".*/\1/')
|
||||
if [ -z "$VERSION" ]; then
|
||||
echo "::error::Could not parse [project].version from pyproject.toml."
|
||||
exit 1
|
||||
fi
|
||||
echo "Local version: $VERSION"
|
||||
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Fail if version already exists on PyPI
|
||||
env:
|
||||
VERSION: ${{ steps.parse.outputs.version }}
|
||||
run: |
|
||||
STATUS=$(curl -sS -o /dev/null -w "%{http_code}" "https://pypi.org/pypi/openbb-technical/${VERSION}/json")
|
||||
case "$STATUS" in
|
||||
200)
|
||||
echo "::error::openbb-technical ${VERSION} is already published on PyPI."
|
||||
echo "Bump openbb_platform/extensions/technical/pyproject.toml [project].version and re-merge a fresh release branch."
|
||||
exit 1
|
||||
;;
|
||||
404)
|
||||
echo "openbb-technical ${VERSION} is not yet on PyPI — proceeding."
|
||||
;;
|
||||
*)
|
||||
echo "::error::Unexpected status $STATUS from PyPI JSON API. Aborting to avoid a silent skip."
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
- name: Verify release branch name matches pyproject version
|
||||
if: github.event_name == 'pull_request'
|
||||
env:
|
||||
VERSION: ${{ steps.parse.outputs.version }}
|
||||
BRANCH: ${{ github.event.pull_request.head.ref }}
|
||||
run: |
|
||||
EXPECTED="release/openbb-technical-v${VERSION}"
|
||||
if [ "$BRANCH" != "$EXPECTED" ]; then
|
||||
echo "::error::Release branch '${BRANCH}' does not match pyproject version '${VERSION}'."
|
||||
echo "Expected branch name: '${EXPECTED}'."
|
||||
echo "Either rename the release branch or update [project].version in pyproject.toml so they agree."
|
||||
exit 1
|
||||
fi
|
||||
echo "Branch '${BRANCH}' matches pyproject version '${VERSION}'."
|
||||
|
||||
build:
|
||||
name: Build sdist + wheel
|
||||
needs: version-check
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
working-directory: openbb_platform/extensions/technical
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
ref: develop
|
||||
|
||||
- uses: actions/setup-python@v6
|
||||
with:
|
||||
python-version: "3.11"
|
||||
|
||||
- run: python -m pip install --upgrade pip uv
|
||||
|
||||
- name: Build sdist + wheel
|
||||
run: uv build --no-sources
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: openbb-technical-dist
|
||||
path: openbb_platform/extensions/technical/dist/
|
||||
if-no-files-found: error
|
||||
retention-days: 7
|
||||
|
||||
test:
|
||||
name: Test (${{ matrix.os }} / Python ${{ matrix.python_version }})
|
||||
needs: build
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- { os: ubuntu-latest, python_version: "3.10" }
|
||||
- { os: ubuntu-latest, python_version: "3.11" }
|
||||
- { os: ubuntu-latest, python_version: "3.12" }
|
||||
- { os: ubuntu-latest, python_version: "3.13" }
|
||||
- { os: ubuntu-latest, python_version: "3.14" }
|
||||
- { os: macos-latest, python_version: "3.10" }
|
||||
- { os: macos-latest, python_version: "3.14" }
|
||||
- { os: windows-latest, python_version: "3.10" }
|
||||
- { os: windows-latest, python_version: "3.14" }
|
||||
runs-on: ${{ matrix.os }}
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
working-directory: openbb_platform/extensions/technical
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
ref: develop
|
||||
|
||||
- uses: actions/setup-python@v6
|
||||
with:
|
||||
python-version: ${{ matrix.python_version }}
|
||||
allow-prereleases: true
|
||||
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: openbb-technical-dist
|
||||
path: openbb_platform/extensions/technical/dist
|
||||
|
||||
- run: python -m pip install --upgrade pip uv
|
||||
|
||||
- name: Install openbb-technical from source (+ dev group)
|
||||
# Source install via ``-e .`` reads ``[tool.uv.sources]`` and
|
||||
# resolves ``openbb-core[pandas]`` from the sibling tree at
|
||||
# ``../../core``. Installing the wheel directly would fail
|
||||
# dependency resolution until ``openbb-core>=2.0.0`` ships to
|
||||
# PyPI; the wheel is still the artifact uploaded to PyPI by
|
||||
# the ``publish`` job — this matrix validates the source the
|
||||
# wheel was built from.
|
||||
run: |
|
||||
uv pip install --system -e .
|
||||
uv pip install --system --group dev
|
||||
|
||||
- name: Run unit tests
|
||||
run: pytest tests --cov=openbb_technical --cov-report=term-missing --cov-fail-under=100
|
||||
|
||||
publish:
|
||||
name: Publish to PyPI
|
||||
needs: test
|
||||
runs-on: ubuntu-latest
|
||||
environment: pypi-openbb-technical
|
||||
permissions:
|
||||
id-token: write
|
||||
steps:
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: openbb-technical-dist
|
||||
path: dist
|
||||
|
||||
- uses: pypa/gh-action-pypi-publish@release/v1
|
||||
with:
|
||||
packages-dir: dist
|
||||
139
.github/workflows/test-unit-openbb-technical.yml
vendored
Normal file
139
.github/workflows/test-unit-openbb-technical.yml
vendored
Normal file
@@ -0,0 +1,139 @@
|
||||
name: 🧪 test openbb-technical
|
||||
|
||||
# PR-test for the openbb-technical extension. Triggers when a PR touches
|
||||
# any file under ``openbb_platform/extensions/technical/`` or this
|
||||
# workflow itself.
|
||||
#
|
||||
# Build-once, test-many: a single ``build`` job produces sdist + wheel,
|
||||
# then ``lint`` and ``test`` both consume the wheel artifact. Tests
|
||||
# install from source (``-e .``) so ``[tool.uv.sources]`` resolves
|
||||
# ``openbb-core[pandas]`` against the sibling repo path — the
|
||||
# ``openbb-core>=2.0.0`` declared in the wheel is not satisfiable from
|
||||
# PyPI until that version ships.
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [develop, main, v5]
|
||||
paths:
|
||||
- "openbb_platform/extensions/technical/**"
|
||||
- ".github/workflows/test-unit-openbb-technical.yml"
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
concurrency:
|
||||
group: test-openbb-technical-${{ github.event.pull_request.number || github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build sdist + wheel
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
working-directory: openbb_platform/extensions/technical
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- uses: actions/setup-python@v6
|
||||
with:
|
||||
python-version: "3.11"
|
||||
|
||||
- run: python -m pip install --upgrade pip uv
|
||||
|
||||
- name: Build sdist + wheel
|
||||
run: uv build --no-sources
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: openbb-technical-dist
|
||||
path: openbb_platform/extensions/technical/dist/
|
||||
if-no-files-found: error
|
||||
retention-days: 7
|
||||
|
||||
lint:
|
||||
name: Lint (ruff + ty)
|
||||
# ``needs: build`` keeps lint dependent on a clean build. Lint runs
|
||||
# on the source tree (not the wheel) and uses the editable install
|
||||
# so ``ty`` sees real types from openbb-core / pandas-ta / scipy.
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
working-directory: openbb_platform/extensions/technical
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- uses: actions/setup-python@v6
|
||||
with:
|
||||
python-version: "3.11"
|
||||
|
||||
- run: python -m pip install --upgrade pip uv
|
||||
|
||||
- name: Install openbb-technical from source (+ dev group)
|
||||
# ``-e .`` reads ``[tool.uv.sources]`` and resolves openbb-core
|
||||
# against the sibling source tree. ``--group dev`` installs
|
||||
# openbb-devtools (ruff, ty, pytest-asyncio, etc.).
|
||||
run: |
|
||||
uv pip install --system -e .
|
||||
uv pip install --system --group dev
|
||||
|
||||
- name: ruff check
|
||||
run: ruff check openbb_technical tests integration
|
||||
|
||||
- name: ruff format --check
|
||||
run: ruff format --check openbb_technical tests integration
|
||||
|
||||
- name: ty check
|
||||
run: ty check openbb_technical
|
||||
|
||||
test:
|
||||
name: Test (${{ matrix.os }} / Python ${{ matrix.python_version }})
|
||||
needs: build
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- { os: ubuntu-latest, python_version: "3.10" }
|
||||
- { os: ubuntu-latest, python_version: "3.11" }
|
||||
- { os: ubuntu-latest, python_version: "3.12" }
|
||||
- { os: ubuntu-latest, python_version: "3.13" }
|
||||
- { os: ubuntu-latest, python_version: "3.14" }
|
||||
- { os: macos-latest, python_version: "3.10" }
|
||||
- { os: macos-latest, python_version: "3.14" }
|
||||
- { os: windows-latest, python_version: "3.10" }
|
||||
- { os: windows-latest, python_version: "3.14" }
|
||||
runs-on: ${{ matrix.os }}
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
working-directory: openbb_platform/extensions/technical
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- uses: actions/setup-python@v6
|
||||
with:
|
||||
python-version: ${{ matrix.python_version }}
|
||||
allow-prereleases: true
|
||||
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: openbb-technical-dist
|
||||
path: openbb_platform/extensions/technical/dist
|
||||
|
||||
- run: python -m pip install --upgrade pip uv
|
||||
|
||||
- name: Install openbb-technical from source (+ dev group)
|
||||
# Source install via ``-e .`` reads ``[tool.uv.sources]`` and
|
||||
# resolves openbb-core[pandas] from the sibling tree at
|
||||
# ``../../core``. Installing the wheel directly would fail
|
||||
# dependency resolution until openbb-core>=2.0.0 ships to PyPI.
|
||||
run: |
|
||||
uv pip install --system -e .
|
||||
uv pip install --system --group dev
|
||||
|
||||
- name: Run unit tests
|
||||
run: pytest tests --cov=openbb_technical --cov-report=term-missing --cov-fail-under=100
|
||||
Reference in New Issue
Block a user