Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(wren-ai-service): improve ai service #1068

Merged
merged 8 commits into from
Dec 27, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update
  • Loading branch information
cyyeh committed Dec 26, 2024
commit 6f0cd4a04c61aafbb107e2138e8f544979c0c6b7
4 changes: 2 additions & 2 deletions wren-ai-service/Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,5 @@ prepare-wren-engine:
use-wren-ui-as-engine:
poetry run python -m src.force_update_config

test-sql mdl_path="./tests/data/usecases/hubspot/mdl.json" dataset_type="bigquery":
poetry run python demo/test_sql.py --mdl-path "{{mdl_path}}" --dataset-type "{{dataset_type}}"
test-sql mdl_path="" dataset_type="bigquery" dataset="":
poetry run python demo/test_sql.py --mdl-path "{{mdl_path}}" --dataset-type "{{dataset_type}}" --dataset "{{dataset}}"
17 changes: 15 additions & 2 deletions wren-ai-service/demo/test_sql.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import argparse
import json

from utils import get_data_from_wren_engine
from utils import get_data_from_wren_engine, rerun_wren_engine


def main():
Expand All @@ -10,7 +10,10 @@ def main():
)

parser.add_argument(
"--mdl-path", type=str, required=True, help="Path to MDL JSON file"
"--mdl-path",
type=str,
required=True,
help="Path to MDL JSON file",
)

parser.add_argument(
Expand All @@ -21,6 +24,14 @@ def main():
help="Dataset type (default: bigquery)",
)

parser.add_argument(
"--dataset",
type=str,
default="ecommerce",
choices=["ecommerce", "hr", ""],
help="Dataset (default: ecommerce)",
)

args = parser.parse_args()

# Load MDL JSON file
Expand All @@ -34,6 +45,8 @@ def main():
print(f"Error: Invalid JSON in MDL file {args.mdl_path}")
return

rerun_wren_engine(mdl_json, args.dataset_type, args.dataset)

# Execute query
print("Enter SQL query (end with semicolon on a new line to execute, 'q' to quit):")
lines = []
Expand Down
2 changes: 1 addition & 1 deletion wren-ai-service/demo/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def _update_wren_engine_configs(configs: list[dict]):
assert response.status_code == 200


def rerun_wren_engine(mdl_json: Dict, dataset_type: str, dataset: str):
def rerun_wren_engine(mdl_json: Dict, dataset_type: str, dataset: Optional[str] = None):
assert dataset_type in DATA_SOURCES

SOURCE = dataset_type
Expand Down