From d227cb3f578e658d9c25b3eab67faf0b9df6587e Mon Sep 17 00:00:00 2001 From: qidanrui Date: Mon, 18 Dec 2023 14:20:06 +0000 Subject: [PATCH 1/3] fix the error of show baselines after builing package --- dbgpt_hub/baseline/show_result.py | 16 ++++++++++------ pyproject.toml | 1 + 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/dbgpt_hub/baseline/show_result.py b/dbgpt_hub/baseline/show_result.py index bcc2046..b3cb6e2 100644 --- a/dbgpt_hub/baseline/show_result.py +++ b/dbgpt_hub/baseline/show_result.py @@ -1,6 +1,7 @@ import os import sys import json +import pkgutil from typing import Optional, Dict, Any from prettytable.colortable import ColorTable, Theme from prettytable.colortable import ColorTable, Theme @@ -46,12 +47,15 @@ "extra", "all", ] -baseline_file = "./dbgpt_hub/baseline/baseline.json" - - -with open(baseline_file, "r") as file: - baseline_json = json.load(file) - +baseline_file = "baseline/baseline.json" + +data = pkgutil.get_data("dbgpt_hub", baseline_file) +if data is not None: + baseline_json = json.loads(data.decode("utf-8")) +else: + raise FileNotFoundError("The JSON file was not found in the package.") +# with open(baseline_file, "r") as file: +# baseline_json = json.load(file) def print_color_table_score(acc_data, dataset, model, method, prompt): model_data = [dataset, model, method, prompt] diff --git a/pyproject.toml b/pyproject.toml index 189ea13..03f2fac 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,6 +5,7 @@ description = "DB-GPT-Hub: Text-to-SQL parsing with LLMs" authors = ["Your Name "] license = "MIT" readme = "README.md" +include = ["dbgpt_hub/baseline/baseline.json"] [tool.poetry.dependencies] python = ">=3.10,<3.13" From 66d4e04842da221e2bd671a59b3164d22f91b75d Mon Sep 17 00:00:00 2001 From: qidanrui Date: Mon, 18 Dec 2023 14:32:52 +0000 Subject: [PATCH 2/3] fix the error of show baselines after builing package --- dbgpt_hub/baseline/show_result.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/dbgpt_hub/baseline/show_result.py b/dbgpt_hub/baseline/show_result.py index 72a2973..c7a85e7 100644 --- a/dbgpt_hub/baseline/show_result.py +++ b/dbgpt_hub/baseline/show_result.py @@ -74,9 +74,11 @@ def init_baseline_json(): json.dump(json_data, file, indent=4) -with open(baseline_file, "r") as file: - baseline_json = json.load(file) - +data = pkgutil.get_data("dbgpt_hub", baseline_file) +if data is not None: + baseline_json = json.loads(data.decode("utf-8")) +else: + raise FileNotFoundError("The JSON file was not found in the package.") def table_add_row(table_scores, acc_data, dataset, model, method, prompt): model_data = [dataset, model, method, prompt] From b6e5e289f577fdbd408762658201f60f06f77dcd Mon Sep 17 00:00:00 2001 From: qidanrui Date: Mon, 18 Dec 2023 14:40:16 +0000 Subject: [PATCH 3/3] fix the error of show baselines after builing package --- dbgpt_hub/baseline/show_result.py | 1 + 1 file changed, 1 insertion(+) diff --git a/dbgpt_hub/baseline/show_result.py b/dbgpt_hub/baseline/show_result.py index c7a85e7..b3c58c3 100644 --- a/dbgpt_hub/baseline/show_result.py +++ b/dbgpt_hub/baseline/show_result.py @@ -80,6 +80,7 @@ def init_baseline_json(): else: raise FileNotFoundError("The JSON file was not found in the package.") + def table_add_row(table_scores, acc_data, dataset, model, method, prompt): model_data = [dataset, model, method, prompt] model_ex = get_model_score(acc_data, "ex", model_data)