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 6fadad7
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 9 deletions.
3 changes: 2 additions & 1 deletion api/core/model_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,9 @@ 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)
self._load_balancing_configs.remove(load_balancing_config) # noqa: B909
else:
load_balancing_config.credentials = managed_credentials

Expand Down
3 changes: 2 additions & 1 deletion api/core/rag/datasource/keyword/keyword_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ 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:
texts.remove(text)
# FIXME: Mutation to loop iterable `texts` during iteration
texts.remove(text) # noqa: B909

return texts

Expand Down
3 changes: 2 additions & 1 deletion api/core/rag/datasource/vdb/vector_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ 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:
texts.remove(text)
# FIXME: Mutation to loop iterable `texts` during iteration
texts.remove(text) # noqa: B909

return texts

Expand Down
3 changes: 2 additions & 1 deletion api/core/rag/datasource/vdb/vector_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ 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:
texts.remove(text)
# FIXME: Mutation to loop iterable `texts` during iteration
texts.remove(text) # noqa: B909

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
5 changes: 3 additions & 2 deletions api/services/model_load_balancing_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,9 @@ 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__':
inherit_config = load_balancing_configs.pop(i)
load_balancing_configs.insert(0, inherit_config)
# FIXME: Mutation to loop iterable `load_balancing_configs` during iteration
inherit_config = load_balancing_configs.pop(i) # noqa: B909
load_balancing_configs.insert(0, inherit_config) # noqa: B909

# Get credential form schemas from model credential schema or provider credential schema
credential_schemas = self._get_credential_schema(provider_configuration)
Expand Down

0 comments on commit 6fadad7

Please sign in to comment.