Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add build error msg #558

Merged
merged 2 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/codexgraph_agent/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def main(self):
```bash
conda create --name index_build python=3.9

conda activate myenv
conda activate index_build

pip install -r build_requirements.txt
```
Expand Down
13 changes: 7 additions & 6 deletions apps/codexgraph_agent/pages/components/page.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,9 +309,6 @@ def repo_db_test(self):
if self.build_graph_db():
page_state['build_place'].success(
f"File path set to: {setting['repo_path']}")
else:
page_state['build_place'].error(
'Something went wrong during the build process.')

if page_state['test_connect_button']:
if self.get_graph_db():
Expand Down Expand Up @@ -348,6 +345,7 @@ def build_graph_db(self):
setting = st.session_state.shared['setting']
env_path_setting = setting['env_path_dict']
neo4j_setting = setting['neo4j']
page_state = st.session_state[self.page_name]

env_path_dict = {
'env_path': env_path_setting['env_path'],
Expand All @@ -359,9 +357,10 @@ def build_graph_db(self):
}

graph_db = self.get_graph_db(setting['project_id'])
msg = ''
if graph_db:
try:
build_graph_database(
msg = build_graph_database(
graph_db,
setting['repo_path'],
task_id=setting['project_id'],
Expand All @@ -370,11 +369,13 @@ def build_graph_db(self):
env_path_dict=env_path_dict,
update_progress_bar=self.create_update_progress_bar())
except Exception as e:
self.warning(
page_state['build_place'].error(
f'An error occurred while building the graph database: {str(e)}'
)
graph_db = None

if msg:
page_state['build_place'].error(msg)
return None
return graph_db

@abstractmethod
Expand Down
43 changes: 9 additions & 34 deletions modelscope_agent/environment/graph_database/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,15 @@ def build_graph_database(graph_db: GraphDatabaseHandler,
for i, future in enumerate(as_completed(future_to_file)):
file_path = future_to_file[future]
try:
# future.result()
pass
# print('Successfully processed {}'.format(file_path))
future.result()
print('Successfully processed {}'.format(file_path))
except Exception as exc:
print('{} generated an exception: {}'.format(file_path, exc))
# logger.debug("{} generated an exception: {}".format(file_path, exc))
msg = '`{}` generated an exception: `{}`'.format(
file_path, exc)
print(msg)
# 在捕获到异常后,停止提交新任务,并尝试取消所有未完成的任务
executor.shutdown(wait=False, cancel_futures=True)
return msg
finally:
# 每完成一个任务,更新进度条
if update_progress_bar:
Expand All @@ -136,32 +139,4 @@ def build_graph_database(graph_db: GraphDatabaseHandler,
elapsed_time = end_time - start_time
print(f'✍️ Shallow indexing ({int(elapsed_time)} s)')
# logger.info(f"✍️ Shallow indexing ({int(elapsed_time)} s)")
return graph_db


if __name__ == '__main__':
graph_db = GraphDatabaseHandler(
uri='bolt://localhost:7687',
user='neo4j',
password='12345678',
database_name='neo4j',
task_id='0729',
use_lock=True,
)
env_path_dict = {
'env_path': r'C:\Users\12053\anaconda3\envs\test\python.exe',
'working_directory':
r'D:\study\postgraduate\study_project\alibaba_LLM\codexgraph\indexer_test',
'url': r'bolt://localhost:7687',
'user': 'neo4j',
'password': '12345678',
'db_name': 'neo4j'
}
repo_path = r'D:\study\postgraduate\study_project\alibaba_LLM\codexgraph\test_repo\test_repo'
build_graph_database(
graph_db,
repo_path,
task_id='0729',
is_clear=True,
max_workers=8,
env_path_dict=env_path_dict)
return None
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,10 @@ def recordQualifierLocation(self, referencedSymbolId, sourceRange):
pass

def recordFile(self, filePath):
self.indexedFileId = 1
self.indexedFileId_to_path[self.indexedFileId] = filePath.replace(
'\\', '/')
self.this_file_path = self.indexedFileId_to_path[self.indexedFileId]
return 1

def recordFileLanguage(self, fileId, languageIdentifier):
Expand Down
Loading