Skip to content

Commit f096e33

Browse files
Merge pull request #81 from DeepInsight-AI/new_pre
fix dashboard and autopilot
2 parents 0a3f7fe + 8d51e93 commit f096e33

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

ai/backend/aidb/autopilot/autopilot.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,9 @@ def generate_report_template(self, data):
157157
current_directory = CONFIG.up_file_path
158158

159159
# 构建路径时使用 os.path.join,并使用 os.path.normpath 进行规范化
160-
html_template_path = os.path.join(os.path.normpath(current_directory.replace(r'\user_upload_files', '')), 'ai', 'backend', 'aidb', 'autopilot')
160+
html_template_path = os.path.join(os.path.normpath(current_directory.replace('user_upload_files', '')), 'ai', 'backend', 'aidb', 'autopilot')
161161
html_template_path = html_template_path.replace('\\', '/')
162+
html_file_path = os.path.normpath(html_file_path)
162163

163164
if CONFIG.web_language == 'CN':
164165
html_template_path = os.path.join(html_template_path, 'html_template')
@@ -182,7 +183,7 @@ def generate_report_template(self, data):
182183
# print('rendered_html : ', rendered_html)
183184

184185
# 将渲染后的HTML写入文件
185-
with open(CONFIG.up_file_path + 'output_' + str(timestamp) + '.html', 'w') as output_file:
186+
with open(CONFIG.up_file_path + 'output_' + str(timestamp) + '.html', 'w',encoding='utf-8') as output_file:
186187
output_file.write(rendered_html)
187188

188189
print("HTML文件已生成:output.html")

ai/backend/aidb/dashboard/prettify_dashboard.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ async def generate_echart_code(self, echart_json, task_file_name, task_id, html_
9696
current_directory = CONFIG.up_file_path
9797

9898
# 构建路径时使用 os.path.join
99-
html_file_path = os.path.join(current_directory.replace(r'\user_upload_files', ''), 'bi', 'templates')
99+
html_file_path = os.path.join(current_directory.replace('user_upload_files', ''), 'bi', 'templates')
100+
html_file_path = os.path.normpath(html_file_path)
100101

101102
self.generate_html(echart_json, os.path.join(html_file_path, html_file_name))
102103

@@ -133,7 +134,7 @@ def generate_html(self, data, html_file_name):
133134
rendered_html = template.render(data)
134135

135136
# 将渲染后的HTML写入文件
136-
with open(html_file_name, 'w') as output_file:
137+
with open(html_file_name, 'w',encoding='utf-8') as output_file:
137138
output_file.write(rendered_html)
138139

139140
print("HTML文件已生成:", html_file_name)

ai/backend/util/base_util.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import os
33
from dotenv import load_dotenv
44
from pathlib import Path
5+
from bi.settings import DATA_SOURCE_FILE_DIR as docker_data_source_file_dir
56

67

78
host_secret = 'tNGoVq0KpQ4LKr5WMIZM'
@@ -20,7 +21,7 @@ def is_json(myjson):
2021

2122
def get_upload_path():
2223
# 加载 .env 文件中的环境变量
23-
data_source_file_dir = os.environ.get("DATA_SOURCE_FILE_DIR", None)
24+
data_source_file_dir = os.environ.get("DATA_SOURCE_FILE_DIR",docker_data_source_file_dir)
2425
if data_source_file_dir and len(str(data_source_file_dir)) > 0:
2526
return str(data_source_file_dir) + '/'
2627
else:

0 commit comments

Comments
 (0)