Skip to content

Commit

Permalink
ssh settings in data migration script
Browse files Browse the repository at this point in the history
  • Loading branch information
ychiucco committed Sep 20, 2024
1 parent f6c84ae commit 8128067
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions fractal_server/data_migrations/2_6_0.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,34 @@
from fractal_server.app.db import get_sync_db
from fractal_server.app.models import UserOAuth
from fractal_server.app.models import UserSettings
from fractal_server.config import get_settings
from fractal_server.data_migrations.tools import _check_current_version
from fractal_server.syringe import Inject


def fix_db():
logger = logging.getLogger("fix_db")
logger.warning("START execution of fix_db function")
_check_current_version("2.6.0")

global_settings = Inject(get_settings)

with next(get_sync_db()) as db:
for user in db.execute(select(UserOAuth)).scalars().unique().all():
user.settings = UserSettings(
# SSH
ssh_host=global_settings.FRACTAL_SLURM_SSH_HOST,
ssh_username=global_settings.FRACTAL_SLURM_SSH_USER,
ssh_private_key_path=(
global_settings.FRACTAL_SLURM_SSH_PRIVATE_KEY_PATH
),
ssh_tasks_dir=(
global_settings.FRACTAL_SLURM_SSH_WORKING_BASE_DIR
),
ssh_jobs_dir=(
global_settings.FRACTAL_SLURM_SSH_WORKING_BASE_DIR
),
# SUDO
slurm_user=user.slurm_user,
slurm_accounts=user.slurm_accounts,
cache_dir=user.cache_dir,
Expand Down

0 comments on commit 8128067

Please sign in to comment.