diff --git a/crc/api/common.py b/crc/api/common.py index 8f6c113b..66f62f4f 100644 --- a/crc/api/common.py +++ b/crc/api/common.py @@ -29,9 +29,9 @@ class ApiError(Exception): self.offset = offset self.error_type = error_type self.error_line = error_line - if hasattr(g, 'user'): + try: user = g.user.uid - else: + except Exception as e: user = 'Unknown' self.task_user = user # This is for sentry logging into Slack diff --git a/crc/services/study_service.py b/crc/services/study_service.py index 32110fed..66d66a65 100755 --- a/crc/services/study_service.py +++ b/crc/services/study_service.py @@ -468,7 +468,7 @@ class StudyService(object): @staticmethod def add_all_workflow_specs_to_study(study_model: StudyModel, specs: List[WorkflowSpecInfo]): existing_models = session.query(WorkflowModel).filter(WorkflowModel.study == study_model).all() - existing_spec_ids = map(lambda x: x.workflow_spec_id, existing_models) + existing_spec_ids = list(map(lambda x: x.workflow_spec_id, existing_models)) errors = [] for workflow_spec in specs: if workflow_spec.id in existing_spec_ids: diff --git a/migrations/versions/29bad12c9945_.py b/migrations/versions/29bad12c9945_.py new file mode 100644 index 00000000..f593eee5 --- /dev/null +++ b/migrations/versions/29bad12c9945_.py @@ -0,0 +1,65 @@ +"""empty message + +Revision ID: 29bad12c9945 +Revises: c51ea6590f5d +Create Date: 2022-02-10 10:24:27.796228 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '29bad12c9945' +down_revision = 'c51ea6590f5d' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_constraint('task_event_workflow_spec_id_fkey', 'task_event', type_='foreignkey') + op.drop_constraint('workflow_workflow_spec_id_fkey', 'workflow', type_='foreignkey') + op.drop_constraint('workflow_library_workflow_spec_id_fkey', 'workflow_library', type_='foreignkey') + op.drop_table('workflow_library') + op.drop_table('workflow_spec') + op.drop_table('workflow_spec_category') + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_foreign_key('workflow_workflow_spec_id_fkey', 'workflow', 'workflow_spec', ['workflow_spec_id'], ['id']) + op.create_foreign_key('task_event_workflow_spec_id_fkey', 'task_event', 'workflow_spec', ['workflow_spec_id'], ['id']) + op.create_table('workflow_spec', + sa.Column('id', sa.VARCHAR(), autoincrement=False, nullable=False), + sa.Column('display_name', sa.VARCHAR(), autoincrement=False, nullable=True), + sa.Column('description', sa.TEXT(), autoincrement=False, nullable=True), + sa.Column('is_master_spec', sa.BOOLEAN(), autoincrement=False, nullable=True), + sa.Column('category_id', sa.INTEGER(), autoincrement=False, nullable=True), + sa.Column('display_order', sa.INTEGER(), autoincrement=False, nullable=True), + sa.Column('standalone', sa.BOOLEAN(), autoincrement=False, nullable=True), + sa.Column('library', sa.BOOLEAN(), autoincrement=False, nullable=True), + sa.Column('primary_file_name', sa.VARCHAR(), autoincrement=False, nullable=True), + sa.Column('primary_process_id', sa.VARCHAR(), autoincrement=False, nullable=True), + sa.Column('is_review', sa.BOOLEAN(), autoincrement=False, nullable=True), + sa.ForeignKeyConstraint(['category_id'], ['workflow_spec_category.id'], name='workflow_spec_category_id_fkey'), + sa.PrimaryKeyConstraint('id', name='workflow_spec_pkey'), + postgresql_ignore_search_path=False + ) + op.create_table('workflow_library', + sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False), + sa.Column('workflow_spec_id', sa.VARCHAR(), autoincrement=False, nullable=True), + sa.Column('library_spec_id', sa.VARCHAR(), autoincrement=False, nullable=True), + sa.ForeignKeyConstraint(['library_spec_id'], ['workflow_spec.id'], name='workflow_library_library_spec_id_fkey'), + sa.ForeignKeyConstraint(['workflow_spec_id'], ['workflow_spec.id'], name='workflow_library_workflow_spec_id_fkey'), + sa.PrimaryKeyConstraint('id', name='workflow_library_pkey') + ) + op.create_table('workflow_spec_category', + sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False), + sa.Column('display_name', sa.VARCHAR(), autoincrement=False, nullable=True), + sa.Column('display_order', sa.INTEGER(), autoincrement=False, nullable=True), + sa.Column('admin', sa.BOOLEAN(), autoincrement=False, nullable=True), + sa.PrimaryKeyConstraint('id', name='workflow_spec_category_pkey') + ) + # ### end Alembic commands ###