| #!/usr/bin/env bash |
| |
| set -euo pipefail |
|
|
| ROOT="$(cd "$(dirname "$0")/.." && pwd)" |
| cd "$ROOT" |
|
|
| echo "π MorphSQL β Local Setup" |
| echo "==========================================" |
| echo "" |
|
|
| |
| if [ ! -d ".venv" ]; then |
| echo "π¦ Creating virtual environment..." |
| python3 -m venv .venv |
| fi |
|
|
| source .venv/bin/activate |
|
|
| |
| echo "π¦ Installing dependencies..." |
| pip install -q -e ".[dev,demo]" |
|
|
| |
| echo "" |
| echo "π§ͺ Running tests..." |
| pytest tests/ -v --tb=short |
|
|
| |
| echo "" |
| echo "π Running CLI analyze on example repo..." |
| morphsql analyze examples/vertica_legacy --source vertica --target snowflake --output ./migration-output |
|
|
| |
| echo "" |
| echo "π Running full migration pipeline..." |
| morphsql migrate examples/vertica_legacy --source vertica --target snowflake --output ./migration-output |
|
|
| |
| echo "" |
| echo "β
Verifying outputs..." |
| test -f ./migration-output/migration_report.html && echo " β HTML report generated" |
| test -d ./migration-output/dbt && echo " β dbt projects generated" |
| DBT_COUNT=$(find ./migration-output/dbt -name "dbt_project.yml" | wc -l | tr -d ' ') |
| echo " β $DBT_COUNT dbt projects created" |
|
|
| |
| echo "" |
| echo "π Testing Gradio handlers..." |
| python -c " |
| from pathlib import Path |
| import pandas as pd |
| from demo.handlers import ( |
| convert_for_ui, |
| analyze_sql_object, |
| get_sample_workbench, |
| run_feature_migration, |
| run_behavior_rag, |
| ) |
| from app import _build_demo |
| |
| # Simple SELECT β must produce a live sample preview DataFrame |
| simple = 'SELECT ZEROIFNULL(amount) AS amt FROM staging.orders WHERE id = 1' |
| notes, output, status, share, preview, path, nb, api = convert_for_ui(simple, 'vertica', 'pandas') |
| assert output.strip() and 'pandas' in output.lower() |
| assert isinstance(preview, pd.DataFrame) and not preview.empty |
| |
| # Procedure β conversion must succeed (preview may be empty for procedural SQL) |
| proc = Path('examples/vertica_legacy/procedures/SP_BUILD_CUSTOMER_DAILY.sql').read_text() |
| notes2, output2, *_ = convert_for_ui(proc, 'vertica', 'pandas') |
| assert output2.strip() |
| |
| analysis, fig, badge, out, notes3 = analyze_sql_object(proc, 'vertica', 'snowflake') |
| assert out.strip() and badge |
| |
| wb = get_sample_workbench() |
| assert len(wb) == 12 |
| |
| md, feat = run_feature_migration('snowflake') |
| assert feat.strip() |
| |
| rag = run_behavior_rag('ZEROIFNULL', 'vertica', 'snowflake') |
| assert 'ZEROIFNULL' in rag.upper() or len(rag) > 20 |
| |
| assert _build_demo() is not None |
| print(' β Convert, preview, assess, workbench, features, RAG, Gradio build OK') |
| " |
|
|
| echo "" |
| echo "==========================================" |
| echo "β
All checks passed! Ready to test." |
| echo "" |
| echo "Next steps:" |
| echo " 1. Launch the Gradio demo:" |
| echo " python app.py" |
| echo "" |
| echo " 2. Or use the CLI:" |
| echo " morphsql analyze examples/vertica_legacy --source vertica --target snowflake" |
| echo " morphsql convert examples/vertica_legacy/queries/customer_lifetime_value.sql --source vertica --target pandas -o migration-output/pandas" |
| echo " morphsql migrate examples/vertica_legacy --source vertica --target snowflake --output migration-output" |
| echo "" |
| echo " 3. Open the HTML report:" |
| echo " open migration-output/migration_report.html" |
| echo "" |
|
|