Skip to content

Commit

Permalink
typos fix
Browse files Browse the repository at this point in the history
  • Loading branch information
oushu1zhangxiangxuan1 committed Oct 10, 2023
1 parent 1cdaaeb commit 02bbad4
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 38 deletions.
4 changes: 2 additions & 2 deletions pilot/server/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def signal_handler(sig, frame):
os._exit(0)


def async_db_summery(system_app: SystemApp):
def async_db_summary(system_app: SystemApp):
from pilot.summary.db_summary_client import DBSummaryClient

client = DBSummaryClient(system_app=system_app)
Expand Down Expand Up @@ -79,7 +79,7 @@ def startup_event(wh):
print("begin run _add_app_startup_event")
conn_manage = ConnectManager(system_app)
cfg.LOCAL_DB_MANAGE = conn_manage
async_db_summery(system_app)
async_db_summary(system_app)

return startup_event

Expand Down
12 changes: 6 additions & 6 deletions pilot/summary/db_summary.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
class DBSummary:
def __init__(self, name):
self.name = name
self.summery = None
self.summary = None
self.tables = []
self.metadata = str

def get_summery(self):
return self.summery
def get_summary(self):
return self.summary


class TableSummary:
def __init__(self, name):
self.name = name
self.summery = None
self.summary = None
self.fields = []
self.indexes = []


class FieldSummary:
def __init__(self, name):
self.name = name
self.summery = None
self.summary = None
self.data_type = None


class IndexSummary:
def __init__(self, name):
self.name = name
self.summery = None
self.summary = None
self.bind_fields = []
12 changes: 6 additions & 6 deletions pilot/summary/db_summary_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,21 @@ def db_summary_embedding(self, dbname, db_type):
"embeddings": embeddings,
}
embedding = StringEmbedding(
file_path=db_summary_client.get_summery(),
file_path=db_summary_client.get_summary(),
vector_store_config=vector_store_config,
)
self.init_db_profile(db_summary_client, dbname, embeddings)
if not embedding.vector_name_exist():
if CFG.SUMMARY_CONFIG == "FAST":
for vector_table_info in db_summary_client.get_summery():
for vector_table_info in db_summary_client.get_summary():
embedding = StringEmbedding(
vector_table_info,
vector_store_config,
)
embedding.source_embedding()
else:
embedding = StringEmbedding(
file_path=db_summary_client.get_summery(),
file_path=db_summary_client.get_summary(),
vector_store_config=vector_store_config,
)
embedding.source_embedding()
Expand Down Expand Up @@ -144,8 +144,8 @@ def get_similar_tables(self, dbname, query, topk):
vector_store_config=vector_store_config,
embedding_factory=embedding_factory,
)
table_summery = knowledge_embedding_client.similar_search(query, 1)
related_table_summaries.append(table_summery[0].page_content)
table_summary = knowledge_embedding_client.similar_search(query, 1)
related_table_summaries.append(table_summary[0].page_content)
return related_table_summaries

def init_db_summary(self):
Expand All @@ -169,7 +169,7 @@ def init_db_profile(self, db_summary_client, dbname, embeddings):
"embeddings": embeddings,
}
embedding = StringEmbedding(
file_path=db_summary_client.get_db_summery(),
file_path=db_summary_client.get_db_summary(),
vector_store_config=profile_store_config,
)
if not embedding.vector_name_exist():
Expand Down
48 changes: 24 additions & 24 deletions pilot/summary/rdbms_db_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class RdbmsSummary(DBSummary):
def __init__(self, name, type):
self.name = name
self.type = type
self.summery = """{{"database_name": "{name}", "type": "{type}", "tables": "{tables}", "qps": "{qps}", "tps": {tps}}}"""
self.summary = """{{"database_name": "{name}", "type": "{type}", "tables": "{tables}", "qps": "{qps}", "tps": {tps}}}"""
self.tables = {}
self.tables_info = []
self.vector_tables_info = []
Expand Down Expand Up @@ -48,7 +48,7 @@ def __init__(self, name, type):

for table_name in tables:
table_summary = RdbmsTableSummary(self.db, name, table_name, comment_map)
# self.tables[table_name] = table_summary.get_summery()
# self.tables[table_name] = table_summary.get_summary()
self.tables[table_name] = table_summary.get_columns()
self.table_columns_info.append(table_summary.get_columns())
# self.table_columns_json.append(table_summary.get_summary_json())
Expand All @@ -59,18 +59,18 @@ def __init__(self, name, type):
)
)
self.table_columns_json.append(table_profile)
# self.tables_info.append(table_summary.get_summery())
# self.tables_info.append(table_summary.get_summary())

def get_summery(self):
def get_summary(self):
if CFG.SUMMARY_CONFIG == "FAST":
return self.vector_tables_info
else:
return self.summery.format(
return self.summary.format(
name=self.name, type=self.type, table_info=";".join(self.tables_info)
)

def get_db_summery(self):
return self.summery.format(
def get_db_summary(self):
return self.summary.format(
name=self.name,
type=self.type,
tables=";".join(self.vector_tables_info),
Expand All @@ -94,8 +94,8 @@ class RdbmsTableSummary(TableSummary):
def __init__(self, instance, dbname, name, comment_map):
self.name = name
self.dbname = dbname
self.summery = """database name:{dbname}, table name:{name}, have columns info: {fields}, have indexes info: {indexes}"""
self.json_summery_template = """{{"table_name": "{name}", "comment": "{comment}", "columns": "{fields}", "indexes": "{indexes}", "size_in_bytes": {size_in_bytes}, "rows": {rows}}}"""
self.summary = """database name:{dbname}, table name:{name}, have columns info: {fields}, have indexes info: {indexes}"""
self.json_summary_template = """{{"table_name": "{name}", "comment": "{comment}", "columns": "{fields}", "indexes": "{indexes}", "size_in_bytes": {size_in_bytes}, "rows": {rows}}}"""
self.fields = []
self.fields_info = []
self.indexes = []
Expand All @@ -107,19 +107,19 @@ def __init__(self, instance, dbname, name, comment_map):
for field in fields:
field_summary = RdbmsFieldsSummary(field)
self.fields.append(field_summary)
self.fields_info.append(field_summary.get_summery())
self.fields_info.append(field_summary.get_summary())
field_names.append(field[0])

self.column_summery = """{name}({columns_info})""".format(
self.column_summary = """{name}({columns_info})""".format(
name=name, columns_info=",".join(field_names)
)

for index in indexes:
index_summary = RdbmsIndexSummary(index)
self.indexes.append(index_summary)
self.indexes_info.append(index_summary.get_summery())
self.indexes_info.append(index_summary.get_summary())

self.json_summery = self.json_summery_template.format(
self.json_summary = self.json_summary_template.format(
name=name,
comment=comment_map[name],
fields=self.fields_info,
Expand All @@ -128,34 +128,34 @@ def __init__(self, instance, dbname, name, comment_map):
rows=1000,
)

def get_summery(self):
return self.summery.format(
def get_summary(self):
return self.summary.format(
name=self.name,
dbname=self.dbname,
fields=";".join(self.fields_info),
indexes=";".join(self.indexes_info),
)

def get_columns(self):
return self.column_summery
return self.column_summary

def get_summary_json(self):
return self.json_summery
return self.json_summary


class RdbmsFieldsSummary(FieldSummary):
"""Get mysql field summary template."""

def __init__(self, field):
self.name = field[0]
# self.summery = """column name:{name}, column data type:{data_type}, is nullable:{is_nullable}, default value is:{default_value}, comment is:{comment} """
# self.summery = """{"name": {name}, "type": {data_type}, "is_primary_key": {is_nullable}, "comment":{comment}, "default":{default_value}}"""
# self.summary = """column name:{name}, column data type:{data_type}, is nullable:{is_nullable}, default value is:{default_value}, comment is:{comment} """
# self.summary = """{"name": {name}, "type": {data_type}, "is_primary_key": {is_nullable}, "comment":{comment}, "default":{default_value}}"""
self.data_type = field[1]
self.default_value = field[2]
self.is_nullable = field[3]
self.comment = field[4]

def get_summery(self):
def get_summary(self):
return '{{"name": "{name}", "type": "{data_type}", "is_primary_key": "{is_nullable}", "comment": "{comment}", "default": "{default_value}"}}'.format(
name=self.name,
data_type=self.data_type,
Expand All @@ -170,11 +170,11 @@ class RdbmsIndexSummary(IndexSummary):

def __init__(self, index):
self.name = index[0]
# self.summery = """index name:{name}, index bind columns:{bind_fields}"""
self.summery_template = '{{"name": "{name}", "columns": {bind_fields}}}'
# self.summary = """index name:{name}, index bind columns:{bind_fields}"""
self.summary_template = '{{"name": "{name}", "columns": {bind_fields}}}'
self.bind_fields = index[1]

def get_summery(self):
return self.summery_template.format(
def get_summary(self):
return self.summary_template.format(
name=self.name, bind_fields=self.bind_fields
)

0 comments on commit 02bbad4

Please sign in to comment.