Skip to content

Commit

Permalink
Merge pull request #81 from DeepInsight-AI/new_pre
Browse files Browse the repository at this point in the history
fix dashboard and autopilot
  • Loading branch information
LiChengxin007 authored Jan 23, 2024
2 parents 0a3f7fe + 8d51e93 commit f096e33
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
5 changes: 3 additions & 2 deletions ai/backend/aidb/autopilot/autopilot.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,9 @@ def generate_report_template(self, data):
current_directory = CONFIG.up_file_path

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

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

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

print("HTML文件已生成:output.html")
Expand Down
5 changes: 3 additions & 2 deletions ai/backend/aidb/dashboard/prettify_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ async def generate_echart_code(self, echart_json, task_file_name, task_id, html_
current_directory = CONFIG.up_file_path

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

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

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

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

print("HTML文件已生成:", html_file_name)
Expand Down
3 changes: 2 additions & 1 deletion ai/backend/util/base_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os
from dotenv import load_dotenv
from pathlib import Path
from bi.settings import DATA_SOURCE_FILE_DIR as docker_data_source_file_dir


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

def get_upload_path():
# 加载 .env 文件中的环境变量
data_source_file_dir = os.environ.get("DATA_SOURCE_FILE_DIR", None)
data_source_file_dir = os.environ.get("DATA_SOURCE_FILE_DIR",docker_data_source_file_dir)
if data_source_file_dir and len(str(data_source_file_dir)) > 0:
return str(data_source_file_dir) + '/'
else:
Expand Down

0 comments on commit f096e33

Please sign in to comment.