-
Notifications
You must be signed in to change notification settings - Fork 27
Install pgvector on CI #225
Changes from all commits
dafaf19
ffeec29
e87bf84
7f36dd9
bc7a67e
1333f38
51280b2
8f935a5
44f92e0
52e5f02
d32d229
a548b1f
db1461f
ee155c1
239491f
5d3f11e
bf0af2e
dcb9595
c6866b9
1bd2eed
d0c315c
b1a5833
54ddd1b
f496178
78eb7d3
a059f21
db28bb9
5a9cfbf
a56034c
3e744d0
b1117a5
5b19116
51214ce
2d8fefb
06e876c
2939c7b
7f8a0ab
6ed522c
e992dc3
893995d
98566f5
58a0cfe
1daa435
ecfde8a
c0b021e
32e7172
226e623
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: Test Postgres | ||
name: Test | ||
|
||
on: | ||
push: | ||
|
@@ -8,81 +8,42 @@ on: | |
paths-ignore: | ||
- "*.md" | ||
|
||
env: | ||
PGPASSWORD: postgres | ||
TESTDB: greenplum_python_test | ||
PGUSER: postgres | ||
|
||
jobs: | ||
build: | ||
name: Test Python${{ matrix.python-version }}, PSQL${{matrix.postgres-version}} | ||
name: python${{ matrix.python-version }}; ${{ matrix.server }} | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
fail-fast: true | ||
matrix: | ||
python-version: ["3.9", "3.10"] | ||
postgres-version: ['12', '13'] | ||
python-version: ["3.9", "3.11"] | ||
server: ["postgres12-python39", "postgres12-python311"] | ||
include: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. did you host the container in dockerhub? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, the image is built locally when running
Comment on lines
+18
to
+19
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. python3.9 and python3.11 pg-3.9 and pg-3.11 these are four different jobs am I right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, 4 jobs in total. |
||
- tox_test: "test_py39" | ||
python-version: "3.9" | ||
- tox_test: "test_py310" | ||
python-version: "3.10" | ||
- dill_version: python3.9 | ||
postgres-version: '12' | ||
- dill_version: python3.9 | ||
postgres-version: '13' | ||
|
||
services: | ||
postgres: | ||
# we need postgres with plpython extension postgres base docker hub image did not have that | ||
# I use this one | ||
# image: yihong0618/postgres-plpython:${{ matrix.postgres-version }} | ||
image: thorinschiffer/postgres-plpython:${{ matrix.postgres-version }} | ||
env: | ||
POSTGRES_USER: ${{ env.PGUSER }} | ||
POSTGRES_PASSWORD: ${{ env.PGPASSWORD }} | ||
POSTGRES_DB: ${{ env.TESTDB }} | ||
ports: | ||
- 5432:5432 | ||
options: --name postgres | ||
- server: "postgres12-python39" | ||
server-python-version: "3.9" | ||
- server: "postgres12-python311" | ||
server-python-version: "3.11" | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
- name: Setup python on client | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
cache: pip | ||
- name: Create plpython3u language and environment | ||
run: | | ||
psql postgres://${{ env.PGUSER }}:${{ env.PGPASSWORD }}@localhost/${{ env.TESTDB }} -c "CREATE LANGUAGE plpython3u;" | ||
- name: Install Dependencies | ||
run: | | ||
pip install tox==3.25.0 | ||
|
||
- name: List all containers | ||
run: docker ps -a | ||
|
||
- name: Install Python in PostgreSQL server container | ||
run: | | ||
docker exec --user 0 postgres sh -c 'apt-get update && apt-get install -y python3-pip && mkdir -p $(su --login postgres --session-command "python3 -m site --user-site") && chown -R postgres /var/lib/postgresql' | ||
|
||
- name: Run Tests | ||
run: | | ||
export POSTGRES_PASSWORD=${{ env.PGPASSWORD }} | ||
export POSTGRES_USER=${{ env.PGUSER }} | ||
export POSTGRES_DB=${{ env.TESTDB }} | ||
tox -e ${{ matrix.tox_test }} | ||
|
||
- name: Install Dependencies for greenplumpython dill | ||
# plpytyhon for postgres install to pg services | ||
- name: Run tests without pickler | ||
run: | | ||
pip install pip install --target=. dill | ||
docker cp dill $(docker ps -q):/usr/lib/${{ matrix.dill_version }}/ | ||
rm -rf dill pip | ||
- name: Run Tests with dill | ||
python3 -m pip install tox~=4.11 tox-docker~=4.1 && \ | ||
tox \ | ||
--override=docker:server.dockerfile=server/${{ matrix.server }}.Dockerfile \ | ||
-e test-container \ | ||
-- \ | ||
--override-ini=server_use_pickler=false \ | ||
--ignore=tests/test_use_pickler.py \ | ||
- name: Run tests with pickler if python versions match | ||
if: ${{ matrix.python-version == matrix.server-python-version }} | ||
run: | | ||
export POSTGRES_PASSWORD=${{ env.PGPASSWORD }} | ||
export POSTGRES_USER=${{ env.PGUSER }} | ||
export POSTGRES_DB=${{ env.TESTDB }} | ||
tox -e ${{ matrix.tox_test }} | ||
tox \ | ||
--override=docker:server.dockerfile=server/${{ matrix.server }}.Dockerfile \ | ||
-e test-container \ | ||
-- \ | ||
--override-ini=server_use_pickler=true \ |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
include versioneer.py | ||
include greenplumpython/_version.py | ||
include greenplumpython/VERSION |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,10 +4,10 @@ | |
|
||
### [tox](https://tox.wiki) | ||
|
||
Install with `pip`: | ||
We use tox as the task runner. Tox can be installed with | ||
|
||
``` | ||
pip install tox | ||
python3 -m pip install tox | ||
``` | ||
|
||
Install with `brew` on macOS: | ||
|
@@ -36,16 +36,16 @@ The tests will create connection to the Greenplum cluster. So the `PGPORT` needs | |
export PGPORT=6000 | ||
``` | ||
|
||
Test with the default python version: | ||
Test with the default python version and a local database server: | ||
|
||
``` | ||
tox -e test | ||
``` | ||
|
||
Test with specified officially supported version: | ||
|
||
To run tests against a database server in container: | ||
``` | ||
tox -e test_py39 | ||
python3 -m pip install tox-docker | ||
tox -e test-container | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this start a container automatically? It doesn't with my testing. How is this supposed to work? like: building image->creating container->running test? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, it will start the container automatically before running tests. From the CI build, we should see the following lines when running
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The workflow is as follows:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It fails on my machine:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Have you installed tox-docker? Could you please share the result of
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Then I met antoher error. Python3.11. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Why it builds a python39 image, but runs a python311 tests? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This means the server uses python3.9, while the client uses python3.11. In this case the python versions don't match so dill will not work. In that case, the CI skips There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK, so when running docker test, the client is not running in the container, only the pg server, correct? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, that's correct. |
||
``` | ||
|
||
Run a specified test case(s): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
black==22.3.0 | ||
isort==5.10.1 | ||
pytest==7.0.1 | ||
pglast==3.10 | ||
pyright==1.1.250 | ||
pandas |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
-r requirements.txt | ||
sphinx==5.1.1 | ||
sphinx_rtd_theme==1.0.0 | ||
nbsphinx | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/bin/bash | ||
|
||
set -o nounset -o xtrace -o errexit -o pipefail | ||
|
||
PG_MAJOR_VERSION=$(pg_config --version | grep --only-matching --extended-regexp '[0-9]+' | head -n 1) | ||
export DEBIAN_FRONTEND=nointeractive | ||
apt-get update | ||
apt-get install --no-install-recommends -y \ | ||
postgresql-plpython3-"$PG_MAJOR_VERSION" \ | ||
postgresql-"$PG_MAJOR_VERSION"-pgvector \ | ||
python3-pip \ | ||
python3-venv | ||
apt-get autoclean | ||
|
||
POSTGRES_USER_SITE=$(su --login postgres --session-command "python3 -m site --user-site") | ||
POSTGRES_USER_BASE=$(su --login postgres --session-command "python3 -m site --user-base") | ||
mkdir --parents "$POSTGRES_USER_SITE" | ||
chown --recursive postgres "$POSTGRES_USER_BASE" | ||
|
||
cp /tmp/initdb.sh /docker-entrypoint-initdb.d | ||
chown postgres /docker-entrypoint-initdb.d/* |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
|
||
set -o nounset -o xtrace -o errexit -o pipefail | ||
|
||
{ | ||
echo "logging_collector = ON" | ||
echo "log_statement = 'all'" | ||
echo "log_destination = 'csvlog'" | ||
} >>"$PGDATA"/postgresql.conf | ||
|
||
python3 -m venv "$HOME"/venv | ||
source "$HOME"/venv/bin/activate |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
FROM postgres:12-bookworm | ||
|
||
COPY build.sh initdb.sh /tmp/ | ||
RUN bash /tmp/build.sh | ||
|
||
HEALTHCHECK --interval=1s --timeout=1s --start-period=1s --retries=30 CMD psql \ | ||
--single-transaction \ | ||
--user=$POSTGRES_USER \ | ||
--dbname=$POSTGRES_DB \ | ||
--host=localhost \ | ||
--command="SELECT version();" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
FROM postgres:12-bullseye | ||
|
||
COPY build.sh initdb.sh /tmp/ | ||
RUN bash /tmp/build.sh | ||
|
||
HEALTHCHECK --interval=1s --timeout=1s --start-period=1s --retries=30 CMD psql \ | ||
--single-transaction \ | ||
--user=$POSTGRES_USER \ | ||
--dbname=$POSTGRES_DB \ | ||
--host=localhost \ | ||
--command="SELECT version();" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import pytest | ||
|
||
|
||
def pytest_addoption(parser: pytest.Parser): | ||
parser.addini( | ||
"server_use_pickler", | ||
type="bool", | ||
default=True, | ||
help="Use pickler to deserialize UDFs on server.", | ||
) | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def server_use_pickler(pytestconfig: pytest.Config) -> bool: | ||
val: bool = pytestconfig.getini("server_use_pickler") | ||
return val |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice change