Skip to content

Commit c80c315

Browse files
authored
Merge branch 'dev' into users/nguyenphong/filter-tables-and-fix-datetime-format-in-kusto
2 parents a80a29d + 868a322 commit c80c315

35 files changed

+2235
-1526
lines changed

local_server.bat

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,5 @@
66
:: set http_proxy=http://127.0.0.1:7890
77
:: set https_proxy=http://127.0.0.1:7890
88

9-
set FLASK_APP=py-src/data_formulator/app.py
109
set FLASK_RUN_PORT=5000
11-
set FLASK_RUN_HOST=0.0.0.0
12-
flask run
10+
python -m py-src.data_formulator.app --port %FLASK_RUN_PORT% --dev

local_server.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@
55
# export http_proxy=http://127.0.0.1:7890
66
# export https_proxy=http://127.0.0.1:7890
77

8-
env FLASK_APP=py-src/data_formulator/app.py FLASK_RUN_PORT=5000 FLASK_RUN_HOST=0.0.0.0 flask run
8+
#env FLASK_APP=py-src/data_formulator/app.py FLASK_RUN_PORT=5000 FLASK_RUN_HOST=0.0.0.0 flask run
9+
export FLASK_RUN_PORT=5000
10+
python -m py-src.data_formulator.app --port ${FLASK_RUN_PORT} --dev

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
"@emotion/react": "^11.14.0",
88
"@emotion/styled": "^11.14.0",
99
"@fontsource/roboto": "^4.5.5",
10-
"@mui/icons-material": "^5.14.0",
11-
"@mui/material": "^7.0.2",
10+
"@mui/icons-material": "^7.1.1",
11+
"@mui/material": "^7.1.1",
1212
"@reduxjs/toolkit": "^1.8.6",
1313
"@types/dompurify": "^3.0.5",
1414
"@types/validator": "^13.12.2",

py-src/data_formulator/agent_routes.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,8 +425,6 @@ def request_code_expl():
425425
if request.is_json:
426426
logger.info("# request data: ")
427427
content = request.get_json()
428-
token = content["token"]
429-
430428
client = get_client(content['model'])
431429

432430
# each table is a dict with {"name": xxx, "rows": [...]}

py-src/data_formulator/app.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,17 @@
2929
from dotenv import load_dotenv
3030
import secrets
3131
import base64
32-
APP_ROOT = Path(os.path.join(Path(__file__).parent)).absolute()
32+
APP_ROOT = Path(Path(__file__).parent).absolute()
3333

3434
import os
3535

3636
# blueprints
3737
from data_formulator.tables_routes import tables_bp
3838
from data_formulator.agent_routes import agent_bp
39+
from data_formulator.sse_routes import sse_bp
3940

41+
import queue
42+
from typing import Dict, Any
4043

4144
app = Flask(__name__, static_url_path='', static_folder=os.path.join(APP_ROOT, "dist"))
4245
app.secret_key = secrets.token_hex(16) # Generate a random secret key for sessions
@@ -65,6 +68,7 @@ def default(self, obj):
6568
# register blueprints
6669
app.register_blueprint(tables_bp)
6770
app.register_blueprint(agent_bp)
71+
app.register_blueprint(sse_bp)
6872

6973
print(APP_ROOT)
7074

@@ -252,6 +256,8 @@ def parse_args() -> argparse.Namespace:
252256
help="Whether to execute python in subprocess, it makes the app more secure (reducing the chance for the model to access the local machine), but increases the time of response")
253257
parser.add_argument("-d", "--disable-display-keys", action='store_true', default=False,
254258
help="Whether disable displaying keys in the frontend UI, recommended to turn on if you host the app not just for yourself.")
259+
parser.add_argument("--dev", action='store_true', default=False,
260+
help="Launch the app in development mode (prevents the app from opening the browser automatically)")
255261
return parser.parse_args()
256262

257263

@@ -264,11 +270,14 @@ def run_app():
264270
'disable_display_keys': args.disable_display_keys
265271
}
266272

267-
url = "http://localhost:{0}".format(args.port)
268-
threading.Timer(2, lambda: webbrowser.open(url, new=2)).start()
273+
if not args.dev:
274+
url = "http://localhost:{0}".format(args.port)
275+
threading.Timer(2, lambda: webbrowser.open(url, new=2)).start()
276+
277+
# Enable debug mode and auto-reload in development mode
278+
debug_mode = args.dev
279+
app.run(host='0.0.0.0', port=args.port, threaded=True, debug=debug_mode, use_reloader=debug_mode)
269280

270-
app.run(host='0.0.0.0', port=args.port, threaded=True)
271-
272281
if __name__ == '__main__':
273282
#app.run(debug=True, host='127.0.0.1', port=5000)
274283
#use 0.0.0.0 for public
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
from data_formulator.data_loader.external_data_loader import ExternalDataLoader
22
from data_formulator.data_loader.mysql_data_loader import MySQLDataLoader
3+
from data_formulator.data_loader.mssql_data_loader import MSSQLDataLoader
34
from data_formulator.data_loader.kusto_data_loader import KustoDataLoader
45
from data_formulator.data_loader.s3_data_loader import S3DataLoader
56
from data_formulator.data_loader.azure_blob_data_loader import AzureBlobDataLoader
7+
from data_formulator.data_loader.postgresql_data_loader import PostgreSQLDataLoader
68

79
DATA_LOADERS = {
810
"mysql": MySQLDataLoader,
11+
"mssql": MSSQLDataLoader,
912
"kusto": KustoDataLoader,
1013
"s3": S3DataLoader,
1114
"azure_blob": AzureBlobDataLoader,
15+
"postgresql": PostgreSQLDataLoader
1216
}
1317

14-
__all__ = ["ExternalDataLoader", "MySQLDataLoader", "KustoDataLoader", "S3DataLoader", "AzureBlobDataLoader", "DATA_LOADERS"]
18+
__all__ = ["ExternalDataLoader", "MySQLDataLoader", "MSSQLDataLoader", "KustoDataLoader", "S3DataLoader", "AzureBlobDataLoader","PostgreSQLDataLoader","DATA_LOADERS"]
19+

0 commit comments

Comments
 (0)