Skip to content

Commit

Permalink
chore(db): Make migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
laipz8200 committed Jul 22, 2024
1 parent 5dbb90b commit 768b992
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 3 deletions.
1 change: 1 addition & 0 deletions api/core/model_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,7 @@ def __init__(self, tenant_id: str,
for load_balancing_config in self._load_balancing_configs:
if load_balancing_config.name == "__inherit__":
if not managed_credentials:
# FIXME: Mutation to loop iterable `self._load_balancing_configs` during iteration
# remove __inherit__ if managed credentials is not provided
self._load_balancing_configs.remove(load_balancing_config)
else:
Expand Down
1 change: 1 addition & 0 deletions api/core/rag/datasource/keyword/keyword_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def _filter_duplicate_texts(self, texts: list[Document]) -> list[Document]:
doc_id = text.metadata['doc_id']
exists_duplicate_node = self.text_exists(doc_id)
if exists_duplicate_node:
# FIXME: Mutation to loop iterable `texts` during iteration
texts.remove(text)

return texts
Expand Down
1 change: 1 addition & 0 deletions api/core/rag/datasource/vdb/vector_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def _filter_duplicate_texts(self, texts: list[Document]) -> list[Document]:
doc_id = text.metadata['doc_id']
exists_duplicate_node = self.text_exists(doc_id)
if exists_duplicate_node:
# FIXME: Mutation to loop iterable `texts` during iteration
texts.remove(text)

return texts
Expand Down
1 change: 1 addition & 0 deletions api/core/rag/datasource/vdb/vector_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ def _filter_duplicate_texts(self, texts: list[Document]) -> list[Document]:
doc_id = text.metadata['doc_id']
exists_duplicate_node = self.text_exists(doc_id)
if exists_duplicate_node:
# FIXME: Mutation to loop iterable `texts` during iteration
texts.remove(text)

return texts
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"""add environment variable to workflow model
Revision ID: 8e5588e6412e
Revises: 6e957a32015b
Create Date: 2024-07-22 03:27:16.042533
"""
import sqlalchemy as sa
from alembic import op

import models as models

# revision identifiers, used by Alembic.
revision = '8e5588e6412e'
down_revision = '6e957a32015b'
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('workflows', schema=None) as batch_op:
batch_op.add_column(sa.Column('environment_variables', sa.Text(), server_default='{}', nullable=False))

# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('workflows', schema=None) as batch_op:
batch_op.drop_column('environment_variables')

# ### end Alembic commands ###
4 changes: 1 addition & 3 deletions api/models/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,7 @@ class Workflow(db.Model):
created_at = db.Column(db.DateTime, nullable=False, server_default=db.text('CURRENT_TIMESTAMP(0)'))
updated_by = db.Column(StringUUID)
updated_at = db.Column(db.DateTime)
# TODO: update this field to sqlalchemy column after frontend update.
_environment_variables = '{}'
# _environment_variables = db.Column('environment_variables', db.Text, nullable=False, server_default='{}')
_environment_variables = db.Column('environment_variables', db.Text, nullable=False, server_default='{}')

@property
def created_by_account(self):
Expand Down
1 change: 1 addition & 0 deletions api/services/model_load_balancing_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ def get_load_balancing_configs(self, tenant_id: str, provider: str, model: str,
# move the inherit configuration to the first
for i, load_balancing_config in enumerate(load_balancing_configs):
if load_balancing_config.name == '__inherit__':
# FIXME: Mutation to loop iterable `load_balancing_configs` during iteration
inherit_config = load_balancing_configs.pop(i)
load_balancing_configs.insert(0, inherit_config)

Expand Down

0 comments on commit 768b992

Please sign in to comment.