Skip to content

Commit 9a30186

Browse files
deeleeramoneCopilot
andauthored
[V5] CLI 2.0 - Pluggable Backends, Non-TTY Default, HTTP Dispatcher, Spec Files + Codegen (#7433)
* stash some changes * add more robust testing * mypy * point PR at V5 * introduce spec file * codespell * test fix * fix workflow environment setup * fix workflow environment setup * fix workflow environment setup * add pyyaml to dependencies * split lint jobs * fix workflow environment setup * fix workflow environment setup * workflow env setup * workflow env setup * clean up code comments * add auth hook entrypoints * codespell * add codegen feature * codespell * move _unpack into dispatchers for consistency with codegen packages * surface nested models in the response * fix missing coverage in CI * socrata updates * test fix * detect plotly output * add --include and --exclude flags from generate-extension command * cap test matrix at python 3.14 * no useless comments * platform controller command description split * merge URL overloads from path params * exclude none and unset from model dump --------- Co-authored-by: deeleeramone <> Co-authored-by: Copilot <copilot@github.com>
1 parent c3f49f0 commit 9a30186

127 files changed

Lines changed: 44123 additions & 8061 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.codespell.ignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
ake
22
alle
3+
alph
34
ba
45
brin
56
buda
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: 🧹 openbb-cli linting
2+
3+
env:
4+
PIP_DEFAULT_TIMEOUT: 100
5+
6+
on:
7+
pull_request:
8+
types: [opened, synchronize, edited]
9+
paths:
10+
- 'cli/**'
11+
- '.github/workflows/lint-openbb-cli.yml'
12+
merge_group:
13+
types: [checks_requested]
14+
15+
concurrency:
16+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
17+
cancel-in-progress: true
18+
19+
jobs:
20+
lint:
21+
name: Lint openbb-cli
22+
runs-on: ubuntu-latest
23+
env:
24+
UV_CACHE_DIR: ${{ github.workspace }}/.uv-cache
25+
permissions:
26+
contents: read
27+
steps:
28+
- name: Checkout Code
29+
uses: actions/checkout@v6
30+
with:
31+
ref: ${{ github.event.pull_request.head.ref || github.ref }}
32+
repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
33+
fetch-depth: 20
34+
token: ${{ secrets.GITHUB_TOKEN }}
35+
36+
- name: Fetch base branch
37+
run: git fetch --no-tags --depth=20 origin ${{ github.base_ref }}
38+
39+
- name: Setup Python 3.10
40+
uses: actions/setup-python@v6
41+
with:
42+
python-version: "3.10"
43+
architecture: x64
44+
45+
- name: Cache uv (built wheels)
46+
uses: actions/cache@v4
47+
with:
48+
path: ${{ github.workspace }}/.uv-cache
49+
key: uv-${{ runner.os }}-py3.10-lint-${{ hashFiles('cli/pyproject.toml', 'cli/uv.lock', 'openbb_platform/core/pyproject.toml', 'openbb_platform/obbject_extensions/charting/pyproject.toml', 'openbb_platform/extensions/devtools/pyproject.toml') }}
50+
restore-keys: |
51+
uv-${{ runner.os }}-py3.10-lint-
52+
53+
- name: Get changed CLI files for PR
54+
if: github.event_name == 'pull_request'
55+
run: |
56+
echo "diff_files=$(git diff --diff-filter=d --name-only origin/${{ github.base_ref }}...${HEAD_REF} | grep -E '^cli/.*\.py$' | grep -v 'integration' | grep -v 'tests' | xargs)" >> $GITHUB_ENV
57+
env:
58+
HEAD_REF: ${{ github.head_ref }}
59+
60+
- name: Install openbb-cli
61+
working-directory: cli
62+
run: |
63+
python -m pip install --upgrade pip uv
64+
python -m uv pip install --system -e ".[charting]" --group dev
65+
66+
- name: Run ruff format / ruff check / ty on changed CLI files
67+
run: |
68+
if [ -n "${{ env.diff_files }}" ]; then
69+
ruff format --check ${{ env.diff_files }}
70+
ruff check ${{ env.diff_files }}
71+
ty check ${{ env.diff_files }}
72+
else
73+
echo "No Python files changed in cli"
74+
fi

.github/workflows/general-linting.yml renamed to .github/workflows/lint-openbb-platform.yml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,12 @@ env:
66
on:
77
pull_request:
88
types: [opened, synchronize, edited]
9-
# push:
10-
# branches:
11-
# - "feature/*"
12-
# - "hotfix/*"
13-
# - "release/*"
9+
paths:
10+
- 'openbb_platform/**'
11+
- '.github/workflows/general-linting.yml'
1412
merge_group:
1513
types: [checks_requested]
1614

17-
# Cancel previous runs that are not yet completed.
1815
concurrency:
1916
group: ${{ github.event_name }}-${{ github.repository }}-${{ github.ref }}
2017
cancel-in-progress: true
@@ -47,7 +44,7 @@ jobs:
4744
if: github.event_name == 'pull_request'
4845
run: |
4946
# "Checking PR diff"
50-
echo "diff_files=$(git diff --diff-filter=d --name-only origin/${{ github.base_ref }}...${HEAD_REF} | grep -E '^(openbb_platform|cli)/.*\.py$' | grep -v 'openbb_platform/core/openbb/package' | grep -v 'integration' | grep -v 'tests' | xargs)" >> $GITHUB_ENV
47+
echo "diff_files=$(git diff --diff-filter=d --name-only origin/${{ github.base_ref }}...${HEAD_REF} | grep -E '^openbb_platform/.*\.py$' | grep -v 'openbb_platform/core/openbb/package' | grep -v 'integration' | grep -v 'tests' | xargs)" >> $GITHUB_ENV
5148
echo $diff_files
5249
5350
env:
@@ -81,13 +78,13 @@ jobs:
8178
done
8279
- run: codespell --ignore-words=.codespell.ignore --skip="$(tr '\n' ',' < .codespell.skip | sed 's/,$//')" --quiet-level=2
8380
- run: |
84-
# Run linters for openbb_platform | cli
81+
# Run linters for openbb_platform
8582
if [ -n "${{ env.diff_files }}" ]; then
8683
ruff format --check ${{ env.diff_files }}
8784
ruff check ${{ env.diff_files }}
8885
ty check ${{ env.diff_files }}
8986
else
90-
echo "No Python files changed in openbb_platform | cli"
87+
echo "No Python files changed in openbb_platform"
9188
fi
9289
9390
markdown-link-check:
Lines changed: 95 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,121 @@
1-
name: 🖥️ Unit test CLI
1+
name: 🖥️ openbb-cli
22

33
on:
44
pull_request:
55
branches:
66
- develop
7+
- v5
78
paths:
89
- 'cli/**'
10+
- '.github/workflows/test-unit-cli.yml'
11+
push:
12+
branches:
13+
- develop
14+
- v5
15+
paths:
16+
- 'cli/**'
17+
- '.github/workflows/test-unit-cli.yml'
18+
merge_group:
19+
types: [checks_requested]
20+
workflow_dispatch:
921

1022
concurrency:
11-
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
12-
cancel-in-progress: true
23+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
24+
cancel-in-progress: true
25+
26+
defaults:
27+
run:
28+
shell: bash
29+
working-directory: cli
1330

1431
jobs:
15-
unit_tests:
16-
runs-on: ubuntu-latest
32+
test:
33+
name: Test (${{ matrix.os }} / Python ${{ matrix.python_version }})
34+
runs-on: ${{ matrix.os }}
35+
env:
36+
OPENBB_ALLOW_ON_COMMAND_OUTPUT: "True"
37+
OPENBB_ALLOW_MUTABLE_EXTENSIONS: "True"
38+
UV_CACHE_DIR: ${{ github.workspace }}/.uv-cache
1739
permissions:
1840
contents: read
1941
strategy:
20-
fail-fast: false
21-
22-
matrix:
23-
python_version:
24-
["3.10", "3.11", "3.12", "3.13", "3.14"]
42+
fail-fast: false
43+
matrix:
44+
include:
45+
# Linux: full sweep across every supported Python.
46+
- { os: ubuntu-latest, python_version: "3.10" }
47+
- { os: ubuntu-latest, python_version: "3.11" }
48+
- { os: ubuntu-latest, python_version: "3.12" }
49+
- { os: ubuntu-latest, python_version: "3.13" }
50+
- { os: ubuntu-latest, python_version: "3.14" }
51+
# macOS and Windows: min and max supported.
52+
- { os: macos-latest, python_version: "3.10" }
53+
- { os: macos-latest, python_version: "3.14" }
54+
- { os: windows-latest, python_version: "3.10" }
55+
- { os: windows-latest, python_version: "3.14" }
2556
steps:
2657
- name: Checkout code
2758
uses: actions/checkout@v6
2859
with:
29-
ref: ${{ github.event.pull_request.head.sha }}
60+
ref: ${{ github.event.pull_request.head.sha || github.sha }}
61+
3062
- name: Install Python ${{ matrix.python_version }}
3163
uses: actions/setup-python@v6
3264
with:
33-
python-version: ${{ matrix.python_version }}
34-
allow-prereleases: true
35-
cache: "pip"
65+
python-version: ${{ matrix.python_version }}
66+
allow-prereleases: true
67+
cache: "pip"
3668

37-
- name: Cache pip packages
38-
uses: actions/cache@v5
69+
- name: Cache uv (built wheels — scipy/numpy/pandas source builds)
70+
uses: actions/cache@v4
3971
with:
40-
path: ~/.cache/pip
41-
key: ${{ runner.os }}-pip-${{ matrix.python_version }}-${{ hashFiles('cli/poetry.lock') }}
72+
path: ${{ github.workspace }}/.uv-cache
73+
key: uv-${{ runner.os }}-py${{ matrix.python_version }}-${{ hashFiles('cli/pyproject.toml', 'cli/uv.lock', 'openbb_platform/core/pyproject.toml', 'openbb_platform/obbject_extensions/charting/pyproject.toml', 'openbb_platform/extensions/devtools/pyproject.toml') }}
4274
restore-keys: |
43-
${{ runner.os }}-pip-
75+
uv-${{ runner.os }}-py${{ matrix.python_version }}-
4476
45-
- name: Run tests
77+
- name: Install gfortran + OpenBLAS (macOS, prerelease Python — scipy source build)
78+
if: runner.os == 'macOS' && matrix.python_version == '3.15'
79+
shell: bash
80+
working-directory: .
4681
run: |
47-
pip install nox
48-
nox -f .github/scripts/noxfile.py -s unit_test_cli --python ${{ matrix.python_version }}
82+
set -euo pipefail
83+
brew install gcc openblas pkg-config
84+
GFORTRAN_BIN=$(ls /opt/homebrew/opt/gcc/bin/gfortran-* | tail -1)
85+
GFORTRAN_DIR=$(dirname "$GFORTRAN_BIN")
86+
ln -sf "$GFORTRAN_BIN" "$GFORTRAN_DIR/gfortran"
87+
echo "$GFORTRAN_DIR" >> "$GITHUB_PATH"
88+
"$GFORTRAN_DIR/gfortran" --version
89+
OPENBLAS_PC="$(brew --prefix openblas)/lib/pkgconfig"
90+
echo "PKG_CONFIG_PATH=$OPENBLAS_PC" >> "$GITHUB_ENV"
91+
PKG_CONFIG_PATH="$OPENBLAS_PC" pkg-config --modversion openblas
92+
93+
- name: Install gfortran (Linux, prerelease Python — scipy source build)
94+
if: runner.os == 'Linux' && matrix.python_version == '3.15'
95+
shell: bash
96+
working-directory: .
97+
run: |
98+
set -euo pipefail
99+
sudo apt-get update -y
100+
sudo apt-get install -y gfortran libopenblas-dev liblapack-dev
101+
gfortran --version
102+
103+
- name: Install openbb-cli
104+
run: |
105+
python -m pip install --upgrade pip uv
106+
python -m uv pip install --system -e ".[charting]" --group dev
107+
108+
- name: Run unit tests
109+
run: |
110+
python -m pytest tests \
111+
--cov=openbb_cli \
112+
--cov-config=.coveragerc \
113+
--cov-report=term-missing \
114+
--cov-report=xml:coverage-unit.xml
115+
116+
- name: Upload unit-test coverage artifact
117+
if: always()
118+
uses: actions/upload-artifact@v4
119+
with:
120+
name: openbb-cli-coverage-unit-${{ matrix.os }}-py${{ matrix.python_version }}
121+
path: cli/coverage-unit.xml

cli/.coveragerc

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
[run]
2+
branch = False
3+
parallel = True
4+
source = openbb_cli
5+
data_file = .coverage
6+
omit =
7+
openbb_cli/cli.py
8+
openbb_cli/assets/**
9+
tests/*
10+
integration/*
11+
12+
[paths]
13+
source =
14+
openbb_cli
15+
*/site-packages/openbb_cli
16+
*/cli/openbb_cli
17+
18+
[report]
19+
show_missing = True
20+
skip_covered = False
21+
exclude_lines =
22+
pragma: no cover
23+
if TYPE_CHECKING:
24+
if __name__ == .__main__.:
25+
raise NotImplementedError

0 commit comments

Comments
 (0)