Skip to content

Commit

Permalink
[pre-commit.ci] pre-commit autoupdate (#1171)
Browse files Browse the repository at this point in the history
<!--pre-commit.ci start-->
updates:
- [github.com/psf/black: 22.12.0 →
23.1.0](psf/black@22.12.0...23.1.0)
- [github.com/charliermarsh/ruff-pre-commit: v0.0.253 →
v0.0.259](astral-sh/ruff-pre-commit@v0.0.253...v0.0.259)
<!--pre-commit.ci end-->

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
pre-commit-ci[bot] authored Mar 29, 2023
1 parent 9ea063c commit 5342788
Show file tree
Hide file tree
Showing 23 changed files with 5 additions and 46 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ repos:
- id: check-toml
# Python
- repo: https://github.com/psf/black
rev: 22.12.0
rev: 23.1.0
hooks:
- id: black-jupyter
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.253
rev: v0.0.259
hooks:
- id: ruff
args: ["--fix"]
Expand Down
2 changes: 0 additions & 2 deletions dpgen/auto_test/Lammps.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ def __init__(self, inter_parameter, path_to_poscar):
self.set_inter_type_func()

def set_inter_type_func(self):

if self.inter_type == "deepmd":
self.inter_func = inter_deepmd

Expand All @@ -45,7 +44,6 @@ def set_inter_type_func(self):
self.inter_func = inter_eam_alloy

def set_model_param(self):

if self.inter_type == "deepmd":
model_name = os.path.basename(self.model)
deepmd_version = self.inter.get("deepmd_version", "1.2.0")
Expand Down
1 change: 0 additions & 1 deletion dpgen/auto_test/common_equi.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ def run_equi(confs, inter_param, mdata):
"API version %s has been removed. Please upgrade to 1.0." % api_version
)
elif Version(api_version) >= Version("1.0"):

submission = make_submission(
mdata_machine=machine,
mdata_resources=resources,
Expand Down
1 change: 0 additions & 1 deletion dpgen/auto_test/gen_confs.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ def gen_element_std(ele_name):


def gen_alloy(eles, key):

mpr = MPRester(key)

data = mpr.query(
Expand Down
2 changes: 0 additions & 2 deletions dpgen/auto_test/lib/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ def insert_data(task, task_type, username, file_name):


def make_work_path(jdata, task, reprod_opt, static, user):

task_type = jdata["task_type"]
conf_dir = jdata["conf_dir"]
conf_path = os.path.abspath(conf_dir)
Expand Down Expand Up @@ -94,7 +93,6 @@ def get_machine_info(mdata, task_type):


def collect_task(all_task, task_type):

if task_type == "vasp":
output_file = "OUTCAR"
check_finished = vasp.check_finished
Expand Down
2 changes: 0 additions & 2 deletions dpgen/data/surf.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@ def poscar_elong(poscar_in, poscar_out, elong, shift_center=True):


def make_unit_cell(jdata):

from_poscar = jdata.get("from_poscar", False)
if not from_poscar:
latt = jdata["latt"]
Expand All @@ -249,7 +248,6 @@ def make_unit_cell(jdata):


def make_super_cell_pymatgen(jdata):

make_unit_cell(jdata)
out_dir = jdata["out_dir"]
path_uc = os.path.join(out_dir, global_dirname_02)
Expand Down
3 changes: 1 addition & 2 deletions dpgen/database/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ def _main(param):


def parsing_vasp(path, config_info_dict, skip_init, output=OUTPUT, id_prefix=None):

fp_iters = os.path.join(path, ITERS_PAT)
dlog.debug(fp_iters)
f_fp_iters = glob(fp_iters)
Expand Down Expand Up @@ -114,7 +113,7 @@ def _parsing_vasp(paths, config_info_dict, id_prefix, iters=True):
iter_info = tmp_iter.split(".")[-1]
sys_info = path.split("/")[-4]
config_info_int = int(tmp_.split(".")[1])
for (key, value) in config_info_dict.items():
for key, value in config_info_dict.items():
if config_info_int in value:
config_info = key
attrib["config_info"] = config_info
Expand Down
1 change: 0 additions & 1 deletion dpgen/dispatcher/Dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ def make_submission(
outlog,
errlog,
):

if mdata_machine["local_root"] != "./":
raise RuntimeError(f"local_root must be './' in dpgen's machine.json.")

Expand Down
1 change: 0 additions & 1 deletion dpgen/generator/lib/calypso_check_outcar.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ def Write_Outcar(element, ele, volume, lat, pos, ene, force, stress, pstress):


def check():

from ase.io import read
from deepmd.calculator import DP

Expand Down
3 changes: 0 additions & 3 deletions dpgen/generator/lib/calypso_run_model_devi.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ def write_model_devi_out(devi, fname):


def Modd(all_models, type_map):

# Model Devi

cwd = os.getcwd()
Expand All @@ -44,7 +43,6 @@ def Modd(all_models, type_map):
pcount = 0
strus_lists = glob.glob(os.path.join(cwd, "*.structures"))
for num, strus_path in enumerate(strus_lists):

structures_data = dpdata.System(strus_path, "deepmd/npy", type_map=type_map)

# every 500 confs in one task dir
Expand Down Expand Up @@ -115,7 +113,6 @@ def Modd(all_models, type_map):


if __name__ == "__main__":

cwd = os.getcwd()
model_path = os.path.join(
os.path.abspath(os.path.join(cwd, os.pardir)), "gen_stru_analy"
Expand Down
1 change: 0 additions & 1 deletion dpgen/generator/lib/lammps.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ def get_all_dumped_forces(file_name):
exist_atoms = False

for idx, ii in enumerate(lines):

if "ITEM: NUMBER OF ATOMS" in ii:
natoms = int(lines[idx + 1])
exist_natoms = True
Expand Down
2 changes: 0 additions & 2 deletions dpgen/generator/lib/make_calypso.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ def make_calypso_input(


def _make_model_devi_buffet(jdata, calypso_run_opt_path):

calypso_input_path = jdata.get("calypso_input_path")
if jdata.get("vsc", False):
# [input.dat.Li.250, input.dat.Li.300]
Expand Down Expand Up @@ -164,7 +163,6 @@ def _make_model_devi_buffet(jdata, calypso_run_opt_path):


def _make_model_devi_native_calypso(iter_index, model_devi_jobs, calypso_run_opt_path):

for iiidx, jobbs in enumerate(model_devi_jobs):
if iter_index in jobbs.get("times"):
cur_job = model_devi_jobs[iiidx]
Expand Down
1 change: 0 additions & 1 deletion dpgen/generator/lib/parse_calypso.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


def _parse_calypso_input(var, input_path):

if os.path.basename(input_path) != "input.dat":
input_path = os.path.join(input_path, "input.dat")
if not os.path.exists(input_path):
Expand Down
3 changes: 0 additions & 3 deletions dpgen/generator/lib/run_calypso.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
def gen_structures(
iter_index, jdata, mdata, caly_run_path, current_idx, length_of_caly_runopt_list
):

# run calypso
# vsc means generate elemental, binary and ternary at the same time
vsc = jdata.get("vsc", False) # take CALYPSO as confs generator
Expand Down Expand Up @@ -343,7 +342,6 @@ def gen_structures(


def gen_main(iter_index, jdata, mdata, caly_run_opt_list, gen_idx):

iter_name = make_iter_name(iter_index)
work_path = os.path.join(iter_name, model_devi_name)

Expand Down Expand Up @@ -456,7 +454,6 @@ def analysis(iter_index, jdata, calypso_model_devi_path):


def run_calypso_model_devi(iter_index, jdata, mdata):

dlog.info("start running CALYPSO")

iter_name = make_iter_name(iter_index)
Expand Down
9 changes: 0 additions & 9 deletions dpgen/generator/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,6 @@ def run_train(iter_index, jdata, mdata):
if Version(mdata["deepmd_version"]) >= Version("1") and Version(
mdata["deepmd_version"]
) < Version("3"):

# 1.x
## Commands are like `dp train` and `dp freeze`
## train_command should not be None
Expand Down Expand Up @@ -1783,7 +1782,6 @@ def _make_model_devi_amber(


def run_md_model_devi(iter_index, jdata, mdata):

# rmdlog.info("This module has been run !")
model_devi_exec = mdata["model_devi_command"]

Expand Down Expand Up @@ -1842,7 +1840,6 @@ def run_md_model_devi(iter_index, jdata, mdata):
if use_plm_path:
forward_files += ["plmpath.pdb"]
elif model_devi_engine == "gromacs":

gromacs_settings = jdata.get("gromacs_settings", {})
mdp_filename = gromacs_settings.get("mdp_filename", "md.mdp")
topol_filename = gromacs_settings.get("topol_filename", "processed.top")
Expand Down Expand Up @@ -1956,7 +1953,6 @@ def run_md_model_devi(iter_index, jdata, mdata):


def run_model_devi(iter_index, jdata, mdata):

model_devi_engine = jdata.get("model_devi_engine", "lammps")
if model_devi_engine != "calypso":
run_md_model_devi(iter_index, jdata, mdata)
Expand Down Expand Up @@ -3851,7 +3847,6 @@ def run_fp(iter_index, jdata, mdata):


def post_fp_check_fail(iter_index, jdata, rfailed=None):

ratio_failed = rfailed if rfailed else jdata.get("ratio_failed", 0.05)
iter_name = make_iter_name(iter_index)
work_path = os.path.join(iter_name, fp_name)
Expand Down Expand Up @@ -3880,7 +3875,6 @@ def post_fp_check_fail(iter_index, jdata, rfailed=None):


def post_fp_vasp(iter_index, jdata, rfailed=None):

ratio_failed = rfailed if rfailed else jdata.get("ratio_failed", 0.05)
model_devi_engine = jdata.get("model_devi_engine", "lammps")
if model_devi_engine != "calypso":
Expand Down Expand Up @@ -4169,7 +4163,6 @@ def post_fp_gaussian(iter_index, jdata):


def post_fp_cp2k(iter_index, jdata, rfailed=None):

ratio_failed = rfailed if rfailed else jdata.get("ratio_failed", 0.10)
model_devi_jobs = jdata["model_devi_jobs"]
assert iter_index < len(model_devi_jobs)
Expand Down Expand Up @@ -4230,7 +4223,6 @@ def post_fp_cp2k(iter_index, jdata, rfailed=None):


def post_fp_pwmat(iter_index, jdata, rfailed=None):

ratio_failed = rfailed if rfailed else jdata.get("ratio_failed", 0.05)
model_devi_jobs = jdata["model_devi_jobs"]
assert iter_index < len(model_devi_jobs)
Expand Down Expand Up @@ -4355,7 +4347,6 @@ def post_fp(iter_index, jdata):


def set_version(mdata):

deepmd_version = "1"
mdata["deepmd_version"] = deepmd_version
return mdata
Expand Down
7 changes: 2 additions & 5 deletions dpgen/tools/auto_gen_param.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#%%
# %%
import argparse
import json
import os
Expand Down Expand Up @@ -212,7 +212,6 @@ def get_model_devi_jobs(
temps_intervel=0.1,
num_temps=5,
):

if temps_iterator is None:
temps_iterator = default_temps_generator(
melt_point=melt_point, temps_intervel=temps_intervel, num_temps=num_temps
Expand Down Expand Up @@ -243,7 +242,6 @@ def get_sys_configs(system_list):


def get_init_data_sys(scan_dir="./", init_file_name="type.raw"):

init_data_sys = []
for t in os.walk(scan_dir):
if init_file_name in t[2]:
Expand Down Expand Up @@ -272,7 +270,6 @@ def get_basic_param_json(
temps_intervel=0.1,
num_temps=5,
):

init_data_sys = get_init_data_sys(scan_dir=scan_dir, init_file_name=init_file_name)
print(f"length of init_data_sys: {len(init_data_sys)} {init_data_sys}")
system_dict = scan_files(scan_dir, file_name, min_allow_files_num)
Expand Down Expand Up @@ -336,4 +333,4 @@ def auto_gen_param(args):
raise RuntimeError("must provide melt point or PARAM")


#%%
# %%
1 change: 0 additions & 1 deletion tests/auto_test/test_elastic.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ def test_task_param(self):
self.assertEqual(self.prop_param[0], self.elastic.task_param())

def test_make_confs(self):

shutil.copy(
os.path.join(self.source_path, "Al-fcc.json"),
os.path.join(self.equi_path, "result.json"),
Expand Down
1 change: 0 additions & 1 deletion tests/auto_test/test_eos.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ def test_task_param(self):
self.assertEqual(self.prop_param[0], self.eos.task_param())

def test_make_confs_0(self):

if not os.path.exists(os.path.join(self.equi_path, "CONTCAR")):
with self.assertRaises(RuntimeError):
self.eos.make_confs(self.target_path, self.equi_path)
Expand Down
1 change: 0 additions & 1 deletion tests/auto_test/test_refine.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ def tearDown(self):
shutil.rmtree("confs/std-fcc/relaxation")

def test_make_eos(self):

pwd = os.getcwd()
confs = self.jdata["structures"]
inter_param = self.jdata["interaction"]
Expand Down
1 change: 0 additions & 1 deletion tests/data/test_coll_abacus.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ def tearDown(self):
shutil.rmtree(self.odir)

def test_coll(self):

with open(abacus_param_file, "r") as fp:
jdata = json.load(fp)
jdata["out_dir"] = self.odir
Expand Down
1 change: 0 additions & 1 deletion tests/data/test_coll_vasp.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ def tearDown(self):
shutil.rmtree(self.odir)

def test_coll(self):

with open(param_file, "r") as fp:
jdata = json.load(fp)
jdata["out_dir"] = self.odir
Expand Down
1 change: 0 additions & 1 deletion tests/database/test_db_vasp.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ def setUp(self):
self.output = jdata["output"]

def testDPPotcar(self):

refd = {
"@module": "dpgen.database.vasp",
"@class": "DPPotcar",
Expand Down
2 changes: 0 additions & 2 deletions tests/generator/test_post_fp.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ def tearDown(self):
shutil.rmtree("iter.000000")

def test_post_fp_vasp_0(self):

with open(param_file, "r") as fp:
jdata = json.load(fp)
jdata["use_ele_temp"] = 2
Expand Down Expand Up @@ -127,7 +126,6 @@ def test_post_fp_vasp_0(self):
self.assertEqual(list(list(aparam)[1]), [1, 1])

def test_post_fp_vasp_1(self):

with open(param_file, "r") as fp:
jdata = json.load(fp)
jdata["use_ele_temp"] = 1
Expand Down

0 comments on commit 5342788

Please sign in to comment.