Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: initial support for poetry build tool #4513

Merged
merged 10 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) # 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
Loading