-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
* Problem: If a user wants to assign a GPU to a QEmu VM he cannot do it. Solution: Implement GPU assignation feature that will be pass-though to QEmu VMs with native performance. * Fix: Solved code quality issues * Fix: Solved compilation issue and fixed gpu logic. * Fix: Solved issue getting already running executions with GPU * Fix: Expose GPU support option in `status/config` endpoint * Fix: Applied some code review suggestions * Add migration * Fix: Allow to use the notify endpoint for GPU instances also. * Fix: Remove migration duplicity. * Fix: Changes DB initialization order to ensure that DB always exists before running the migrations. * Fix: Updated migration to only insert the column if isn't inside. --------- Co-authored-by: Olivier Le Thanh Duong <[email protected]>
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
"""add gpu table | ||
Revision ID: 5c6ae643c69b | ||
Revises: bbb12a12372e | ||
Create Date: 2024-12-09 19:40:19.279735 | ||
""" | ||
|
||
import sqlalchemy as sa | ||
from alembic import op | ||
Check warning on line 10 in src/aleph/vm/orchestrator/migrations/versions/0002_5c6ae643c69b_add_gpu_column_to_executions_table.py Codecov / codecov/patchsrc/aleph/vm/orchestrator/migrations/versions/0002_5c6ae643c69b_add_gpu_column_to_executions_table.py#L9-L10
|
||
|
||
# revision identifiers, used by Alembic. | ||
from sqlalchemy import create_engine | ||
from sqlalchemy.engine import reflection | ||
Check warning on line 14 in src/aleph/vm/orchestrator/migrations/versions/0002_5c6ae643c69b_add_gpu_column_to_executions_table.py Codecov / codecov/patchsrc/aleph/vm/orchestrator/migrations/versions/0002_5c6ae643c69b_add_gpu_column_to_executions_table.py#L13-L14
|
||
|
||
from aleph.vm.conf import make_db_url | ||
Check warning on line 16 in src/aleph/vm/orchestrator/migrations/versions/0002_5c6ae643c69b_add_gpu_column_to_executions_table.py Codecov / codecov/patchsrc/aleph/vm/orchestrator/migrations/versions/0002_5c6ae643c69b_add_gpu_column_to_executions_table.py#L16
|
||
|
||
revision = "5c6ae643c69b" | ||
down_revision = "bbb12a12372e" | ||
branch_labels = None | ||
depends_on = None | ||
Check warning on line 21 in src/aleph/vm/orchestrator/migrations/versions/0002_5c6ae643c69b_add_gpu_column_to_executions_table.py Codecov / codecov/patchsrc/aleph/vm/orchestrator/migrations/versions/0002_5c6ae643c69b_add_gpu_column_to_executions_table.py#L18-L21
|
||
|
||
|
||
def upgrade() -> None: | ||
engine = create_engine(make_db_url()) | ||
inspector = reflection.Inspector.from_engine(engine) | ||
Check warning on line 26 in src/aleph/vm/orchestrator/migrations/versions/0002_5c6ae643c69b_add_gpu_column_to_executions_table.py Codecov / codecov/patchsrc/aleph/vm/orchestrator/migrations/versions/0002_5c6ae643c69b_add_gpu_column_to_executions_table.py#L24-L26
|
||
|
||
# The table already exists on most CRNs. | ||
tables = inspector.get_table_names() | ||
Check warning on line 29 in src/aleph/vm/orchestrator/migrations/versions/0002_5c6ae643c69b_add_gpu_column_to_executions_table.py Codecov / codecov/patchsrc/aleph/vm/orchestrator/migrations/versions/0002_5c6ae643c69b_add_gpu_column_to_executions_table.py#L29
|
||
if "executions" in tables: | ||
columns = inspector.get_columns("executions") | ||
column_names = [c["name"] for c in columns] | ||
Check warning on line 32 in src/aleph/vm/orchestrator/migrations/versions/0002_5c6ae643c69b_add_gpu_column_to_executions_table.py Codecov / codecov/patchsrc/aleph/vm/orchestrator/migrations/versions/0002_5c6ae643c69b_add_gpu_column_to_executions_table.py#L31-L32
|
||
if "gpus" not in column_names: | ||
op.add_column("executions", sa.Column("gpus", sa.JSON(), nullable=True)) | ||
Check warning on line 34 in src/aleph/vm/orchestrator/migrations/versions/0002_5c6ae643c69b_add_gpu_column_to_executions_table.py Codecov / codecov/patchsrc/aleph/vm/orchestrator/migrations/versions/0002_5c6ae643c69b_add_gpu_column_to_executions_table.py#L34
|
||
|
||
|
||
def downgrade() -> None: | ||
op.drop_column("executions", "gpus") | ||
Check warning on line 38 in src/aleph/vm/orchestrator/migrations/versions/0002_5c6ae643c69b_add_gpu_column_to_executions_table.py Codecov / codecov/patchsrc/aleph/vm/orchestrator/migrations/versions/0002_5c6ae643c69b_add_gpu_column_to_executions_table.py#L37-L38
|