From 71f291832fd0246f9a090833cb2dc4b521d4cde2 Mon Sep 17 00:00:00 2001 From: Jinzhe Zeng Date: Tue, 19 Dec 2023 01:56:08 -0500 Subject: [PATCH] move to ruff formatter (#181) See https://astral.sh/blog/the-ruff-formatter. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 7 ++++--- dpgen2/entrypoint/submit.py | 1 - dpgen2/exploration/deviation/deviation_manager.py | 1 + dpgen2/exploration/task/lmp_template_task_group.py | 5 ++++- dpgen2/exploration/task/npt_task_group.py | 5 ++++- tests/op/test_prep_dp_train.py | 3 --- 6 files changed, 13 insertions(+), 9 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f016f4b6..a96c7d1d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,10 +15,11 @@ repos: - id: check-symlinks - id: check-toml # Python -- repo: https://github.com/psf/black - rev: 22.12.0 +- repo: https://github.com/astral-sh/ruff-pre-commit + # Ruff version. + rev: v0.1.3 hooks: - - id: black-jupyter + - id: ruff-format - repo: https://github.com/PyCQA/isort rev: 5.12.0 hooks: diff --git a/dpgen2/entrypoint/submit.py b/dpgen2/entrypoint/submit.py index 997c76bc..8b2b2a63 100644 --- a/dpgen2/entrypoint/submit.py +++ b/dpgen2/entrypoint/submit.py @@ -457,7 +457,6 @@ def workflow_concurrent_learning( ) if config["inputs"].get("do_finetune", False): - finetune_step = make_finetune_step( config, prep_train_config, diff --git a/dpgen2/exploration/deviation/deviation_manager.py b/dpgen2/exploration/deviation/deviation_manager.py index b16f91e5..cbc227c5 100644 --- a/dpgen2/exploration/deviation/deviation_manager.py +++ b/dpgen2/exploration/deviation/deviation_manager.py @@ -12,6 +12,7 @@ class DeviManager(ABC): r"""A class for model deviation management.""" + MAX_DEVI_V = "max_devi_v" MIN_DEVI_V = "min_devi_v" AVG_DEVI_V = "avg_devi_v" diff --git a/dpgen2/exploration/task/lmp_template_task_group.py b/dpgen2/exploration/task/lmp_template_task_group.py index 7aba601d..2c1aefda 100644 --- a/dpgen2/exploration/task/lmp_template_task_group.py +++ b/dpgen2/exploration/task/lmp_template_task_group.py @@ -110,7 +110,10 @@ def _make_lmp_task( plm_cont: Optional[str] = None, ) -> ExplorationTask: task = ExplorationTask() - task.add_file(lmp_conf_name, conf,).add_file( + task.add_file( + lmp_conf_name, + conf, + ).add_file( lmp_input_name, lmp_cont, ) diff --git a/dpgen2/exploration/task/npt_task_group.py b/dpgen2/exploration/task/npt_task_group.py index d16ebaea..e90ee5e8 100644 --- a/dpgen2/exploration/task/npt_task_group.py +++ b/dpgen2/exploration/task/npt_task_group.py @@ -106,7 +106,10 @@ def _make_lmp_task( pp: Optional[float], ) -> ExplorationTask: task = ExplorationTask() - task.add_file(lmp_conf_name, conf,).add_file( + task.add_file( + lmp_conf_name, + conf, + ).add_file( lmp_input_name, make_lmp_input( lmp_conf_name, diff --git a/tests/op/test_prep_dp_train.py b/tests/op/test_prep_dp_train.py index acd0371d..a41f6415 100644 --- a/tests/op/test_prep_dp_train.py +++ b/tests/op/test_prep_dp_train.py @@ -111,7 +111,6 @@ def test_template_str_hybrid(self): self.assertEqual(jdata["training"]["seed"], 4 * ii + 3) def test_template_str_se_e2_a(self): - ip = OPIO( { "template_script": template_script_se_e2_a, @@ -133,7 +132,6 @@ def test_template_str_se_e2_a(self): self.assertEqual(jdata["training"]["seed"], 3 * ii + 2) def test_template_list_hyb_sea(self): - ip = OPIO( { "template_script": [template_script_hybrid, template_script_se_e2_a], @@ -166,7 +164,6 @@ def test_template_list_hyb_sea(self): self.assertEqual(jdata["training"]["seed"], 4 * ii + 2) def test_template_raise_wrong_list_length(self): - ip = OPIO( { "template_script": [