Skip to content

Commit 24e84c7

Browse files
author
longbingljw
authored
fix:ci test (#47)
* fix * fix * fix * fix * fix * fix
1 parent 3dd1151 commit 24e84c7

File tree

18 files changed

+84
-174
lines changed

18 files changed

+84
-174
lines changed

.github/workflows/vdb-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ jobs:
8484
chroma
8585
elasticsearch
8686
oceanbase
87-
87+
compose-flags: "--profile oceanbase --profile weaviate --profile qdrant --profile couchbase --profile milvus --profile pgvector --profile pgvecto-rs --profile chroma --profile elasticsearch"
8888
- name: setup test config
8989
run: |
9090
echo $(pwd)

api/controllers/console/app/wraps.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
def _load_app_model(app_id: str) -> Optional[App]:
1313
assert isinstance(current_user, Account)
14+
if current_user is None:
15+
return None
1416
app_model = (
1517
db.session.query(App)
1618
.where(App.id == app_id, App.tenant_id == current_user.current_tenant_id, App.status == "normal")
@@ -19,15 +21,6 @@ def _load_app_model(app_id: str) -> Optional[App]:
1921
return app_model
2022

2123

22-
def _load_app_model(app_id: str) -> Optional[App]:
23-
app_model = (
24-
db.session.query(App)
25-
.filter(App.id == app_id, App.tenant_id == current_user.current_tenant_id, App.status == "normal")
26-
.first()
27-
)
28-
return app_model
29-
30-
3124
def get_app_model(view: Optional[Callable] = None, *, mode: Union[AppMode, list[AppMode], None] = None):
3225
def decorator(view_func):
3326
@wraps(view_func)

api/core/entities/model_entities.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -76,25 +76,6 @@ def raise_for_status(self) -> None:
7676
if self.status in error_messages:
7777
raise ValueError(error_messages[self.status])
7878

79-
def raise_for_status(self) -> None:
80-
"""
81-
Check model status and raise ValueError if not active.
82-
83-
:raises ValueError: When model status is not active, with a descriptive message
84-
"""
85-
if self.status == ModelStatus.ACTIVE:
86-
return
87-
88-
error_messages = {
89-
ModelStatus.NO_CONFIGURE: "Model is not configured",
90-
ModelStatus.QUOTA_EXCEEDED: "Model quota has been exceeded",
91-
ModelStatus.NO_PERMISSION: "No permission to use this model",
92-
ModelStatus.DISABLED: "Model is disabled",
93-
}
94-
95-
if self.status in error_messages:
96-
raise ValueError(error_messages[self.status])
97-
9879

9980
class ModelWithProviderEntity(ProviderModelWithStatusEntity):
10081
"""

api/core/rag/datasource/vdb/pgvector/pgvector.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import logging
44
import uuid
55
from contextlib import contextmanager
6-
from typing import Any
6+
from typing import Any, Optional
77

88
import psycopg2.errors
99
import psycopg2.extras # type: ignore
@@ -68,6 +68,8 @@ def validate_config(cls, values: dict) -> dict:
6868
USING hnsw (embedding vector_cosine_ops) WITH (m = 16, ef_construction = 64);
6969
"""
7070

71+
SQL_CREATE_INDEX_PG_BIGM: Optional[str]
72+
7173
if dify_config.SQLALCHEMY_DATABASE_URI_SCHEME == "postgresql":
7274
SQL_CREATE_INDEX_PG_BIGM = """
7375
CREATE INDEX IF NOT EXISTS bigm_idx_{index_hash} ON {table_name}
@@ -264,7 +266,7 @@ def _create_collection(self, dimension: int):
264266
# ref: https://github.com/pgvector/pgvector?tab=readme-ov-file#indexing
265267
if dimension <= 2000:
266268
cur.execute(SQL_CREATE_INDEX.format(table_name=self.table_name, index_hash=self.index_hash))
267-
if self.pg_bigm:
269+
if self.pg_bigm and SQL_CREATE_INDEX_PG_BIGM is not None:
268270
cur.execute(SQL_CREATE_INDEX_PG_BIGM.format(table_name=self.table_name, index_hash=self.index_hash))
269271
redis_client.set(collection_exist_cache_key, 1, ex=3600)
270272

api/extensions/ext_migrate.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ def init_app(app: DifyApp):
1010
# Migration directory has to be mannually specified since mergeing 1.8.0,
1111
# haven't found why yet
1212
if "mysql" in dify_config.SQLALCHEMY_DATABASE_URI_SCHEME:
13-
directory="migrations-mysql"
13+
directory = "migrations-mysql"
14+
else:
15+
directory = "migrations"
1416

1517
flask_migrate.Migrate(app, db, directory=directory)

api/extensions/ext_redis.py

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ class RedisClientWrapper:
4343
if the client is not initialized.
4444
"""
4545

46-
_client: Union[redis.Redis, RedisCluster, None]
46+
_client: Union[redis.Redis, RedisCluster, Any, None]
4747

4848
def __init__(self) -> None:
4949
self._client = None
5050

51-
def initialize(self, client: Union[redis.Redis, RedisCluster]) -> None:
51+
def initialize(self, client: Union[redis.Redis, RedisCluster, Any]) -> None:
5252
if self._client is None:
5353
self._client = client
5454

@@ -253,25 +253,6 @@ def _create_standalone_client(redis_params: dict[str, Any]) -> Union[redis.Redis
253253
return client
254254

255255

256-
def init_app(app: DifyApp):
257-
"""Initialize Redis client and attach it to the app."""
258-
global redis_client
259-
260-
# Determine Redis mode and create appropriate client
261-
if dify_config.REDIS_USE_SENTINEL:
262-
redis_params = _get_base_redis_params()
263-
client = _create_sentinel_client(redis_params)
264-
elif dify_config.REDIS_USE_CLUSTERS:
265-
client = _create_cluster_client()
266-
else:
267-
redis_params = _get_base_redis_params()
268-
client = _create_standalone_client(redis_params)
269-
270-
# Initialize the wrapper and attach to app
271-
redis_client.initialize(client)
272-
app.extensions["redis"] = redis_client
273-
274-
275256
def redis_fallback(default_return: Optional[Any] = None):
276257
"""
277258
decorator to handle Redis operation exceptions and return a default value when Redis is unavailable.

api/migrations-mysql/env.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010

1111
# Interpret the config file for Python logging.
1212
# This line sets up loggers basically.
13-
fileConfig(config.config_file_name)
13+
if config.config_file_name:
14+
fileConfig(config.config_file_name)
1415
logger = logging.getLogger('alembic.env')
1516

1617

api/migrations-mysql/versions/15d91fcf3eb9_fix_table.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212

1313
# revision identifiers, used by Alembic.
1414
revision = '15d91fcf3eb9'
15-
down_revision = '4ce39f688dc4'
16-
branch_labels = None
17-
depends_on = None
15+
down_revision: str | None = '4ce39f688dc4'
16+
branch_labels: str | None = None
17+
depends_on: str | None = None
1818

1919

2020
def upgrade():

api/migrations-mysql/versions/37c2bb41f84a_update_mcp_servers_and_tools.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212

1313
# revision identifiers, used by Alembic.
1414
revision = '37c2bb41f84a'
15-
down_revision = 'e0e5dc8aa037'
16-
branch_labels = None
17-
depends_on = None
15+
down_revision: str | None = 'e0e5dc8aa037'
16+
branch_labels: str | None = None
17+
depends_on: str | None = None
1818

1919

2020
def upgrade():
@@ -73,7 +73,7 @@ def upgrade():
7373
sa.UniqueConstraint('app_id', 'node_id', 'name', name=op.f('workflow_draft_variables_app_id_key'))
7474
)
7575
with op.batch_alter_table('workflow_node_executions', schema=None) as batch_op:
76-
batch_op.create_index(batch_op.f('workflow_node_executions_tenant_id_idx'), ['tenant_id', 'workflow_id', 'node_id', sa.literal_column('created_at DESC')], unique=False)
76+
batch_op.create_index(batch_op.f('workflow_node_executions_tenant_id_idx'), ['tenant_id', 'workflow_id', 'node_id', 'created_at'], unique=False)
7777

7878
with op.batch_alter_table('workflow_runs', schema=None) as batch_op:
7979
batch_op.drop_index(batch_op.f('workflow_run_tenant_app_sequence_idx'))

api/migrations-mysql/versions/4ce39f688dc4_1_8_0.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212

1313
# revision identifiers, used by Alembic.
1414
revision = '4ce39f688dc4'
15-
down_revision = '7aefe33a8deb'
16-
branch_labels = None
17-
depends_on = None
15+
down_revision: str | None = '7aefe33a8deb'
16+
branch_labels: str | None = None
17+
depends_on: str | None = None
1818

1919

2020
def upgrade():

0 commit comments

Comments
 (0)