Repository navigation
Fix: migrate legacy model id configs - #15495
Conversation
📝 WalkthroughWalkthroughThis PR adds a new MySQL migration stage that normalizes legacy model identifiers from ChangesModel ID Config Migration
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
docker/entrypoint.sh (1)
275-280:⚠️ Potential issue | 🟠 Major | ⚡ Quick winDon't hide a cross-table config rewrite behind
--init-model-provider-tables.Line 280 makes this flag mutate
tenant,document,search,user_canvas*,pipeline_operation_log, and other non-provider tables as well. That changes the operational contract of the flag and can surprise operators who only intended thetenant_model_*backfill. I'd gatemodel_id_configbehind its own explicit init path, or rename/update the entrypoint contract in the same change.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@docker/entrypoint.sh` around lines 275 - 280, The current INIT_MODEL_PROVIDER_TABLES branch runs migrations for tenant_model_provider, tenant_model_instance, tenant_model, and also model_id_config which mutates non-provider tables; change the entrypoint logic so model_id_config is not hidden behind INIT_MODEL_PROVIDER_TABLES: add a new explicit env flag (e.g., INIT_MODEL_ID_CONFIG_TABLES) or rename the existing flag to reflect the broader behavior, and gate the "$PY tools/scripts/mysql_migration.py --stages model_id_config --config conf/service_conf.yaml --execute" call behind that new flag (or adjust naming/contract) while leaving tenant_model_* migrations under INIT_MODEL_PROVIDER_TABLES; update any related docs/comments to match the new flag name.
🧹 Nitpick comments (1)
tools/scripts/mysql_migration.py (1)
912-975: 🏗️ Heavy liftAvoid the second full-table pass before updates.
check()walks every configured table viacount_changes(), andexecute()immediately repeats the same scans/parsing again. With large tables likepipeline_operation_logandevaluation_runs, that doubles the I/O and JSON work for this init path. Cache the pending updates fromcheck()or letexecute()stream the migration in a single pass.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tools/scripts/mysql_migration.py` around lines 912 - 975, The check() method currently calls count_changes() and forces a full scan, and execute() then re-scans via iter_string_changes() and iter_json_changes(), doubling I/O; modify check() to cache the pending change rows (e.g., store a list on self like self._pending_changes containing tuples for both string and json updates returned by count_changes() or by a new helper that yields rows), have count_changes() either return those lists or produce them via a single iterator, and update execute() to consume self._pending_changes (respecting create_table_only and dry_run and using db.execute_sql as before) instead of re-iterating tables; ensure names referenced: check(), execute(), count_changes(), iter_string_changes(), iter_json_changes(), self._pending_changes, create_table_only, dry_run, and db.execute_sql.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@docker/entrypoint.sh`:
- Around line 275-280: The current INIT_MODEL_PROVIDER_TABLES branch runs
migrations for tenant_model_provider, tenant_model_instance, tenant_model, and
also model_id_config which mutates non-provider tables; change the entrypoint
logic so model_id_config is not hidden behind INIT_MODEL_PROVIDER_TABLES: add a
new explicit env flag (e.g., INIT_MODEL_ID_CONFIG_TABLES) or rename the existing
flag to reflect the broader behavior, and gate the "$PY
tools/scripts/mysql_migration.py --stages model_id_config --config
conf/service_conf.yaml --execute" call behind that new flag (or adjust
naming/contract) while leaving tenant_model_* migrations under
INIT_MODEL_PROVIDER_TABLES; update any related docs/comments to match the new
flag name.
---
Nitpick comments:
In `@tools/scripts/mysql_migration.py`:
- Around line 912-975: The check() method currently calls count_changes() and
forces a full scan, and execute() then re-scans via iter_string_changes() and
iter_json_changes(), doubling I/O; modify check() to cache the pending change
rows (e.g., store a list on self like self._pending_changes containing tuples
for both string and json updates returned by count_changes() or by a new helper
that yields rows), have count_changes() either return those lists or produce
them via a single iterator, and update execute() to consume
self._pending_changes (respecting create_table_only and dry_run and using
db.execute_sql as before) instead of re-iterating tables; ensure names
referenced: check(), execute(), count_changes(), iter_string_changes(),
iter_json_changes(), self._pending_changes, create_table_only, dry_run, and
db.execute_sql.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 03dd9fa1-9cd0-43e0-ae9e-d24c6f76d5b8
📒 Files selected for processing (2)
docker/entrypoint.shtools/scripts/mysql_migration.py
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #15495 +/- ##
=======================================
Coverage 93.16% 93.16%
=======================================
Files 10 10
Lines 717 717
Branches 118 118
=======================================
Hits 668 668
Misses 29 29
Partials 20 20 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
What problem does this PR solve?
migrate legacy model id configs
Type of change