Skip to content

Commit c69b269

Browse files
authored
Merge pull request #182 from chdb-io/prAction
Run fast build and linter and tests on self hosted machine on Pull Request
2 parents dc29e0a + 700751c commit c69b269

20 files changed

+121
-259
lines changed

.all-contributorsrc

Lines changed: 0 additions & 62 deletions
This file was deleted.

.github/workflows/auto_release.yml

Lines changed: 0 additions & 45 deletions
This file was deleted.

.github/workflows/build_wheels.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,17 @@ on:
88
required: true
99
release:
1010
types: [created]
11-
pull_request:
12-
types: [opened, reopened]
13-
paths-ignore:
14-
- '**/.md'
11+
# push:
12+
# branches:
13+
# - main
14+
# paths-ignore:
15+
# - '**/*.md'
16+
# pull_request:
17+
# branches:
18+
# - main
19+
# paths-ignore:
20+
# - '**/*.md'
21+
1522

1623
jobs:
1724
build_wheels_linux:

.github/workflows/libfuzzer.yml

Lines changed: 0 additions & 95 deletions
This file was deleted.

.github/workflows/pr_ci.yaml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Pull-CI
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize]
6+
7+
jobs:
8+
build:
9+
env:
10+
PYTHON_VERSIONS: "3.11"
11+
12+
runs-on: self-hosted
13+
steps:
14+
- name: Check for chdb directory
15+
run: |
16+
if [ ! -d "/home/ubuntu/pr_runner/chdb" ]; then
17+
echo "chdb directory does not exist. Checkout the repository."
18+
mkdir -p /home/ubuntu/pr_runner/
19+
git clone https://github.com/chdb-io/chdb.git /home/ubuntu/pr_runner/chdb
20+
fi
21+
22+
- name: Check for ccache status
23+
run: |
24+
ccache -sv
25+
26+
- name: Copy submodules
27+
run: cp -a /builder_cache/contrib /home/ubuntu/pr_runner/chdb/
28+
29+
- name: Cleanup and update chdb directory
30+
run: |
31+
cd /home/ubuntu/pr_runner/chdb
32+
git fetch origin || true
33+
git reset --hard origin/${{ github.head_ref }} || true
34+
git clean -fdx || true
35+
git checkout -f --progress ${{ github.head_ref }} || true
36+
git status -v || true
37+
continue-on-error: true
38+
39+
- name: Code style check
40+
run: |
41+
export PYENV_ROOT="$HOME/.pyenv"
42+
[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"
43+
eval "$(pyenv init -)"
44+
pyenv local 3.11
45+
python3 -m pip install flake8
46+
cd chdb && python3 -m flake8
47+
working-directory: /home/ubuntu/pr_runner/chdb
48+
49+
- name: Cleanup dist directory
50+
run: rm -rf /home/ubuntu/pr_runner/chdb/dist/*
51+
52+
- name: Set PYTHON_VERSIONS environment variable
53+
run: echo "PYTHON_VERSIONS=3.11" >> $GITHUB_ENV
54+
55+
- name: Run build script
56+
run: bash -x ./chdb/build_linux_arm64.sh
57+
working-directory: /home/ubuntu/pr_runner/chdb
58+
59+
- name: Check ccache statistics
60+
run: |
61+
ccache -s
62+
ls -lh chdb
63+
df -h
64+
working-directory: /home/ubuntu/pr_runner/chdb
65+
66+
- name: Audit wheels
67+
run: |
68+
export PYENV_ROOT="$HOME/.pyenv"
69+
[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"
70+
eval "$(pyenv init -)"
71+
pyenv local 3.11
72+
ls -lh dist
73+
python3 -m pip install auditwheel
74+
python3 -m auditwheel -v repair -w dist/ --plat manylinux_2_17_aarch64 dist/*.whl
75+
working-directory: /home/ubuntu/pr_runner/chdb

.github/workflows/pull_request_approved.yml

Lines changed: 0 additions & 23 deletions
This file was deleted.

chdb/.flake8

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[flake8]
2+
max-line-length = 130
3+
extend-ignore = E722

chdb/__init__.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@
22
import os
33

44

5+
class ChdbError(Exception):
6+
"""Base class for exceptions in this module."""
7+
8+
59
_arrow_format = set({"dataframe", "arrowtable"})
610
_process_result_format_funs = {
7-
"dataframe" : lambda x : to_df(x),
8-
"arrowtable": lambda x : to_arrowTable(x)
9-
}
11+
"dataframe": lambda x: to_df(x),
12+
"arrowtable": lambda x: to_arrowTable(x)
13+
}
1014

1115
# If any UDF is defined, the path of the UDF will be set to this variable
1216
# and the path will be deleted when the process exits
@@ -33,7 +37,7 @@
3337
# Change here if project is renamed and does not equal the package name
3438
dist_name = __name__
3539
__version__ = ".".join(map(str, chdb_version))
36-
except: # pragma: no cover
40+
except: # noqa
3741
__version__ = "unknown"
3842

3943

@@ -42,8 +46,8 @@ def to_arrowTable(res):
4246
"""convert res to arrow table"""
4347
# try import pyarrow and pandas, if failed, raise ImportError with suggestion
4448
try:
45-
import pyarrow as pa
46-
import pandas
49+
import pyarrow as pa # noqa
50+
import pandas as pd # noqa
4751
except ImportError as e:
4852
print(f"ImportError: {e}")
4953
print('Please install pyarrow and pandas via "pip install pyarrow pandas"')
@@ -66,10 +70,14 @@ def query(sql, output_format="CSV", path="", udf_path=""):
6670
if udf_path != "":
6771
g_udf_path = udf_path
6872
lower_output_format = output_format.lower()
69-
result_func = _process_result_format_funs.get(lower_output_format, lambda x : x)
73+
result_func = _process_result_format_funs.get(lower_output_format, lambda x: x)
7074
if lower_output_format in _arrow_format:
7175
output_format = "Arrow"
7276
res = _chdb.query(sql, output_format, path=path, udf_path=g_udf_path)
7377
if res.has_error():
74-
raise Exception(res.error_message())
78+
raise ChdbError(res.error_message())
7579
return result_func(res)
80+
81+
82+
__all__ = ["ChdbError", "query", "chdb_version",
83+
"engine_version", "to_df", "to_arrowTable"]

0 commit comments

Comments
 (0)