Skip to content

Commit

Permalink
build: initial support for poetry build tool (#4513)
Browse files Browse the repository at this point in the history
Co-authored-by: Bowen Liang <bowenliang@apache.org>
  • Loading branch information
MatriQ and bowenliang123 committed Jun 11, 2024
1 parent f426e1b commit f62f71a
Show file tree
Hide file tree
Showing 6 changed files with 7,403 additions and 3 deletions.
72 changes: 72 additions & 0 deletions .github/workflows/api-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,75 @@ jobs:
- name: Test Vector Stores
run: dev/pytest/pytest_vdb.sh

test-in-poetry:
runs-on: ubuntu-latest
strategy:
matrix:
python-version:
- "3.10"
- "3.11"

steps:
- name: Install poetry
uses: abatilo/actions-poetry@v3
with:
poetry-version: "1.8.1"

- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'poetry'
cache-dependency-path: ./api/poetry.lock

- name: Poetry check
run: poetry check -C api

- name: Install dependencies
run: poetry install -C api

- name: Run Unit tests
run: poetry run -C api bash dev/pytest/pytest_unit_tests.sh

- name: Run ModelRuntime
run: poetry run -C api bash dev/pytest/pytest_model_runtime.sh

- name: Run Tool
run: poetry run -C api bash dev/pytest/pytest_tools.sh

- name: Set up Sandbox
uses: hoverkraft-tech/compose-action@v2.0.0
with:
compose-file: |
docker/docker-compose.middleware.yaml
services: |
sandbox
ssrf_proxy
- name: Run Workflow
run: poetry run -C api bash dev/pytest/pytest_workflow.sh

- name: Set up Vector Stores (Weaviate, Qdrant, PGVector, Milvus, PgVecto-RS)
uses: hoverkraft-tech/compose-action@v2.0.0
with:
compose-file: |
docker/docker-compose.middleware.yaml
docker/docker-compose.qdrant.yaml
docker/docker-compose.milvus.yaml
docker/docker-compose.pgvecto-rs.yaml
docker/docker-compose.pgvector.yaml
services: |
weaviate
qdrant
etcd
minio
milvus-standalone
pgvecto-rs
pgvector
- name: Test Vector Stores
run: poetry run -C api bash dev/pytest/pytest_vdb.sh
6 changes: 4 additions & 2 deletions api/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"FLASK_DEBUG": "1",
"GEVENT_SUPPORT": "True"
},
"console": "integratedTerminal"
"console": "integratedTerminal",
"python": "${command:python.interpreterPath}"
},
{
"name": "Python: Flask",
Expand All @@ -36,7 +37,8 @@
"--debug"
],
"jinja": true,
"justMyCode": true
"justMyCode": true,
"python": "${command:python.interpreterPath}"
}
]
}
17 changes: 16 additions & 1 deletion api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,30 @@
```bash
sed -i "/^SECRET_KEY=/c\SECRET_KEY=$(openssl rand -base64 42)" .env
```
4. If you use Anaconda, create a new environment and activate it
4. Create environment.
- Anaconda
If you use Anaconda, create a new environment and activate it
```bash
conda create --name dify python=3.10
conda activate dify
```
- Poetry
If you use Poetry, you don't need to manually create the environment. You can execute `poetry shell` to activate the environment.
5. Install dependencies
- Anaconda
```bash
pip install -r requirements.txt
```
- Poetry
```bash
poetry install
```
In case of contributors missing to update dependencies for `pyproject.toml`, you can perform the following shell instead.
```base
poetry shell # activate current environment
poetry add $(cat requirements.txt) # install dependencies of production and update pyproject.toml
poetry add $(cat requirements-dev.txt) --group dev # install dependencies of development and update pyproject.toml
```
6. Run migrate

Before the first launch, migrate the database to the latest version.
Expand Down
Loading

0 comments on commit f62f71a

Please sign in to comment.