diff --git a/api/core/model_manager.py b/api/core/model_manager.py index d64db890f90f4c..8f55918e1ffb22 100644 --- a/api/core/model_manager.py +++ b/api/core/model_manager.py @@ -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 diff --git a/api/core/rag/datasource/keyword/keyword_base.py b/api/core/rag/datasource/keyword/keyword_base.py index 02838cb1bd5254..15e416a9c6c486 100644 --- a/api/core/rag/datasource/keyword/keyword_base.py +++ b/api/core/rag/datasource/keyword/keyword_base.py @@ -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 diff --git a/api/core/rag/datasource/vdb/vector_base.py b/api/core/rag/datasource/vdb/vector_base.py index 17768ab042dd93..e60008831eefaf 100644 --- a/api/core/rag/datasource/vdb/vector_base.py +++ b/api/core/rag/datasource/vdb/vector_base.py @@ -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 diff --git a/api/core/rag/datasource/vdb/vector_factory.py b/api/core/rag/datasource/vdb/vector_factory.py index 256abd28afbe53..8bad9f6bd2f0c3 100644 --- a/api/core/rag/datasource/vdb/vector_factory.py +++ b/api/core/rag/datasource/vdb/vector_factory.py @@ -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 diff --git a/api/migrations/versions/8e5588e6412e_add_environment_variable_to_workflow_.py b/api/migrations/versions/8e5588e6412e_add_environment_variable_to_workflow_.py new file mode 100644 index 00000000000000..ec2336da4dec71 --- /dev/null +++ b/api/migrations/versions/8e5588e6412e_add_environment_variable_to_workflow_.py @@ -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 ### diff --git a/api/models/workflow.py b/api/models/workflow.py index 30a6bef95d2221..df2269cd0fb6cc 100644 --- a/api/models/workflow.py +++ b/api/models/workflow.py @@ -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): diff --git a/api/services/model_load_balancing_service.py b/api/services/model_load_balancing_service.py index c684c2862b9745..185c88c8bbadbf 100644 --- a/api/services/model_load_balancing_service.py +++ b/api/services/model_load_balancing_service.py @@ -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)