Skip to content

Commit

Permalink
add build error msg (#558)
Browse files Browse the repository at this point in the history
<!-- Thank you for your contribution! -->
<!-- Unless your change is trivial, please create an issue to discuss
the change before creating a PR -->

## Change Summary

add build error msg


## Related issue number

<!-- WARNING: please use "fix #123" style references so the issue is
closed when this PR is merged. -->

## Checklist

* [ ] The pull request title is a good summary of the changes - it will
be used in the changelog
* [ ] Unit tests for the changes exist
* [x] Run `pre-commit install` and `pre-commit run --all-files` before
git commit, and passed lint check.
* [ ] Some cases need DASHSCOPE_TOKEN_API to pass the Unit Tests, I have
at least **pass the Unit tests on local**
* [ ] Documentation reflects the changes where applicable
* [ ] My PR is ready to review, **please add a comment including the
phrase "please review" to assign reviewers**
  • Loading branch information
Zhikaiiii authored Jul 30, 2024
2 parents c860082 + 006d8c1 commit ec59259
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 41 deletions.
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

0 comments on commit ec59259

Please sign in to comment.