hpc-task 0.0.1__tar.gz → 0.0.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {hpc_task-0.0.1 → hpc_task-0.0.2}/PKG-INFO +1 -1
- {hpc_task-0.0.1 → hpc_task-0.0.2}/hpc_task.egg-info/PKG-INFO +1 -1
- {hpc_task-0.0.1 → hpc_task-0.0.2}/setup.py +1 -1
- {hpc_task-0.0.1 → hpc_task-0.0.2}/tests/test_task.py +60 -7
- {hpc_task-0.0.1 → hpc_task-0.0.2}/LICENSE +0 -0
- {hpc_task-0.0.1 → hpc_task-0.0.2}/README.md +0 -0
- {hpc_task-0.0.1 → hpc_task-0.0.2}/hpc_task/__init__.py +0 -0
- {hpc_task-0.0.1 → hpc_task-0.0.2}/hpc_task/hpc.py +0 -0
- {hpc_task-0.0.1 → hpc_task-0.0.2}/hpc_task.egg-info/SOURCES.txt +0 -0
- {hpc_task-0.0.1 → hpc_task-0.0.2}/hpc_task.egg-info/dependency_links.txt +0 -0
- {hpc_task-0.0.1 → hpc_task-0.0.2}/hpc_task.egg-info/requires.txt +0 -0
- {hpc_task-0.0.1 → hpc_task-0.0.2}/hpc_task.egg-info/top_level.txt +0 -0
- {hpc_task-0.0.1 → hpc_task-0.0.2}/setup.cfg +0 -0
|
@@ -4,13 +4,17 @@ import pytest
|
|
|
4
4
|
import ase
|
|
5
5
|
from ase.calculators.vasp import Vasp
|
|
6
6
|
from hpc_task.hpc import HPCTask
|
|
7
|
+
from hpc_task.templates.vasp import vasp_template
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
if os.getenv("JUMP_HOST_IP"):
|
|
10
|
+
jump_host = {
|
|
11
|
+
'hostname': os.getenv("JUMP_HOST_IP"),
|
|
12
|
+
'port': int(os.getenv("JUMP_HOST_PORT")),
|
|
13
|
+
'username': os.getenv("JUMP_HOST_USER"),
|
|
14
|
+
'password': os.getenv("JUMP_HOST_PASS"), # 建议使用密钥认证而非密码
|
|
15
|
+
}
|
|
16
|
+
else:
|
|
17
|
+
jump_host = None
|
|
14
18
|
|
|
15
19
|
target_host = {
|
|
16
20
|
'hostname': os.getenv("TARGET_HOST_IP"),
|
|
@@ -67,8 +71,9 @@ class TestHPCTask:
|
|
|
67
71
|
def test_vasp_calc(self):
|
|
68
72
|
atoms = ase.Atoms('N2', positions=[(0.,0.,0.),(1.4,0.,0.)],cell=[10,10,10], pbc=True)
|
|
69
73
|
workdir = 'test_vasp_calc'
|
|
74
|
+
|
|
70
75
|
curdir = os.path.abspath('.')
|
|
71
|
-
python_command = [ # TODO: 写成一个python 的 template
|
|
76
|
+
python_command = [ # TODO: 写成一个python 的 template,每一个calc 一个模板
|
|
72
77
|
"from hpc_task.hpc import HPCTask",
|
|
73
78
|
"import os",
|
|
74
79
|
f"os.chdir('{curdir}')",
|
|
@@ -92,3 +97,51 @@ class TestHPCTask:
|
|
|
92
97
|
atoms.calc = calc
|
|
93
98
|
e = atoms.get_potential_energy()
|
|
94
99
|
print(f"Energy of N2 is {e} eV.")
|
|
100
|
+
|
|
101
|
+
def test_gosh_remote(self):
|
|
102
|
+
# TODO: 服务器的参数需要读取并设置在 mpi 中
|
|
103
|
+
|
|
104
|
+
atoms = ase.Atoms('N2', positions=[(0., 0., 0.), (1.4, 0., 0.)], cell=[10, 10, 10], pbc=True)
|
|
105
|
+
workdir = 'test_vasp_calc'
|
|
106
|
+
|
|
107
|
+
curdir = os.path.abspath('.')
|
|
108
|
+
# 占据节点
|
|
109
|
+
hpc = HPCTask(workdir=workdir)
|
|
110
|
+
hpc.connect(target_host, jump_host)
|
|
111
|
+
stdin, stdout, stderr = hpc.prerun()
|
|
112
|
+
stdin, stdout, stderr = hpc.ssh_client.exec_command('hostname')
|
|
113
|
+
hostname = stdout.read().decode().strip()
|
|
114
|
+
print(hpc.jobid)
|
|
115
|
+
print(f"Job {hpc.jobid} status: {hpc.status}")
|
|
116
|
+
|
|
117
|
+
dct = {
|
|
118
|
+
'curdir': curdir,
|
|
119
|
+
'workdir': workdir,
|
|
120
|
+
'target_host': target_host,
|
|
121
|
+
'jump_host': jump_host,
|
|
122
|
+
'hostname': hostname,
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
python_command = vasp_template.substitute(dct)
|
|
126
|
+
os.makedirs(workdir, exist_ok=True)
|
|
127
|
+
with open(os.path.join(workdir,'calc_command.py'), 'w') as f:
|
|
128
|
+
f.write(python_command)
|
|
129
|
+
|
|
130
|
+
calc_command = f'python calc_command.py'
|
|
131
|
+
calc = Vasp(
|
|
132
|
+
command=calc_command,
|
|
133
|
+
directory=workdir,
|
|
134
|
+
xc='pbe',
|
|
135
|
+
gamma=True,
|
|
136
|
+
encut=400,
|
|
137
|
+
lwave=False,
|
|
138
|
+
lcharg=False,
|
|
139
|
+
)
|
|
140
|
+
atoms.calc = calc
|
|
141
|
+
e = atoms.get_potential_energy()
|
|
142
|
+
print(f"Energy of N2 is {e} eV.")
|
|
143
|
+
|
|
144
|
+
# 释放节点
|
|
145
|
+
stdin, stdout, stderr = hpc.postrun()
|
|
146
|
+
print(f"Job {hpc.jobid} status: {hpc.status}")
|
|
147
|
+
hpc.close()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|