Skip to content

Commit 421155f

Browse files
authored
Merge pull request #188 from AnguseZhang/dev/zhouh
chore: streamline code formatting and enhance pre-commit automation
2 parents 93a1ff1 + f2b7f97 commit 421155f

129 files changed

Lines changed: 2613 additions & 1669 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/dependabot.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
version: 2
22
updates:
3+
# 原有的 GitHub Actions 配置
34
- package-ecosystem: github-actions
45
directory: '/'
56
schedule:
67
interval: weekly
78
open-pull-requests-limit: 99
89
labels:
9-
- 'pr: dependencies'
10+
- 'dependencies'
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Update pre-commit hooks
2+
3+
on:
4+
schedule:
5+
- cron: '0 0 * * 0'
6+
workflow_dispatch:
7+
8+
jobs:
9+
update:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- uses: actions/setup-python@v5
14+
15+
- name: Update pre-commit hooks
16+
uses: creyD/pre-commit-update@v1.2.0
17+
with:
18+
token: ${{ secrets.GITHUB_TOKEN }}
19+
label: 'dependencies'

.pre-commit-config.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,36 @@ repos:
5656
- id: requirements-txt-fixer
5757
- id: sort-simple-yaml
5858
- id: trailing-whitespace
59+
5960
- repo: https://github.com/asottile/pyupgrade
6061
rev: v3.20.0
6162
hooks:
6263
- id: pyupgrade
64+
65+
- repo: https://github.com/psf/black
66+
rev: 23.9.1
67+
hooks:
68+
- id: black
69+
args: [ --skip-string-normalization, --line-length=88 ]
70+
71+
- repo: https://github.com/pycqa/isort
72+
rev: 5.12.0
73+
hooks:
74+
- id: isort
75+
args: [ "--profile", "black" ]
76+
77+
- repo: https://github.com/pycqa/autoflake
78+
rev: v2.2.1
79+
hooks:
80+
- id: autoflake
81+
args:
82+
- --in-place
83+
- --remove-all-unused-imports
84+
- --remove-unused-variables
85+
86+
- repo: https://github.com/pycqa/flake8
87+
rev: 6.1.0
88+
hooks:
89+
- id: flake8
90+
additional_dependencies: [ flake8-bugbear ]
91+
args: [ '--extend-ignore=E501,B036,E203', --max-line-length=88 ]
Lines changed: 21 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,34 @@
1-
from pathlib import Path
2-
from dotenv import load_dotenv
3-
41
from dp.agent.adapter.adk import CalculationMCPToolset
5-
from google.adk.agents import LlmAgent, BaseAgent
6-
from google.adk.models.lite_llm import LiteLlm
7-
from google.adk.runners import Runner
2+
from google.adk.agents import BaseAgent
83
from google.adk.tools.mcp_tool.mcp_session_manager import SseServerParams
94

10-
from agents.matmaster_agent import llm_config
11-
from agents.matmaster_agent.llm_config import MatMasterLlmConfig
12-
from agents.matmaster_agent.logger import matmodeler_logging_handler
13-
14-
from agents.matmaster_agent.base_agents.job_agent import (
15-
BaseAsyncJobAgent,
16-
ResultCalculationMCPLlmAgent,
17-
SubmitCoreCalculationMCPLlmAgent,
18-
)
19-
20-
from agents.matmaster_agent.constant import (
21-
MATMASTER_AGENT_NAME,
22-
BohriumExecutor,
23-
BohriumStorge,
24-
LOCAL_EXECUTOR
5+
from agents.matmaster_agent.ABACUS_agent.constant import (
6+
ABACUS_CALCULATOR_BOHRIUM_EXECUTOR,
7+
ABACUS_CALCULATOR_BOHRIUM_STORAGE,
8+
ABACUS_CALCULATOR_URL,
259
)
26-
2710
from agents.matmaster_agent.ABACUS_agent.prompt import (
28-
ABACUS_AGENT_NAME,
2911
ABACUS_AGENT_DESCRIPTION,
3012
ABACUS_AGENT_INSTRUCTION,
31-
ABACUS_SUBMIT_CORE_AGENT_NAME,
32-
ABACUS_SUBMIT_CORE_AGENT_DESCRIPTION,
33-
ABACUS_SUBMIT_CORE_AGENT_INSTRUCTION,
34-
ABACUS_SUBMIT_RENDER_AGENT_NAME,
35-
ABACUS_RESULT_CORE_AGENT_NAME,
36-
ABACUS_RESULT_CORE_AGENT_INSTRUCTION,
37-
ABACUS_RESULT_TRANSFER_AGENT_NAME,
38-
ABACUS_RESULT_TRANSFER_AGENT_INSTRUCTION,
39-
ABACUS_TRANSFER_AGENT_NAME,
40-
ABACUS_TRANSFER_AGENT_INSTRCUTION,
41-
ABACUS_SUBMIT_AGENT_NAME,
42-
ABACUS_SUBMIT_AGENT_DESCRIPTION,
43-
ABACUS_RESULT_AGENT_NAME,
44-
ABACUS_RESULT_AGENT_DESCRIPTION
45-
)
46-
47-
from agents.matmaster_agent.ABACUS_agent.constant import (
48-
ABACUS_CALCULATOR_URL,
49-
ABACUS_CALCULATOR_BOHRIUM_EXECUTOR,
50-
ABACUS_CALCULATOR_BOHRIUM_STORAGE,
13+
ABACUS_AGENT_NAME,
5114
)
15+
from agents.matmaster_agent.base_agents.job_agent import BaseAsyncJobAgent
16+
from agents.matmaster_agent.constant import MATMASTER_AGENT_NAME
17+
from agents.matmaster_agent.logger import matmodeler_logging_handler
5218

5319
mcp_tools_abacus = CalculationMCPToolset(
5420
connection_params=SseServerParams(
5521
url=ABACUS_CALCULATOR_URL,
56-
sse_read_timeout = 3600,
22+
sse_read_timeout=3600,
5723
),
58-
executor = ABACUS_CALCULATOR_BOHRIUM_EXECUTOR,
59-
storage = ABACUS_CALCULATOR_BOHRIUM_STORAGE,
24+
executor=ABACUS_CALCULATOR_BOHRIUM_EXECUTOR,
25+
storage=ABACUS_CALCULATOR_BOHRIUM_STORAGE,
6026
async_mode=True,
6127
wait=False,
62-
logging_callback=matmodeler_logging_handler
28+
logging_callback=matmodeler_logging_handler,
6329
)
6430

31+
6532
class ABACUSCalculatorAgent(BaseAsyncJobAgent):
6633
def __init__(self, llm_config):
6734
super().__init__(
@@ -72,11 +39,14 @@ def __init__(self, llm_config):
7239
agent_instruction=ABACUS_AGENT_INSTRUCTION,
7340
dflow_flag=False,
7441
supervisor_agent=MATMASTER_AGENT_NAME,
75-
sync_tools=['abacus_prepare',
76-
'abacus_modify_input',
77-
'abacus_modify_stru',
78-
'abacus_collect_data']
42+
sync_tools=[
43+
'abacus_prepare',
44+
'abacus_modify_input',
45+
'abacus_modify_stru',
46+
'abacus_collect_data',
47+
],
7948
)
8049

50+
8151
def init_abacus_calculation_agent(llm_config) -> BaseAgent:
8252
return ABACUSCalculatorAgent(llm_config)

agents/matmaster_agent/ABACUS_agent/constant.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
11
import copy
22

3-
from agents.matmaster_agent.constant import BohriumExecutor, BohriumStorge, LOCAL_EXECUTOR, CURRENT_ENV
3+
from agents.matmaster_agent.constant import (
4+
CURRENT_ENV,
5+
LOCAL_EXECUTOR,
6+
BohriumExecutor,
7+
BohriumStorge,
8+
)
49

510
if CURRENT_ENV in ['test', 'uat']:
611
ABACUS_CALCULATOR_URL = 'http://tfhs1357255.bohrium.tech:50001/sse'
712
else:
813
ABACUS_CALCULATOR_URL = 'https://abacus-agent-tools-uuid1751014104.app-space.dplink.cc/sse?token=7cae849e8a324f2892225e070443c45b'
914
ABACUS_AGENT_NAME = 'ABACUS_calculation_agent'
1015
ABACUS_CALCULATOR_BOHRIUM_EXECUTOR = copy.deepcopy(BohriumExecutor)
11-
ABACUS_CALCULATOR_BOHRIUM_EXECUTOR['machine']['remote_profile']['image_address'] = \
12-
'registry.dp.tech/dptech/dp/native/prod-22618/abacusagenttools:v0.2-openmp'
13-
ABACUS_CALCULATOR_BOHRIUM_EXECUTOR['machine']['remote_profile']['machine_type'] = 'c16_m32_cpu'
16+
ABACUS_CALCULATOR_BOHRIUM_EXECUTOR['machine']['remote_profile'][
17+
'image_address'
18+
] = 'registry.dp.tech/dptech/dp/native/prod-22618/abacusagenttools:v0.2-openmp'
19+
ABACUS_CALCULATOR_BOHRIUM_EXECUTOR['machine']['remote_profile'][
20+
'machine_type'
21+
] = 'c16_m32_cpu'
1422
ABACUS_CALCULATOR_BOHRIUM_STORAGE = copy.deepcopy(BohriumStorge)
1523

1624
EXECUTOR_MAP = {

agents/matmaster_agent/ABACUS_agent/prompt.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,9 @@
8585
"""
8686

8787

88-
89-
ABACUS_SUBMIT_CORE_AGENT_DESCRIPTION = """A specialized ABACUS calculation job submit agent"""
88+
ABACUS_SUBMIT_CORE_AGENT_DESCRIPTION = (
89+
"""A specialized ABACUS calculation job submit agent"""
90+
)
9091
ABACUS_SUBMIT_CORE_AGENT_INSTRUCTION = """
9192
You are an expert in materials science and chemistry.
9293
Help users prtfrom ABACUS calculation, including structure optimization, molecular dynamics, and various property calculations.
@@ -140,7 +141,9 @@
140141
"""
141142

142143

143-
ABACUS_RESULT_TRANSFER_AGENT_INSTRUCTION = """A specialized ABACUS calculation result transfer agent"""
144+
ABACUS_RESULT_TRANSFER_AGENT_INSTRUCTION = (
145+
"""A specialized ABACUS calculation result transfer agent"""
146+
)
144147

145148
ABACUS_RESULT_AGENT_DESCRIPTION = """Query status and get result"""
146149
ABACUS_RESULT_CORE_AGENT_INSTRUCTION = """

agents/matmaster_agent/DPACalculator_agent/agent.py

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,17 @@
22
from google.adk.agents import BaseAgent
33
from google.adk.tools.mcp_tool.mcp_session_manager import SseServerParams
44

5+
from agents.matmaster_agent.base_agents.job_agent import BaseAsyncJobAgent
6+
from agents.matmaster_agent.constant import MATMASTER_AGENT_NAME
57
from agents.matmaster_agent.DPACalculator_agent.constant import (
8+
DPACalulator_AGENT_NAME,
69
DPACalulator_BOHRIUM_EXECUTOR,
710
DPACalulator_BOHRIUM_STORAGE,
8-
DPACalulator_AGENT_NAME, DPAMCPServerUrl,
11+
DPAMCPServerUrl,
912
)
1013
from agents.matmaster_agent.DPACalculator_agent.prompt import (
1114
DPAAgentDescription,
1215
DPAAgentInstruction,
13-
DPAResultAgentDescription,
14-
DPAResultAgentName,
15-
DPAResultCoreAgentInstruction,
16-
DPAResultCoreAgentName,
17-
DPAResultTransferAgentInstruction,
18-
DPAResultTransferAgentName,
19-
DPASubmitAgentDescription,
20-
DPASubmitAgentName,
21-
DPASubmitCoreAgentDescription,
22-
DPASubmitCoreAgentInstruction,
23-
DPASubmitCoreAgentName,
24-
DPASubmitRenderAgentName,
25-
DPATransferAgentInstruction,
26-
DPATransferAgentName,
27-
)
28-
from agents.matmaster_agent.base_agents.job_agent import (
29-
BaseAsyncJobAgent,
30-
ResultCalculationMCPLlmAgent,
31-
SubmitCoreCalculationMCPLlmAgent,
32-
)
33-
from agents.matmaster_agent.constant import (
34-
MATMASTER_AGENT_NAME
3516
)
3617
from agents.matmaster_agent.logger import matmodeler_logging_handler
3718

@@ -41,7 +22,7 @@
4122
executor=DPACalulator_BOHRIUM_EXECUTOR,
4223
async_mode=True,
4324
wait=False,
44-
logging_callback=matmodeler_logging_handler
25+
logging_callback=matmodeler_logging_handler,
4526
)
4627

4728

@@ -54,7 +35,7 @@ def __init__(self, llm_config):
5435
agent_description=DPAAgentDescription,
5536
agent_instruction=DPAAgentInstruction,
5637
dflow_flag=False,
57-
supervisor_agent=MATMASTER_AGENT_NAME
38+
supervisor_agent=MATMASTER_AGENT_NAME,
5839
)
5940

6041

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
import copy
22

3-
from agents.matmaster_agent.constant import (
4-
CURRENT_ENV,
5-
BohriumExecutor,
6-
BohriumStorge,
7-
)
3+
from agents.matmaster_agent.constant import CURRENT_ENV, BohriumExecutor, BohriumStorge
84

95
DPACalulator_AGENT_NAME = 'dpa_calculator_agent'
106
if CURRENT_ENV in ['test', 'uat']:
117
DPAMCPServerUrl = 'http://pfmx1355864.bohrium.tech:50001/sse'
128
else:
139
DPAMCPServerUrl = 'https://dpa-uuid1750659890.app-space.dplink.cc/sse?token=7c2e8de61ec94f4e80ebcef1ac17c92e'
1410
DPACalulator_BOHRIUM_EXECUTOR = copy.deepcopy(BohriumExecutor)
15-
DPACalulator_BOHRIUM_EXECUTOR['machine']['remote_profile']['image_address'] = \
16-
'registry.dp.tech/dptech/dpa-calculator:a86b37cc'
11+
DPACalulator_BOHRIUM_EXECUTOR['machine']['remote_profile'][
12+
'image_address'
13+
] = 'registry.dp.tech/dptech/dpa-calculator:a86b37cc'
1714
DPACalulator_BOHRIUM_STORAGE = copy.deepcopy(BohriumStorge)

agents/matmaster_agent/DPACalculator_agent/prompt.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
description = ('An agent specialized in computational research using Deep Potential')
1+
description = 'An agent specialized in computational research using Deep Potential'
22

3-
instruction_en = ("""
3+
instruction_en = """
44
You are an intelligent assistant that can perform structure building and optimization,
55
molecular dynamics, NEB calculation, phonon calculation and elastic calculations.
6-
""")
6+
"""
77

88
# from agents.matmaster_agent.traj_analysis_agent.constant import TrajAnalysisAgentName
99
TrajAnalysisAgentName = 'traj_analysis_agent'
@@ -22,7 +22,9 @@
2222
DPATransferAgentName = 'dpa_transfer_agent'
2323

2424
# DPAAgent
25-
DPAAgentDescription = 'An agent specialized in computational research using Deep Potential'
25+
DPAAgentDescription = (
26+
'An agent specialized in computational research using Deep Potential'
27+
)
2628
DPAAgentInstruction = (
2729
'You are an expert in materials science and computational chemistry. '
2830
'Help users perform Deep Potential calculations including structure building, optimization, '
@@ -34,7 +36,9 @@
3436
)
3537

3638
# DPASubmitCoreAgent
37-
DPASubmitCoreAgentDescription = 'A specialized Deep Potential simulations Job Submit Agent'
39+
DPASubmitCoreAgentDescription = (
40+
'A specialized Deep Potential simulations Job Submit Agent'
41+
)
3842
DPASubmitCoreAgentInstruction = """
3943
You are an expert in materials science and computational chemistry.
4044
Help users perform Deep Potential calculations, including structure optimization, molecular dynamics, and property calculations.
@@ -73,7 +77,9 @@
7377
"""
7478

7579
# DPASubmitAgent
76-
DPASubmitAgentDescription = 'Coordinates DPA computational job submission and frontend task queue display'
80+
DPASubmitAgentDescription = (
81+
'Coordinates DPA computational job submission and frontend task queue display'
82+
)
7783
DPASubmitAgentInstruction = f"""
7884
You are a task coordination agent. You must strictly follow this workflow:
7985

0 commit comments

Comments
 (0)