Skip to content

Commit b8d3f11

Browse files
committed
various data-loader templates
1 parent 596686a commit b8d3f11

File tree

3 files changed

+4
-8
lines changed

3 files changed

+4
-8
lines changed

py-src/data_formulator/agents/agent_py_data_rec.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ def process_gpt_response(self, input_tables, messages, response):
165165
if result['status'] == 'ok':
166166
result_df = result['content']
167167
result['content'] = {
168-
'rows': result_df.to_dict(orient='records'),
168+
'rows': json.loads(result_df.to_json(orient='records')),
169169
}
170170
else:
171171
logger.info(result['content'])

py-src/data_formulator/agents/agent_py_data_transform.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,13 +221,11 @@ def process_gpt_response(self, input_tables, messages, response):
221221
result = py_sandbox.run_transform_in_sandbox2020(code_str, [pd.DataFrame.from_records(t['rows']) for t in input_tables], self.exec_python_in_subprocess)
222222
result['code'] = code_str
223223

224-
print(f"result: {result}")
225-
226224
if result['status'] == 'ok':
227225
# parse the content
228226
result_df = result['content']
229227
result['content'] = {
230-
'rows': result_df.to_dict(orient='records'),
228+
'rows': json.loads(result_df.to_json(orient='records')),
231229
}
232230
else:
233231
logger.info(result['content'])

py-src/data_formulator/db_manager.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import duckdb
22
import pandas as pd
3-
from typing import Optional, Dict, List, ContextManager, Any, Tuple
4-
import time
5-
from flask import session
3+
from typing import Dict
64
import tempfile
75
import os
86
from contextlib import contextmanager
@@ -15,7 +13,7 @@ def __init__(self, local_db_dir: str):
1513
self._local_db_dir: str = local_db_dir
1614

1715
@contextmanager
18-
def connection(self, session_id: str) -> ContextManager[duckdb.DuckDBPyConnection]:
16+
def connection(self, session_id: str):
1917
"""Get a DuckDB connection as a context manager that will be closed when exiting the context"""
2018
conn = None
2119
try:

0 commit comments

Comments
 (0)