lablup / lablup/backend.ai

[Phase 2] Create pyinfra dev runner for DevContext subprocess invocation

Open
#10,748 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
670
Forks
183
Avg merge
15h 13m
Merged PRs (30d)
368

Description

## Summary

Extract PostgreSQL connection string generation and alembic.ini configuration into a shared module. Currently duplicated across manager and appproxy setup in both context.py and pyinfra.

## Current Duplication

- `context.py` lines 780-840 (`install_appproxy_db()`), 925-937 (alembic.ini sed replacement)
- `context.py` lines 516, 528-530 (manager alembic.ini)
- `pyinfra deploy/cores/manager/deploy.py` lines 156-161, 222-245
- `pyinfra deploy/cores/manager/templates/alembic.ini.j2` line 38
- Both use identical pattern: `postgresql+asyncpg://user:password@host:port/dbname`
- Hardcoded defaults ("develove", port 8100) appear in multiple places

## Approach

Create `config_gen/database.py` with:

- `build_connection_string(user, password, host, port, dbname) -> str`
- `apply_alembic_config(doc, connection_string)` — applies to alembic.ini tomlkit/configparser doc
- Centralize default credentials in `shared_defaults.py`

## Acceptance Criteria

- Single source of truth for DB connection string format
- Manager and appproxy alembic configs use shared function
- No hardcoded credentials outside shared_defaults

JIRA Issue: BA-5571

Contributor guide

Open the contributing guide

Research direction

Start by comparing the cited sections of context.py with pyinfra/deploy/cores/manager/deploy.py and templates/alembic.ini.j2. Read the existing configuration flow, then create the shared config_gen/database.py and shared_defaults.py modules described in the issue. Done means manager and appproxy use the shared connection-string and Alembic configuration logic, with no hardcoded credentials outside shared_defaults.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend, databases
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.