diff --git a/web_console_v2/api/README.md b/web_console_v2/api/README.md index 7982cfb9c..050e1d8c6 100644 --- a/web_console_v2/api/README.md +++ b/web_console_v2/api/README.md @@ -42,7 +42,7 @@ delete migrations folder first ``` FLASK_APP=command:app flask db init -FLASK_APP=command:app flask flask db migrate -m "Initial migration." +FLASK_APP=command:app flask db migrate -m "Initial migration." ``` ## References diff --git a/web_console_v2/api/fedlearner_webconsole/project/models.py b/web_console_v2/api/fedlearner_webconsole/project/models.py index 9a63e6423..e6a063a40 100644 --- a/web_console_v2/api/fedlearner_webconsole/project/models.py +++ b/web_console_v2/api/fedlearner_webconsole/project/models.py @@ -73,6 +73,6 @@ def get_namespace(self): if config is not None: variables = self.get_config().variables for variable in variables: - if variable.name == 'NAMESPACE': + if variable.name == 'namespace': return variable.value return 'default' diff --git a/web_console_v2/api/fedlearner_webconsole/scheduler/scheduler.py b/web_console_v2/api/fedlearner_webconsole/scheduler/scheduler.py index 438ab7f11..e6dd3230f 100644 --- a/web_console_v2/api/fedlearner_webconsole/scheduler/scheduler.py +++ b/web_console_v2/api/fedlearner_webconsole/scheduler/scheduler.py @@ -161,8 +161,11 @@ def _schedule_job(self, job_id): k8s_client = get_client() yaml = generate_job_run_yaml(job) + try: - k8s_client.create_or_replace_custom_object(CrdKind.FLAPP, yaml) + k8s_client.create_or_replace_custom_object(CrdKind.FLAPP, yaml, + job.project. + get_namespace()) except RuntimeError as e: logging.error('Start job %d has Runtime error msg: %s' , job_id, e.args) diff --git a/web_console_v2/api/fedlearner_webconsole/workflow/models.py b/web_console_v2/api/fedlearner_webconsole/workflow/models.py index 00d14a627..1fb7cd475 100644 --- a/web_console_v2/api/fedlearner_webconsole/workflow/models.py +++ b/web_console_v2/api/fedlearner_webconsole/workflow/models.py @@ -137,7 +137,8 @@ class Workflow(db.Model): uuid = db.Column(db.String(64), comment='uuid') name = db.Column(db.String(255), comment='name') project_id = db.Column(db.Integer, comment='project_id') - config = db.Column(db.LargeBinary(), comment='config') + # max store 16777215 bytes (16 MB) + config = db.Column(db.LargeBinary(16777215), comment='config') comment = db.Column('cmt', db.String(255), key='comment', @@ -156,7 +157,8 @@ class Workflow(db.Model): # index in config.job_defs instead of job's id peer_create_job_flags = db.Column(db.TEXT(), comment='peer_create_job_flags') - fork_proposal_config = db.Column(db.LargeBinary(), + # max store 16777215 bytes (16 MB) + fork_proposal_config = db.Column(db.LargeBinary(16777215), comment='fork_proposal_config') recur_type = db.Column(db.Enum(RecurType, native_enum=False), diff --git a/web_console_v2/api/fedlearner_webconsole/workflow_template/models.py b/web_console_v2/api/fedlearner_webconsole/workflow_template/models.py index 805ca27f7..548e648b1 100644 --- a/web_console_v2/api/fedlearner_webconsole/workflow_template/models.py +++ b/web_console_v2/api/fedlearner_webconsole/workflow_template/models.py @@ -36,7 +36,9 @@ class WorkflowTemplate(db.Model): group_alias = db.Column(db.String(255), nullable=False, comment='group_alias') - config = db.Column(db.LargeBinary(), nullable=False, comment='config') + # max store 16777215 bytes (16 MB) + config = db.Column(db.LargeBinary(16777215), nullable=False, + comment='config') is_left = db.Column(db.Boolean, comment='is_left') def set_config(self, proto): diff --git a/web_console_v2/api/migrations/env.py b/web_console_v2/api/migrations/env.py index 42438a5a2..07ecd0a89 100644 --- a/web_console_v2/api/migrations/env.py +++ b/web_console_v2/api/migrations/env.py @@ -45,7 +45,8 @@ def run_migrations_offline(): """ url = config.get_main_option("sqlalchemy.url") context.configure( - url=url, target_metadata=target_metadata, literal_binds=True + url=url, target_metadata=target_metadata, literal_binds=True, + compare_type=True ) with context.begin_transaction(): @@ -77,7 +78,8 @@ def process_revision_directives(context, revision, directives): connection=connection, target_metadata=target_metadata, process_revision_directives=process_revision_directives, - **current_app.extensions['migrate'].configure_args + **current_app.extensions['migrate'].configure_args, + compare_type=True ) with context.begin_transaction(): diff --git a/web_console_v2/api/migrations/versions/80b0a98ce379_make_config_long.py b/web_console_v2/api/migrations/versions/80b0a98ce379_make_config_long.py new file mode 100644 index 000000000..0b8ba4442 --- /dev/null +++ b/web_console_v2/api/migrations/versions/80b0a98ce379_make_config_long.py @@ -0,0 +1,31 @@ +"""empty message + +Revision ID: 80b0a98ce379 +Revises: b3512a6ce912 +Create Date: 2021-03-18 21:11:17.902485 + +""" +from alembic import op +import sqlalchemy as sa +from sqlalchemy.dialects import mysql +# revision identifiers, used by Alembic. +revision = '80b0a98ce379' +down_revision = 'b3512a6ce912' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.alter_column('workflow_v2', 'config', existing_type=sa.LargeBinary(), type_=sa.LargeBinary(16777215)) + op.alter_column('template_v2', 'config', existing_type=sa.LargeBinary(), type_=sa.LargeBinary(16777215)) + op.alter_column('workflow_v2', 'fork_proposal_config', existing_type=sa.LargeBinary(), type_=sa.LargeBinary(16777215)) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.alter_column('workflow_v2', 'config', existing_type=sa.LargeBinary(16777215), type_=mysql.BLOB) + op.alter_column('template_v2', 'config', existing_type=sa.LargeBinary(16777215), type_=mysql.BLOB) + op.alter_column('workflow_v2', 'fork_proposal_config', existing_type=sa.LargeBinary(16777215), type_=mysql.BLOB) + # ### end Alembic commands ### diff --git a/web_console_v2/api/test/fedlearner_webconsole/project/models_test.py b/web_console_v2/api/test/fedlearner_webconsole/project/models_test.py index ad76f5d88..4594fed70 100644 --- a/web_console_v2/api/test/fedlearner_webconsole/project/models_test.py +++ b/web_console_v2/api/test/fedlearner_webconsole/project/models_test.py @@ -40,7 +40,7 @@ def test_get_namespace_from_variables(self): project.set_config(project_pb2.Project( variables=[ common_pb2.Variable( - name='NAMESPACE', + name='namespace', value='haha' ) ]