Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/adding mset replacement functionality 20210615 #445

Open
wants to merge 65 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
b73c2c9
added MsetReplacementEvent model
cschu Jun 15, 2021
c61ae1d
fixed alembic complaint
cschu Jun 15, 2021
723ec8b
added alembic script for revision related to b73c2c91
cschu Jun 15, 2021
e53527b
pleasing flake8
cschu Jun 15, 2021
157ef00
Merge branch 'develop' into feature/adding_mset_replacement_functiona…
cschu Jun 16, 2021
0708ccb
Merge branch 'develop' into feature/adding_mset_replacement_functiona…
cschu Jun 16, 2021
3dbc0f4
fixed MsetReplacement/MetaDataSet key issues (with @lkuchenb)
cschu Jun 24, 2021
df35eba
merged upstream
cschu Jun 24, 2021
1b3a3fc
pleasing flake8
cschu Jun 24, 2021
9f09d96
Merge branch 'develop' into feature/adding_mset_replacement_functiona…
cschu Jun 24, 2021
729ddcc
added initial mset replacement logic
cschu Jun 24, 2021
85ade91
merged upstream
cschu Jun 24, 2021
2bd9b75
pleasing flake8 and mypy
cschu Jun 24, 2021
523208f
addressing @lkuchenb's code review
cschu Jun 25, 2021
9068be3
added user.can_update flag
cschu Jun 25, 2021
2392560
generated alembic script pertaining to 9068be3
cschu Jun 25, 2021
54d3b63
pleasing flake8
cschu Jun 25, 2021
1c9a668
pleasing flake8
cschu Jun 25, 2021
1ffefdb
Merge branch 'develop' into feature/adding_mset_replacement_functiona…
cschu Jun 29, 2021
bf20b41
fixing the fixtures
cschu Jun 29, 2021
67fe823
fixing the fixtures
cschu Jun 29, 2021
9accbed
addressing mypy error
cschu Jun 29, 2021
5db3d83
implemented code review requests (@lkuchenb)
cschu Jun 30, 2021
b92e67e
patched exposed event id
cschu Jun 30, 2021
307353f
actually fixed exposed event id
cschu Jul 1, 2021
f5d2483
added can_update to restricted fields, updated info request integrati…
cschu Jul 1, 2021
7a4c6de
added metadataset->msetreplacementevent relationships
cschu Jul 1, 2021
effc7d7
simplified check for already replaced metadatasets
cschu Jul 1, 2021
db6efbc
added back_populates args
cschu Jul 1, 2021
6c7199b
fixed issue with introducing can_update column for existing users
cschu Jul 1, 2021
621babc
Merge branch 'develop' into feature/adding_mset_replacement_functiona…
cschu Jul 1, 2021
55a11f7
openapi version bump (1.4.0)
cschu Jul 1, 2021
c6a340f
added/registered new api route; renamed information request operation…
cschu Jul 5, 2021
e0dfe33
added update_metadatasets protoype
cschu Jul 6, 2021
ce78f8a
Merge branch 'develop' into feature/adding_mset_replacement_functiona…
cschu Jul 6, 2021
4fecd28
pleasing flake8 and mypy
cschu Jul 6, 2021
115eff6
package bump (pleasing versioning checks)
cschu Jul 6, 2021
4912fdb
merged openapi.yaml with upstream changes
cschu Jul 6, 2021
36cd8ec
Apply suggestions from code review
cschu Jul 6, 2021
ac112b7
works
cschu Jul 6, 2021
4a35bce
weird.
cschu Jul 6, 2021
e0803da
weird.
cschu Jul 6, 2021
6f75123
weird
cschu Jul 6, 2021
d0b3f6b
refactored + working
cschu Jul 7, 2021
e77bf56
added preliminary test for metadataset replacement
cschu Jul 7, 2021
0289f2a
workaround to re-enable bulk-deletion test
cschu Jul 7, 2021
ac2b431
removed redundant label from msetreplacementevents (label is attached…
cschu Jul 14, 2021
3e1bfcd
cleaning
cschu Jul 14, 2021
c6f22a0
added can_update=True to initial user
cschu Jul 14, 2021
9e88373
metadatasetresponses now include replaced/replaces information (#462)
cschu Jul 14, 2021
d882ffe
added more testcases
cschu Jul 28, 2021
d395384
pleasing flake8
cschu Jul 28, 2021
b7cf1ed
pleasing mypy
cschu Jul 28, 2021
e47a56d
pleasing mypy
cschu Jul 28, 2021
b87e481
removed comment
cschu Jul 28, 2021
455ee05
added information about replaced metadatasets to datatable
cschu Jul 28, 2021
27163f5
Apply suggestions from @lkuchenb's code review
cschu Aug 3, 2021
306cf35
implemented suggestions from @lkuchenb's code review
cschu Aug 3, 2021
d353255
merge upstream (github code review)
cschu Aug 3, 2021
455626a
dealt with fallout from renaming msetreplacements-table
cschu Aug 3, 2021
00738a1
fixed bulk deletion test
cschu Aug 4, 2021
ea30854
fixed failing stage_and_submit test
cschu Aug 4, 2021
cbe39eb
pleasing mypy
cschu Aug 4, 2021
dd036cc
fixed issue that prevented new user registration requests to be compl…
cschu Aug 24, 2021
216a08b
Merge branch 'develop' into feature/adding_mset_replacement_functiona…
lkuchenb Nov 5, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions datameta/alembic/versions/20210615_37ecf07b7838.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
"""added msetreplacements table, moved update-related fields from mset

Revision ID: 37ecf07b7838
Revises: 7fdc829db18d
Create Date: 2021-06-15 09:09:20.305816

"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = '37ecf07b7838'
down_revision = '7fdc829db18d'
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('msetreplacements',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('uuid', postgresql.UUID(as_uuid=True), nullable=False),
sa.Column('user_id', sa.Integer(), nullable=False),
sa.Column('datetime', sa.DateTime(), nullable=False),
sa.Column('reason', sa.String(length=140), nullable=False),
sa.Column('metadataset_id', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['metadataset_id'], ['metadatasets.id'], name=op.f('fk_msetreplacements_metadataset_id_metadatasets')),
sa.ForeignKeyConstraint(['user_id'], ['users.id'], name=op.f('fk_msetreplacements_user_id_users')),
sa.PrimaryKeyConstraint('id', name=op.f('pk_msetreplacements')),
sa.UniqueConstraint('uuid', name=op.f('uq_msetreplacements_uuid'))
)
op.drop_constraint('fk_metadatasets_replaced_by_id_metadatasets', 'metadatasets', type_='foreignkey')
op.drop_column('metadatasets', 'deprecated_label')
op.drop_column('metadatasets', 'is_deprecated')
op.drop_column('metadatasets', 'replaced_by_id')
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('metadatasets', sa.Column('replaced_by_id', sa.INTEGER(), autoincrement=False, nullable=True))
op.add_column('metadatasets', sa.Column('is_deprecated', sa.BOOLEAN(), autoincrement=False, nullable=True))
op.add_column('metadatasets', sa.Column('deprecated_label', sa.VARCHAR(), autoincrement=False, nullable=True))
op.create_foreign_key('fk_metadatasets_replaced_by_id_metadatasets', 'metadatasets', 'metadatasets', ['replaced_by_id'], ['id'])
op.drop_table('msetreplacements')
# ### end Alembic commands ###
24 changes: 20 additions & 4 deletions datameta/models/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class User(Base):
apikeys = relationship('ApiKey', back_populates='user')
services = relationship('Service', secondary=user_service_table, back_populates='users')
service_executions = relationship('ServiceExecution', back_populates='user')
mset_replacements = relationship('MsetReplacementEvent', back_populates='user')


class ApiKey(Base):
Expand Down Expand Up @@ -214,17 +215,32 @@ class MetaDataSet(Base):
uuid = Column(UUID(as_uuid=True), unique=True, default=uuid.uuid4, nullable=False)
user_id = Column(Integer, ForeignKey('users.id'), nullable=False)
submission_id = Column(Integer, ForeignKey('submissions.id'), nullable=True)
is_deprecated = Column(Boolean, default=False)
deprecated_label = Column(String, nullable=True)
replaced_by_id = Column(Integer, ForeignKey('metadatasets.id'), nullable=True)

# Relationships
user = relationship('User', back_populates='metadatasets')
submission = relationship('Submission', back_populates='metadatasets')
metadatumrecords = relationship('MetaDatumRecord', back_populates='metadataset')
replaces = relationship('MetaDataSet', backref=backref('replaced_by', remote_side=[id]))
service_executions = relationship('ServiceExecution', back_populates = 'metadataset')


class MsetReplacementEvent(Base):
""" Stores information about an mset replacement event """
__tablename__ = 'msetreplacements'
cschu marked this conversation as resolved.
Show resolved Hide resolved
id = Column(Integer, primary_key=True)
uuid = Column(UUID(as_uuid=True), unique=True, default=uuid.uuid4, nullable=False)
user_id = Column(Integer, ForeignKey('users.id'), nullable=False)
datetime = Column(DateTime, nullable=False)
# former 'is_deprecated' label from MetaDataSet
reason = Column(String(140), nullable=False)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
reason = Column(String(140), nullable=False)
label = Column(String(140), nullable=False)

# the id of the new mset
metadataset_id = Column(Integer, ForeignKey('metadatasets.id'), nullable=False)

# Relationships
user = relationship('User', back_populates='mset_replacements')
# replaced msets can then backref to the even and the replacing mset can be obtained via event.metadataset_id
replaced_msets = relationship('MetaDataSet', backref=backref('replaced_through', remote_side=[metadataset_id]))


class ApplicationSetting(Base):
__tablename__ = 'appsettings'
id = Column(Integer, primary_key=True)
Expand Down