From 53427889958b10918aed8972a3af27167ad8f0be Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 29 Mar 2023 09:10:36 +0800 Subject: [PATCH] [pre-commit.ci] pre-commit autoupdate (#1171) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/psf/black: 22.12.0 → 23.1.0](https://github.com/psf/black/compare/22.12.0...23.1.0) - [github.com/charliermarsh/ruff-pre-commit: v0.0.253 → v0.0.259](https://github.com/charliermarsh/ruff-pre-commit/compare/v0.0.253...v0.0.259) --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 4 ++-- dpgen/auto_test/Lammps.py | 2 -- dpgen/auto_test/common_equi.py | 1 - dpgen/auto_test/gen_confs.py | 1 - dpgen/auto_test/lib/util.py | 2 -- dpgen/data/surf.py | 2 -- dpgen/database/run.py | 3 +-- dpgen/dispatcher/Dispatcher.py | 1 - dpgen/generator/lib/calypso_check_outcar.py | 1 - dpgen/generator/lib/calypso_run_model_devi.py | 3 --- dpgen/generator/lib/lammps.py | 1 - dpgen/generator/lib/make_calypso.py | 2 -- dpgen/generator/lib/parse_calypso.py | 1 - dpgen/generator/lib/run_calypso.py | 3 --- dpgen/generator/run.py | 9 --------- dpgen/tools/auto_gen_param.py | 7 ++----- tests/auto_test/test_elastic.py | 1 - tests/auto_test/test_eos.py | 1 - tests/auto_test/test_refine.py | 1 - tests/data/test_coll_abacus.py | 1 - tests/data/test_coll_vasp.py | 1 - tests/database/test_db_vasp.py | 1 - tests/generator/test_post_fp.py | 2 -- 23 files changed, 5 insertions(+), 46 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b5ce6e9c2..1c91cd6cb 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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"] diff --git a/dpgen/auto_test/Lammps.py b/dpgen/auto_test/Lammps.py index 1a3693807..0cd46b245 100644 --- a/dpgen/auto_test/Lammps.py +++ b/dpgen/auto_test/Lammps.py @@ -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 @@ -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") diff --git a/dpgen/auto_test/common_equi.py b/dpgen/auto_test/common_equi.py index 2c0bfbf8e..61f3eb115 100644 --- a/dpgen/auto_test/common_equi.py +++ b/dpgen/auto_test/common_equi.py @@ -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, diff --git a/dpgen/auto_test/gen_confs.py b/dpgen/auto_test/gen_confs.py index 29cc02ba8..9a17173e6 100755 --- a/dpgen/auto_test/gen_confs.py +++ b/dpgen/auto_test/gen_confs.py @@ -93,7 +93,6 @@ def gen_element_std(ele_name): def gen_alloy(eles, key): - mpr = MPRester(key) data = mpr.query( diff --git a/dpgen/auto_test/lib/util.py b/dpgen/auto_test/lib/util.py index 62d5285a0..76005bdbc 100644 --- a/dpgen/auto_test/lib/util.py +++ b/dpgen/auto_test/lib/util.py @@ -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) @@ -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 diff --git a/dpgen/data/surf.py b/dpgen/data/surf.py index da1042bba..88ef0fc83 100644 --- a/dpgen/data/surf.py +++ b/dpgen/data/surf.py @@ -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"] @@ -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) diff --git a/dpgen/database/run.py b/dpgen/database/run.py index 722028b10..8a2df327d 100644 --- a/dpgen/database/run.py +++ b/dpgen/database/run.py @@ -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) @@ -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 diff --git a/dpgen/dispatcher/Dispatcher.py b/dpgen/dispatcher/Dispatcher.py index c15c1f498..0d9e43f16 100644 --- a/dpgen/dispatcher/Dispatcher.py +++ b/dpgen/dispatcher/Dispatcher.py @@ -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.") diff --git a/dpgen/generator/lib/calypso_check_outcar.py b/dpgen/generator/lib/calypso_check_outcar.py index 148e3a5af..e3982335e 100644 --- a/dpgen/generator/lib/calypso_check_outcar.py +++ b/dpgen/generator/lib/calypso_check_outcar.py @@ -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 diff --git a/dpgen/generator/lib/calypso_run_model_devi.py b/dpgen/generator/lib/calypso_run_model_devi.py index f3ed62a36..1f656cc59 100644 --- a/dpgen/generator/lib/calypso_run_model_devi.py +++ b/dpgen/generator/lib/calypso_run_model_devi.py @@ -34,7 +34,6 @@ def write_model_devi_out(devi, fname): def Modd(all_models, type_map): - # Model Devi cwd = os.getcwd() @@ -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 @@ -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" diff --git a/dpgen/generator/lib/lammps.py b/dpgen/generator/lib/lammps.py index e03ed7def..bd32fd562 100644 --- a/dpgen/generator/lib/lammps.py +++ b/dpgen/generator/lib/lammps.py @@ -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 diff --git a/dpgen/generator/lib/make_calypso.py b/dpgen/generator/lib/make_calypso.py index 00c1412de..2758d76df 100644 --- a/dpgen/generator/lib/make_calypso.py +++ b/dpgen/generator/lib/make_calypso.py @@ -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] @@ -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] diff --git a/dpgen/generator/lib/parse_calypso.py b/dpgen/generator/lib/parse_calypso.py index 7bd3d7d50..81b2147c2 100644 --- a/dpgen/generator/lib/parse_calypso.py +++ b/dpgen/generator/lib/parse_calypso.py @@ -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): diff --git a/dpgen/generator/lib/run_calypso.py b/dpgen/generator/lib/run_calypso.py index 289f63266..1f78ffa97 100644 --- a/dpgen/generator/lib/run_calypso.py +++ b/dpgen/generator/lib/run_calypso.py @@ -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 @@ -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) @@ -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) diff --git a/dpgen/generator/run.py b/dpgen/generator/run.py index 9984d058e..ec5991fc9 100644 --- a/dpgen/generator/run.py +++ b/dpgen/generator/run.py @@ -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 @@ -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"] @@ -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") @@ -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) @@ -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) @@ -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": @@ -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) @@ -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) @@ -4355,7 +4347,6 @@ def post_fp(iter_index, jdata): def set_version(mdata): - deepmd_version = "1" mdata["deepmd_version"] = deepmd_version return mdata diff --git a/dpgen/tools/auto_gen_param.py b/dpgen/tools/auto_gen_param.py index 9b6340b20..df5793be3 100755 --- a/dpgen/tools/auto_gen_param.py +++ b/dpgen/tools/auto_gen_param.py @@ -1,4 +1,4 @@ -#%% +# %% import argparse import json import os @@ -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 @@ -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]: @@ -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) @@ -336,4 +333,4 @@ def auto_gen_param(args): raise RuntimeError("must provide melt point or PARAM") -#%% +# %% diff --git a/tests/auto_test/test_elastic.py b/tests/auto_test/test_elastic.py index c611a4f8a..0a4b83725 100644 --- a/tests/auto_test/test_elastic.py +++ b/tests/auto_test/test_elastic.py @@ -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"), diff --git a/tests/auto_test/test_eos.py b/tests/auto_test/test_eos.py index 6c5f90ad1..de68fae95 100644 --- a/tests/auto_test/test_eos.py +++ b/tests/auto_test/test_eos.py @@ -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) diff --git a/tests/auto_test/test_refine.py b/tests/auto_test/test_refine.py index b380ead2d..279d43e90 100644 --- a/tests/auto_test/test_refine.py +++ b/tests/auto_test/test_refine.py @@ -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"] diff --git a/tests/data/test_coll_abacus.py b/tests/data/test_coll_abacus.py index c5f11f526..e6e1fd564 100644 --- a/tests/data/test_coll_abacus.py +++ b/tests/data/test_coll_abacus.py @@ -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 diff --git a/tests/data/test_coll_vasp.py b/tests/data/test_coll_vasp.py index e5b282698..75afc41d1 100644 --- a/tests/data/test_coll_vasp.py +++ b/tests/data/test_coll_vasp.py @@ -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 diff --git a/tests/database/test_db_vasp.py b/tests/database/test_db_vasp.py index 17fe7f0fd..73b8f8ad9 100644 --- a/tests/database/test_db_vasp.py +++ b/tests/database/test_db_vasp.py @@ -51,7 +51,6 @@ def setUp(self): self.output = jdata["output"] def testDPPotcar(self): - refd = { "@module": "dpgen.database.vasp", "@class": "DPPotcar", diff --git a/tests/generator/test_post_fp.py b/tests/generator/test_post_fp.py index 132819964..04cdf1132 100644 --- a/tests/generator/test_post_fp.py +++ b/tests/generator/test_post_fp.py @@ -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 @@ -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