From 4d48845240f5a0ea7f714307b3d43eb0b706f68b Mon Sep 17 00:00:00 2001 From: Danrui Qi Date: Tue, 19 Dec 2023 10:05:38 +0800 Subject: [PATCH] Fix the error of show baselines after builing package (#190) --- dbgpt_hub/baseline/show_result.py | 10 +++++++--- pyproject.toml | 3 ++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/dbgpt_hub/baseline/show_result.py b/dbgpt_hub/baseline/show_result.py index 887d267..b3c58c3 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 @@ -27,7 +28,7 @@ "all", ] -baseline_file = "./dbgpt_hub/baseline/baseline.json" +baseline_file = "baseline/baseline.json" ALPACA = 'I want you to act as a SQL terminal in front of an example database, you need only to return the sql command to me.Below is an instruction that describes a task, Write a response that appropriately completes the request.\\n\\"\\n##Instruction:\\ndepartment_management contains tables such as department, head, management. Table department has columns such as Department_ID, Name, Creation, Ranking, Budget_in_Billions, Num_Employees. Department_ID is the primary key.\\nTable head has columns such as head_ID, name, born_state, age. head_ID is the primary key.\\nTable management has columns such as department_ID, head_ID, temporary_acting. department_ID is the primary key.\\nThe head_ID of management is the foreign key of head_ID of head.\\nThe department_ID of management is the foreign key of Department_ID of department.\\n\\n' OPENAI = "openai" @@ -73,8 +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): diff --git a/pyproject.toml b/pyproject.toml index 189ea13..b6d6018 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,10 +1,11 @@ [tool.poetry] name = "dbgpt_hub" -version = "0.2.1" +version = "0.3.0" 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"