-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: expand environments specification (#338)
This is a breaking change in the API. It requires changes in the UI for it to be fully useful.
- Loading branch information
Showing
15 changed files
with
1,130 additions
and
380 deletions.
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
41 changes: 41 additions & 0 deletions
41
...nku_data_services/migrations/versions/1ef98b967767_add_command_and_args_to_environment.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,41 @@ | ||
"""Add command and args to environment | ||
Revision ID: 1ef98b967767 | ||
Revises: 584598f3b769 | ||
Create Date: 2024-08-25 21:05:02.158021 | ||
""" | ||
|
||
import sqlalchemy as sa | ||
from alembic import op | ||
from sqlalchemy.dialects import postgresql | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "1ef98b967767" | ||
down_revision = "584598f3b769" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.add_column( | ||
"environments", | ||
sa.Column("args", sa.JSON().with_variant(postgresql.JSONB(astext_type=sa.Text()), "postgresql"), nullable=True), | ||
schema="sessions", | ||
) | ||
op.add_column( | ||
"environments", | ||
sa.Column( | ||
"command", sa.JSON().with_variant(postgresql.JSONB(astext_type=sa.Text()), "postgresql"), nullable=True | ||
), | ||
schema="sessions", | ||
) | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_column("environments", "command", schema="sessions") | ||
op.drop_column("environments", "args", schema="sessions") | ||
# ### end Alembic commands ### |
109 changes: 109 additions & 0 deletions
109
..._data_services/migrations/versions/584598f3b769_expand_and_separate_environments_from_.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,109 @@ | ||
"""expand and separate environments from session launchers | ||
Revision ID: 584598f3b769 | ||
Revises: 9058bf0a1a12 | ||
Create Date: 2024-08-12 14:25:24.292285 | ||
""" | ||
|
||
import sqlalchemy as sa | ||
from alembic import op | ||
from sqlalchemy.dialects import postgresql | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "584598f3b769" | ||
down_revision = "9058bf0a1a12" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
default_url: str = "/lab" | ||
working_dir: str = "/home/jovyan/work" | ||
mount_dir: str = "/home/jovyan/work" | ||
uid: int = 1000 | ||
gid: int = 1000 | ||
port: int = 8888 | ||
|
||
|
||
def upgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.execute("DELETE FROM sessions.launchers") | ||
op.drop_column("launchers", "default_url", schema="sessions") | ||
op.drop_column("launchers", "environment_kind", schema="sessions") | ||
op.drop_column("launchers", "container_image", schema="sessions") | ||
op.execute("DROP TYPE environmentkind CASCADE") | ||
op.execute("CREATE TYPE environmentkind AS ENUM ('GLOBAL', 'CUSTOM')") | ||
op.add_column("environments", sa.Column("port", sa.Integer(), nullable=True), schema="sessions") | ||
op.add_column("environments", sa.Column("working_directory", sa.String(), nullable=True), schema="sessions") | ||
op.add_column("environments", sa.Column("mount_directory", sa.String(), nullable=True), schema="sessions") | ||
op.add_column("environments", sa.Column("uid", sa.Integer(), nullable=True), schema="sessions") | ||
op.add_column("environments", sa.Column("gid", sa.Integer(), nullable=True), schema="sessions") | ||
op.add_column( | ||
"environments", | ||
sa.Column("environment_kind", sa.Enum("GLOBAL", "CUSTOM", name="environmentkind"), nullable=True), | ||
schema="sessions", | ||
) | ||
op.execute(sa.text("UPDATE sessions.environments SET port = :port WHERE port is NULL").bindparams(port=port)) | ||
op.execute( | ||
sa.text( | ||
"UPDATE sessions.environments SET working_directory = :working_dir WHERE working_directory is NULL" | ||
).bindparams(working_dir=working_dir) | ||
) | ||
op.execute( | ||
sa.text( | ||
"UPDATE sessions.environments SET mount_directory = :mount_dir WHERE mount_directory is NULL" | ||
).bindparams(mount_dir=mount_dir) | ||
) | ||
op.execute(sa.text("UPDATE sessions.environments SET uid = :uid WHERE uid is NULL").bindparams(uid=uid)) | ||
op.execute(sa.text("UPDATE sessions.environments SET gid = :gid WHERE gid is NULL").bindparams(gid=gid)) | ||
op.execute("UPDATE sessions.environments SET environment_kind = 'GLOBAL' WHERE environment_kind is NULL") | ||
op.execute( | ||
sa.text("UPDATE sessions.environments SET default_url = :default_url WHERE default_url is NULL").bindparams( | ||
default_url=default_url | ||
) | ||
) | ||
op.alter_column("environments", "port", nullable=False, schema="sessions") | ||
op.alter_column("environments", "working_directory", nullable=False, schema="sessions") | ||
op.alter_column("environments", "mount_directory", nullable=False, schema="sessions") | ||
op.alter_column("environments", "uid", nullable=False, schema="sessions") | ||
op.alter_column("environments", "gid", nullable=False, schema="sessions") | ||
op.alter_column("environments", "environment_kind", nullable=False, schema="sessions") | ||
op.alter_column( | ||
"environments", "default_url", existing_type=sa.VARCHAR(length=200), nullable=False, schema="sessions" | ||
) | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_column("environments", "environment_kind", schema="sessions") | ||
op.drop_column("environments", "gid", schema="sessions") | ||
op.drop_column("environments", "uid", schema="sessions") | ||
op.drop_column("environments", "mount_directory", schema="sessions") | ||
op.drop_column("environments", "working_directory", schema="sessions") | ||
op.drop_column("environments", "port", schema="sessions") | ||
op.execute("DROP TYPE environmentkind") | ||
op.execute("CREATE TYPE environmentkind AS ENUM ('global_environment', 'container_image')") | ||
op.add_column( | ||
"launchers", | ||
sa.Column("container_image", sa.VARCHAR(length=500), autoincrement=False, nullable=True), | ||
schema="sessions", | ||
) | ||
op.add_column( | ||
"launchers", | ||
sa.Column( | ||
"environment_kind", | ||
postgresql.ENUM("global_environment", "container_image", name="environmentkind"), | ||
autoincrement=False, | ||
nullable=False, | ||
), | ||
schema="sessions", | ||
) | ||
op.add_column( | ||
"launchers", | ||
sa.Column("default_url", sa.VARCHAR(length=200), autoincrement=False, nullable=True), | ||
schema="sessions", | ||
) | ||
op.alter_column( | ||
"environments", "default_url", existing_type=sa.VARCHAR(length=200), nullable=True, schema="sessions" | ||
) | ||
# ### end Alembic commands ### |
Oops, something went wrong.