-
Notifications
You must be signed in to change notification settings - Fork 32
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
feat(models): add service tables #241
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
reana_db/alembic/versions/20250117_1005_3d0994430da7_add_service_tables.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
"""Add service tables. | ||
|
||
Revision ID: 3d0994430da7 | ||
Revises: 2e82f33ee37d | ||
Create Date: 2025-01-17 10:05:48.699316 | ||
|
||
""" | ||
|
||
import sqlalchemy_utils | ||
import sqlalchemy as sa | ||
from alembic import op | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision = "3d0994430da7" | ||
down_revision = "2e82f33ee37d" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
"""Upgrade to 3d0994430da7 revision.""" | ||
op.create_table( | ||
"service", | ||
sa.Column("id_", sqlalchemy_utils.types.uuid.UUIDType(), nullable=False), | ||
sa.Column("name", sa.String(length=255), nullable=True), | ||
sa.Column("uri", sa.Text(), nullable=True), | ||
sa.Column( | ||
"status", | ||
sa.Enum( | ||
"created", | ||
"running", | ||
"finished", | ||
"failed", | ||
"deleted", | ||
"stopped", | ||
"queued", | ||
"pending", | ||
name="servicestatus", | ||
), | ||
nullable=False, | ||
), | ||
sa.Column("owner_id", sqlalchemy_utils.types.uuid.UUIDType(), nullable=True), | ||
sa.Column("type_", sa.Enum("dask", name="servicetype"), nullable=False), | ||
sa.ForeignKeyConstraint( | ||
["owner_id"], ["__reana.user_.id_"], name=op.f("fk_service_owner_id_user_") | ||
), | ||
sa.PrimaryKeyConstraint("id_", name=op.f("pk_service")), | ||
sa.UniqueConstraint("name", "uri", name=op.f("uq_service_name")), | ||
schema="__reana", | ||
) | ||
op.create_table( | ||
"workflow_service", | ||
sa.Column("workflow_id", sqlalchemy_utils.types.uuid.UUIDType(), nullable=True), | ||
sa.Column("service_id", sqlalchemy_utils.types.uuid.UUIDType(), nullable=False), | ||
sa.ForeignKeyConstraint( | ||
["service_id"], | ||
["__reana.service.id_"], | ||
name=op.f("fk_workflow_service_service_id_service"), | ||
), | ||
sa.ForeignKeyConstraint( | ||
["workflow_id"], | ||
["__reana.workflow.id_"], | ||
name=op.f("fk_workflow_service_workflow_id_workflow"), | ||
), | ||
sa.PrimaryKeyConstraint("service_id", name=op.f("pk_workflow_service")), | ||
schema="__reana", | ||
) | ||
|
||
|
||
def downgrade(): | ||
"""Downgrade to 2e82f33ee37d revision.""" | ||
op.drop_table("workflow_service", schema="__reana") | ||
op.drop_table("service", schema="__reana") | ||
sa.Enum(name="servicestatus").drop(op.get_bind()) | ||
sa.Enum(name="servicetype").drop(op.get_bind()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this one intended to be general Dask service? I wonder about distinguishing Dask cluster from Dask dashboard, for example in case there would be more services exposed from the Dask integration. But I guess these theoretical distinctions may not be useful as of yet...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can introduce a new service type relatively easily if we need an extra field in the future. Calling the service
dask_dashboard
or something similar at the moment could be too specific.