Skip to content

Commit

Permalink
Merge pull request #26 from fengsh27/main
Browse files Browse the repository at this point in the history
create ci for pull request
  • Loading branch information
slobentanzer authored Nov 11, 2023
2 parents 5046f2b + 0c7b3da commit e76e7c6
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 5 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: biochatter Continuous Integration

on: [pull_request, push]

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.11

- name: Install Docker
run: |
sudo apt remove containerd.io
sudo apt install -y docker.io
- name: Install Docker Compose
run: |
sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
- name: Install Poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -
- name: Install dependencies
run: |
poetry install
poetry install -E podcast
- name: Start Milvus server
run: |
docker-compose -f milvus-docker-compose.yml up -d
- name: Set API key
run: |
echo ${{ secrets.OPENAI_API_KEY }} > api_key.txt
echo ${{ secrets.AZURE_TEST_OPENAI_MODEL_NAME }} > azure_test_model.txt
echo ${{ secrets.AZURE_TEST_OPENAI_DEPLOYMENT_NAME }} > azure_test_deployment.txt
echo ${{ secrets.AZURE_TEST_OPENAI_API_VERSION }} > azure_test_api_version.txt
echo ${{ secrets.AZURE_TEST_OPENAI_API_BASE }} > azure_test_api_base.txt
echo ${{ secrets.AZURE_TEST_OPENAI_API_KEY }} > azure_test_api_key.txt
- name: Set environment variable
run: |
echo "OPENAI_API_KEY=$(cat api_key.txt)" >> $GITHUB_ENV
echo "AZURE_TEST_OPENAI_MODEL_NAME=$(cat azure_test_model.txt)" >> $GITHUB_ENV
echo "AZURE_TEST_OPENAI_DEPLOYMENT_NAME=$(cat azure_test_deployment.txt)" >> $GITHUB_ENV
echo "AZURE_TEST_OPENAI_API_VERSION=$(cat azure_test_api_version.txt)" >> $GITHUB_ENV
echo "AZURE_TEST_OPENAI_API_BASE=$(cat azure_test_api_base.txt)" >> $GITHUB_ENV
echo "AZURE_TEST_OPENAI_API_KEY=$(cat azure_test_api_key.txt)" >> $GITHUB_ENV
- name: Run tests
run: |
poetry run pytest --ignore=./volumes
47 changes: 47 additions & 0 deletions milvus-docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@

version: '3.5'

services:
etcd:
container_name: milvus-etcd
image: quay.io/coreos/etcd:v3.5.5
environment:
- ETCD_AUTO_COMPACTION_MODE=revision
- ETCD_AUTO_COMPACTION_RETENTION=1000
- ETCD_QUOTA_BACKEND_BYTES=4294967296
- ETCD_SNAPSHOT_COUNT=50000
volumes:
- ${DOCKER_VOLUME_DIRECTORY:-.}/volumes/etcd:/etcd
command: etcd -advertise-client-urls=http://127.0.0.1:2379 -listen-client-urls http://0.0.0.0:2379 --data-dir /etcd

minio:
container_name: milvus-minio
image: minio/minio:RELEASE.2022-03-17T06-34-49Z
environment:
MINIO_ACCESS_KEY: minioadmin
MINIO_SECRET_KEY: minioadmin
volumes:
- ${DOCKER_VOLUME_DIRECTORY:-.}/volumes/minio:/minio_data
command: minio server /minio_data
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
interval: 30s
timeout: 20s
retries: 3

standalone:
container_name: milvus-standalone
image: milvusdb/milvus:v2.2.8
command: ["milvus", "run", "standalone"]
environment:
ETCD_ENDPOINTS: etcd:2379
MINIO_ADDRESS: minio:9000
volumes:
- ${DOCKER_VOLUME_DIRECTORY:-.}/volumes/milvus:/var/lib/milvus
ports:
- "19530:19530"
- "9091:9091"
depends_on:
- "etcd"
- "minio"

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

[tool.black]
line-length = 80
line-length = 80
2 changes: 1 addition & 1 deletion test/test_llm_connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ def test_azure_raises_request_error():
with pytest.raises(NotFoundError):
convo.set_api_key("fake_key")


def test_azure():
"""
Test OpenAI Azure endpoint functionality. Azure connectivity is enabled by
Expand All @@ -122,3 +121,4 @@ def test_azure():
)

assert convo.set_api_key(os.getenv("AZURE_TEST_OPENAI_API_KEY"))

4 changes: 1 addition & 3 deletions test/test_vectorstore_host.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
from biochatter.vectorstore_host import VectorDatabaseHostMilvus

"""
This test needs OPENAI_API_KEY in the environment and a local milvus server. The
entire module needs to be run in one go, as the collections are created and
called in different tests.
This test needs OPENAI_API_KEY in the environment and a local milvus server.
"""

# setup milvus connection
Expand Down

0 comments on commit e76e7c6

Please sign in to comment.