mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-11-26 11:12:50 +00:00
[V5] openbb-eia: Refactor for V5 + Add Full API Implementation (#7584)
* eia refactor for v5 * add test and publish workflows * data browser state * fix workflows * more workflow test items * temp files in tests * more fixes * more browsers * fix codeql issues * fix mer state and ensure multi-user capability * uv lock * table bridge * fix electricity browser state * convert HTML widgets to iFrame * fix recursion error in workspace mcp
This commit is contained in:
164
.github/workflows/test-unit-openbb-us-eia.yml
vendored
Normal file
164
.github/workflows/test-unit-openbb-us-eia.yml
vendored
Normal file
@@ -0,0 +1,164 @@
|
||||
name: 🧪 test openbb-us-eia
|
||||
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [develop, main, v5]
|
||||
paths:
|
||||
- "openbb_platform/providers/eia/**"
|
||||
- ".github/workflows/test-unit-openbb-us-eia.yml"
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
force_catalog_rebuild:
|
||||
description: "Force the build hook to regenerate the EIA catalog from the live APIv2 metadata tree (ignores actions/cache)."
|
||||
type: boolean
|
||||
default: false
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
concurrency:
|
||||
# Cancel in-flight matrix runs when a new commit lands on the same PR.
|
||||
group: test-openbb-us-eia-${{ 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/providers/eia
|
||||
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 the build backend and openbb-core
|
||||
run: |
|
||||
uv pip install --system "hatchling>=1.25" "requests>=2.31"
|
||||
uv pip install --system ../../core
|
||||
|
||||
- name: Restore EIA catalog
|
||||
# ``eia_catalog.json.xz`` is gitignored. On a cache hit the build hook
|
||||
# reuses it; on a miss it crawls api.eia.gov, which needs EIA_API_KEY.
|
||||
id: eia-cache
|
||||
uses: actions/cache@v5
|
||||
with:
|
||||
path: openbb_platform/providers/eia/openbb_us_eia/assets/eia_catalog.json.xz
|
||||
key: eia-catalog-${{ hashFiles('openbb_platform/providers/eia/openbb_us_eia/utils/generate_catalog.py') }}
|
||||
restore-keys: |
|
||||
eia-catalog-
|
||||
|
||||
- name: Build sdist
|
||||
env:
|
||||
OPENBB_EIA_FORCE_CATALOG_REBUILD: ${{ inputs.force_catalog_rebuild == true && '1' || '0' }}
|
||||
EIA_API_KEY: ${{ secrets.EIA_API_KEY }}
|
||||
run: uv build --sdist --no-sources --no-build-isolation --python "$(which python)"
|
||||
|
||||
- name: Build wheel
|
||||
env:
|
||||
OPENBB_EIA_FORCE_CATALOG_REBUILD: "0"
|
||||
run: uv build --wheel --no-sources --no-build-isolation --python "$(which python)"
|
||||
|
||||
- uses: actions/upload-artifact@v5
|
||||
with:
|
||||
name: openbb-us-eia-dist
|
||||
path: openbb_platform/providers/eia/dist/
|
||||
if-no-files-found: error
|
||||
retention-days: 7
|
||||
|
||||
lint:
|
||||
name: Lint (ruff + ty)
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
working-directory: openbb_platform/providers/eia
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- uses: actions/setup-python@v6
|
||||
with:
|
||||
python-version: "3.11"
|
||||
|
||||
- run: python -m pip install --upgrade pip uv
|
||||
|
||||
- uses: actions/download-artifact@v5
|
||||
with:
|
||||
name: openbb-us-eia-dist
|
||||
path: openbb_platform/providers/eia/dist
|
||||
|
||||
- name: Install dependencies then openbb-us-eia wheel
|
||||
run: |
|
||||
uv pip install --system ../../core
|
||||
uv pip install --system --group dev
|
||||
uv pip install --system dist/openbb_us_eia-*.whl
|
||||
|
||||
- name: ruff check
|
||||
run: ruff check openbb_us_eia tests hatch_build.py
|
||||
|
||||
- name: ruff format --check
|
||||
run: ruff format --check openbb_us_eia tests hatch_build.py
|
||||
|
||||
- name: ty check
|
||||
run: ty check openbb_us_eia
|
||||
|
||||
test:
|
||||
name: Test (${{ matrix.os }} / Python ${{ matrix.python_version }})
|
||||
needs: build
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
# Linux: full sweep across every released Python.
|
||||
- { 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" }
|
||||
# macOS + Windows: min and max supported.
|
||||
- { 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/providers/eia
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- uses: actions/setup-python@v6
|
||||
with:
|
||||
python-version: ${{ matrix.python_version }}
|
||||
allow-prereleases: true
|
||||
|
||||
- uses: actions/download-artifact@v5
|
||||
with:
|
||||
name: openbb-us-eia-dist
|
||||
path: openbb_platform/providers/eia/dist
|
||||
|
||||
- run: python -m pip install --upgrade pip uv
|
||||
|
||||
- name: Install dependencies then openbb-us-eia wheel
|
||||
run: |
|
||||
uv pip install --system ../../core
|
||||
uv pip install --system --group dev
|
||||
uv pip install --system dist/openbb_us_eia-*.whl
|
||||
|
||||
- name: Test the installed wheel
|
||||
# Remove the local ``openbb_us_eia/`` source so pytest imports the
|
||||
# package from site-packages — the exact wheel that was just built.
|
||||
# The HTTP fetchers replay from tests/record cassettes, so no EIA
|
||||
# credential is needed here.
|
||||
run: |
|
||||
rm -rf openbb_us_eia
|
||||
pytest tests --cov=openbb_us_eia --cov-report=term-missing --cov-fail-under=100
|
||||
Reference in New Issue
Block a user