Skip to content

Commit

Permalink
✨ Add cavatica related gf fields
Browse files Browse the repository at this point in the history
🗃️ add tests and flask migration

🎨 fix formating to old version
  • Loading branch information
chris-s-friedman committed Sep 4, 2024
1 parent 645d888 commit d316438
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 1 deletion.
18 changes: 18 additions & 0 deletions dataservice/api/genomic_file/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ class GenomicFile(db.Model, Base, IndexdFile):
source files, this field should be NULL
:param file_version_descriptor: Indicates the release status
:param data_category: Type of data
:param cavatica_file_id: Indicates the file ID in CAVATICA
:param cavatica_volume: Indicates the CAVATICA volume ID, mediating cloud
storage access
:param workflow_endpoint: The endpoint name of the task outputs from
CAVATICA task or the CAVATICA app output name
"""
__tablename__ = 'genomic_file'
__prefix__ = 'GF'
Expand Down Expand Up @@ -95,6 +100,19 @@ class GenomicFile(db.Model, Base, IndexdFile):
db.Text(),
doc='Inidicates type of data file'
)
cavatica_file_id = db.Column(
db.Text(),
doc='Indicates the file ID in CAVATICA'
)
cavatica_volume = db.Column(
db.Text(),
doc='Indicates the CAVATICA volume ID, mediating cloud storage access'
)
workflow_endpoint = db.Column(
db.Text(),
doc='The endpoint name of the task outputs from CAVATICA task or the'
' CAVATICA app output name'
)

task_genomic_files = db.relationship(TaskGenomicFile,
backref='genomic_file',
Expand Down
32 changes: 32 additions & 0 deletions migrations/versions/869f891d97ad_add_cavatica_gf_fields.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""add cavatica gf fields
Revision ID: 869f891d97ad
Revises: 0454317cd224
Create Date: 2024-09-04 14:48:36.499552
"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '869f891d97ad'
down_revision = '0454317cd224'
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('genomic_file', sa.Column('cavatica_file_id', sa.Text(), nullable=True))
op.add_column('genomic_file', sa.Column('cavatica_volume', sa.Text(), nullable=True))
op.add_column('genomic_file', sa.Column('workflow_endpoint', sa.Text(), nullable=True))
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('genomic_file', 'workflow_endpoint')
op.drop_column('genomic_file', 'cavatica_volume')
op.drop_column('genomic_file', 'cavatica_file_id')
# ### end Alembic commands ###
3 changes: 3 additions & 0 deletions tests/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@
"workflow_version": "v1",
"file_version_descriptor": "latest",
"data_category": "foo",
"cavatica_file_id": "668e2b079b1e4f4bec36a685",
"cavatica_volume": "d3b-bixu/sd_p6a1apwc",
"workflow_endpoint": "ctrlfreec_pngs"
"visible": true
},
"/biospecimen-genomic-files": {},
Expand Down
3 changes: 3 additions & 0 deletions tests/genomic_file/test_genomic_file_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ def test_create_and_find(self):
'workflow_version': 'v1',
'file_version_descriptor': 'released',
'data_category': 'foo',
'cavatica_file_id': '668e2b079b1e4f4bec36a685',
'cavatica_volume': 'd3b-bixu/sd_p6a1apwc',
'workflow_endpoint': 'ctrlfreec_pngs'
}
# Add genomic file to db session
gf = GenomicFile(**kwargs)
Expand Down
5 changes: 4 additions & 1 deletion tests/genomic_file/test_genomic_file_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,10 @@ def _new_genomic_file(client):
'urls': ['s3://bucket/key'],
'hashes': {'md5': 'd418219b883fce3a085b1b7f38b01e37'},
'availability': 'Immediate Download',
'controlled_access': False
'controlled_access': False,
'cavatica_file_id': '668e2b079b1e4f4bec36a685',
'cavatica_volume': 'd3b-bixu/sd_p6a1apwc',
'workflow_endpoint': 'ctrlfreec_pngs'
}

response = client.post(url_for(GENOMICFILE_LIST_URL),
Expand Down

0 comments on commit d316438

Please sign in to comment.