-
Notifications
You must be signed in to change notification settings - Fork 2
/
generator.py
221 lines (206 loc) · 5.15 KB
/
generator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
import json
from pathlib import Path
import deepmd
import dpgen
import dpgen2
import dpdispatcher
from deepmd.utils.argcheck import (
gen_args as deepmd_arginfo,
gen_args_multi_task as deepmd_multi_task_arginfo,
)
from dpgen.generator.arginfo import run_jdata_arginfo, run_mdata_arginfo
from dpgen.simplify.arginfo import simplify_jdata_arginfo, simplify_mdata_arginfo
from dpgen.data.arginfo import (
init_bulk_jdata_arginfo,
init_bulk_mdata_arginfo,
init_surf_jdata_arginfo,
init_surf_mdata_arginfo,
init_reaction_jdata_arginfo,
init_reaction_mdata_arginfo,
)
from dpdispatcher import Resources, Task, Machine
from dpgen2.entrypoint.args import submit_args
from dargs import ArgumentEncoder, Argument
args_path = Path(__file__).parent / "args"
args_path.mkdir(exist_ok=True)
args = {}
def jsdelivr_url(repo, version, file):
return "https://fastly.jsdelivr.net/gh/{}@{}/{}".format(repo, version, file)
def add_parameter(key : str, name: str, argument: Argument, version: str,
repo: str, examples: list = None) -> dict:
fn = key + ".json"
with open(args_path / fn, 'w') as f:
json.dump(argument, f, cls=ArgumentEncoder)
arg = {}
arg["name"] = "{} v{}".format(name, version)
arg["fn"] = fn
if examples is not None:
arg_examples = []
for example in examples:
arg_examples.append(
{
"name": example["name"],
"url": jsdelivr_url(repo, version, example["file"])
}
)
arg['examples']= arg_examples
args[key] = arg
# deepmd-kit
add_parameter(
"deepmd-kit-2.0",
"DeePMD-kit",
deepmd_arginfo(),
deepmd.__version__,
"deepmodeling/deepmd-kit",
[
{
"name": "Water se_e2_a",
"file": "examples/water/se_e2_a/input.json"
},
{
"name": "Water se_e2_r",
"file": "examples/water/se_e2_r/input.json"
},
{
"name": "Water se_e2_a_tebd",
"file": "examples/water/se_e2_a_tebd/input.json"
},
{
"name": "Water se_e3",
"file": "examples/water/se_e3/input.json"
},
{
"name": "Water hybrid",
"file": "examples/water/hybrid/input.json"
},
{
"name": "Water tensor polar",
"file": "examples/water_tensor/polar/polar_input.json"
},
{
"name": "Water tensor dipole",
"file": "examples/water_tensor/dipole/dipole_input.json"
},
{
"name": "Frame parameter",
"file": "examples/fparam/train/input.json"
},
{
"name": "Atomic parameter",
"file": "examples/fparam/train/input_aparam.json"
}
],
)
add_parameter(
"deepmd-kit-multi-task",
"DeePMD-kit",
deepmd_multi_task_arginfo(),
deepmd.__version__,
"deepmodeling/deepmd-kit",
)
# dpgen
add_parameter(
"dpgen-run",
"DP-GEN Run",
run_jdata_arginfo(),
dpgen.__version__,
"deepmodeling/dpgen",
)
add_parameter(
"dpgen-machine",
"DP-GEN Run Machine",
run_mdata_arginfo(),
dpgen.__version__,
"deepmodeling/dpgen",
)
add_parameter(
"dpgen-simplify",
"DP-GEN Simplify",
simplify_jdata_arginfo(),
dpgen.__version__,
"deepmodeling/dpgen",
)
add_parameter(
"dpgen-simplify-machine",
"DP-GEN Simplify Machine",
simplify_mdata_arginfo(),
dpgen.__version__,
"deepmodeling/dpgen",
)
add_parameter(
"dpgen-init-bulk",
"DP-GEN init_bulk",
init_bulk_jdata_arginfo(),
dpgen.__version__,
"deepmodeling/dpgen",
)
add_parameter(
"dpgen-init-bulk-machine",
"DP-GEN init_bulk Machine",
init_bulk_mdata_arginfo(),
dpgen.__version__,
"deepmodeling/dpgen",
)
add_parameter(
"dpgen-init-surf",
"DP-GEN init_surf",
init_surf_jdata_arginfo(),
dpgen.__version__,
"deepmodeling/dpgen",
)
add_parameter(
"dpgen-init-surf-machine",
"DP-GEN init_surf",
init_surf_mdata_arginfo(),
dpgen.__version__,
"deepmodeling/dpgen",
)
add_parameter(
"dpgen-init-reaction",
"DP-GEN init_reaction",
init_reaction_jdata_arginfo(),
dpgen.__version__,
"deepmodeling/dpgen",
)
add_parameter(
"dpgen-init-reaction-machine",
"DP-GEN init_reaction Machine",
init_reaction_mdata_arginfo(),
dpgen.__version__,
"deepmodeling/dpgen",
)
# dpdispatcher
add_parameter(
"dpdispatcher-machine",
"DPDispatcher Machine",
Machine.arginfo(),
dpdispatcher.__version__,
"deepmodeling/dpdispatcher",
)
add_parameter(
"dpdispatcher-resources",
"DPDispatcher Resources",
Resources.arginfo(),
dpdispatcher.__version__,
"deepmodeling/dpdispatcher",
)
add_parameter(
"dpdispatcher-task",
"DPDispatcher Task",
Task.arginfo(),
dpdispatcher.__version__,
"deepmodeling/dpdispatcher",
)
# DPGEN2
add_parameter(
"dpgen2-submit",
"DP-GEN2 Submit",
submit_args(),
dpgen2.__version__,
"deepmodeling/dpgen2",
)
# args.json
with open(args_path / "args.json", 'w') as f:
json.dump(args, f)
# list generated files
print(*args_path.iterdir())