Skip to content

Commit deb1158

Browse files
committed
feat(migrate): [2/6] interactive migration wizard with CLI subcommand
Adds guided migration builder for interactive plan creation: - wizard.py: MigrationWizard with index selection, field operations, vector tuning, quantization, and preview - cli/migrate.py: adds 'wizard' subcommand (rvl migrate wizard --index <name>) - Unit tests for wizard logic (41 tests)
1 parent f8121b2 commit deb1158

4 files changed

Lines changed: 2066 additions & 1 deletion

File tree

redisvl/cli/migrate.py

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@
33
from typing import Optional
44

55
from redisvl.cli.utils import add_redis_connection_options, create_redis_url
6-
from redisvl.migration import MigrationExecutor, MigrationPlanner, MigrationValidator
6+
from redisvl.migration import (
7+
MigrationExecutor,
8+
MigrationPlanner,
9+
MigrationValidator,
10+
MigrationWizard,
11+
)
712
from redisvl.migration.utils import (
813
detect_aof_enabled,
914
estimate_disk_space,
@@ -25,6 +30,7 @@ class Migrate:
2530
"Commands:",
2631
"\thelper Show migration guidance and supported capabilities",
2732
"\tlist List all available indexes",
33+
"\twizard Interactively build a migration plan and schema patch",
2834
"\tplan Generate a migration plan for a document-preserving drop/recreate migration",
2935
"\tapply Execute a reviewed drop/recreate migration plan",
3036
"\testimate Estimate disk space required for a migration plan (dry-run, no mutations)",
@@ -84,6 +90,7 @@ def helper(self):
8490
8591
Commands:
8692
rvl migrate list List all indexes
93+
rvl migrate wizard --index <name> Guided migration builder
8794
rvl migrate plan --index <name> --schema-patch <patch.yaml>
8895
rvl migrate apply --plan <plan.yaml>
8996
rvl migrate validate --plan <plan.yaml>"""
@@ -101,6 +108,58 @@ def list(self):
101108
for position, index_name in enumerate(indexes, start=1):
102109
print(f"{position}. {index_name}")
103110

111+
def wizard(self):
112+
parser = argparse.ArgumentParser(
113+
usage=(
114+
"rvl migrate wizard [--index <name>] "
115+
"[--patch <existing_patch.yaml>] "
116+
"[--plan-out <migration_plan.yaml>] [--patch-out <schema_patch.yaml>]"
117+
)
118+
)
119+
parser.add_argument("-i", "--index", help="Source index name", required=False)
120+
parser.add_argument(
121+
"--patch",
122+
help="Load an existing schema patch to continue editing",
123+
default=None,
124+
)
125+
parser.add_argument(
126+
"--plan-out",
127+
help="Path to write migration_plan.yaml",
128+
default="migration_plan.yaml",
129+
)
130+
parser.add_argument(
131+
"--patch-out",
132+
help="Path to write schema_patch.yaml (for later editing)",
133+
default="schema_patch.yaml",
134+
)
135+
parser.add_argument(
136+
"--target-schema-out",
137+
help="Optional path to write the merged target schema",
138+
default=None,
139+
)
140+
parser.add_argument(
141+
"--key-sample-limit",
142+
help="Maximum number of keys to sample from the index keyspace",
143+
type=int,
144+
default=10,
145+
)
146+
parser = add_redis_connection_options(parser)
147+
args = parser.parse_args(sys.argv[3:])
148+
149+
redis_url = create_redis_url(args)
150+
wizard = MigrationWizard(
151+
planner=MigrationPlanner(key_sample_limit=args.key_sample_limit)
152+
)
153+
plan = wizard.run(
154+
index_name=args.index,
155+
redis_url=redis_url,
156+
existing_patch_path=args.patch,
157+
plan_out=args.plan_out,
158+
patch_out=args.patch_out,
159+
target_schema_out=args.target_schema_out,
160+
)
161+
self._print_plan_summary(args.plan_out, plan)
162+
104163
def plan(self):
105164
parser = argparse.ArgumentParser(
106165
usage=(

redisvl/migration/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
from redisvl.migration.executor import MigrationExecutor
22
from redisvl.migration.planner import MigrationPlanner
33
from redisvl.migration.validation import MigrationValidator
4+
from redisvl.migration.wizard import MigrationWizard
45

56
__all__ = [
67
"MigrationExecutor",
78
"MigrationPlanner",
89
"MigrationValidator",
10+
"MigrationWizard",
911
]

0 commit comments

Comments
 (0)