Skip to content

Commit 57a8c16

Browse files
authored
add and run pre-commit to format codes (#1124)
- add pre-commit config, including black and common fixes. - run pre-commit. - manually fix a YAML file. - skip check json and broken symlinks.
1 parent fb8668b commit 57a8c16

File tree

266 files changed

+17215
-12279
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

266 files changed

+17215
-12279
lines changed

.github/ISSUE_TEMPLATE/request-for-help.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Before asking questions, you can
1313
search the previous issues or discussions
1414
check [Manual](https://github.com/deepmodeling/dpgen).
1515

16-
Please **do not** post requests for help (e.g. with installing or using dpgen) here.
16+
Please **do not** post requests for help (e.g. with installing or using dpgen) here.
1717
Instead go to [discussions](https://github.com/deepmodeling/dpgen/discussions).
1818

1919
This issue tracker is for tracking dpgen development related issues only.

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,3 @@ dbconfig.json
4242
_build
4343
tests/generator/calypso_test_path
4444
doc/api/
45-

.pre-commit-config.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# See https://pre-commit.com for more information
2+
# See https://pre-commit.com/hooks.html for more hooks
3+
repos:
4+
- repo: https://github.com/pre-commit/pre-commit-hooks
5+
rev: v4.4.0
6+
hooks:
7+
# there are many log files in tests
8+
# TODO: seperate py files and log files
9+
- id: trailing-whitespace
10+
exclude: "^tests/.*$"
11+
- id: end-of-file-fixer
12+
exclude: "^tests/.*$"
13+
- id: check-yaml
14+
exclude: "^conda/.*$"
15+
#- id: check-json
16+
- id: check-added-large-files
17+
- id: check-merge-conflict
18+
- id: check-symlinks
19+
exclude: "^tests/tools/run_report_test_output/.*$"
20+
- id: check-toml
21+
# Python
22+
- repo: https://github.com/psf/black
23+
rev: 22.12.0
24+
hooks:
25+
- id: black-jupyter
26+
ci:
27+
autoupdate_branch: devel

conda/conda_build_config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
channel_sources:
1+
channel_sources:
22
- defaults
33
- conda-forge
4-
channel_targets:
4+
channel_targets:
55
- deepmodeling

conda/construct.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ channels:
1111
specs:
1212
- python 3.8
1313
- pip
14-
- dpgen {{ version }}
14+
- dpgen {{ version }}
1515

1616
ignore_duplicate_files: True
1717

doc/autotest/Auto-test.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ where the key `structures` provides the structures to relax. `interaction` is pr
3030
### Task type
3131
There are now six task types implemented in the package: `vasp`, `abacus`, `deepmd`, `meam`, `eam_fs`, and `eam_alloy`. An `inter.json` file in json format containing the interaction parameters will be written in the directory of each task after `make`. We give input examples of the `interaction` part for each type below:
3232

33-
**VASP**:
34-
33+
**VASP**:
34+
3535
The default of `potcar_prefix` is "".
3636
```json
3737
"interaction": {
@@ -41,8 +41,8 @@ The default of `potcar_prefix` is "".
4141
"potcars": {"Al": "POTCAR.al", "Mg": "POTCAR.mg"}
4242
}
4343
```
44-
**ABACUS**:
45-
44+
**ABACUS**:
45+
4646
The default of `potcar_prefix` is "". The path of potcars/orb_files/deepks_desc is `potcar_prefix` + `potcars`/`orb_files`/`deepks_desc`.
4747
```json
4848
"interaction": {
@@ -62,7 +62,7 @@ The default of `potcar_prefix` is "". The path of potcars/orb_files/deepks_desc
6262
```json
6363
"interaction": {
6464
"type": "deepmd",
65-
"model": "frozen_model.pb",
65+
"model": "frozen_model.pb",
6666
"type_map": {"Al": 0, "Mg": 1}
6767
}
6868
```
@@ -81,8 +81,8 @@ Please make sure the [USER-MEAMC package](https://lammps.sandia.gov/doc/Packages
8181
Please make sure the [MANYBODY package](https://lammps.sandia.gov/doc/Packages_details.html#pkg-manybody) has already been installed in LAMMPS
8282
```json
8383
"interaction": {
84-
"type": "eam_fs (eam_alloy)",
85-
"model": "AlMg.eam.fs (AlMg.eam.alloy)",
84+
"type": "eam_fs (eam_alloy)",
85+
"model": "AlMg.eam.fs (AlMg.eam.alloy)",
8686
"type_map": {"Al": 1, "Mg": 2}
8787
}
8888
```
@@ -96,9 +96,9 @@ Now the supported property types are `eos`, `elastic`, `vacancy`, `interstitial`
9696
There are three operations in auto test package, namely `make`, `run`, and `post`. Here we take `eos` property as an example for property type.
9797

9898
### Make
99-
The `INCAR`, `POSCAR`, `POTCAR` input files for VASP or `in.lammps`, `conf.lmp`, and the interatomic potential files for LAMMPS will be generated in the directory `confs/mp-*/relaxation/relax_task` for relaxation or `confs/mp-*/eos_00/task.[0-9]*[0-9]` for EOS. The `machine.json` file is not needed for `make`. Example:
99+
The `INCAR`, `POSCAR`, `POTCAR` input files for VASP or `in.lammps`, `conf.lmp`, and the interatomic potential files for LAMMPS will be generated in the directory `confs/mp-*/relaxation/relax_task` for relaxation or `confs/mp-*/eos_00/task.[0-9]*[0-9]` for EOS. The `machine.json` file is not needed for `make`. Example:
100100
```bash
101-
dpgen autotest make relaxation.json
101+
dpgen autotest make relaxation.json
102102
```
103103

104104
### Run
@@ -110,5 +110,5 @@ dpgen autotest run relaxation.json machine.json
110110
### Post
111111
The post process of calculation results would be performed. `result.json` in json format will be generated in `confs/mp-*/relaxation/relax_task` for relaxation and `result.json` in json format and `result.out` in txt format in `confs/mp-*/eos_00` for EOS. The `machine.json` file is also not needed for `post`. Example:
112112
```bash
113-
dpgen autotest post relaxation.json
113+
dpgen autotest post relaxation.json
114114
```

doc/autotest/index.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ Auto test
99
:caption: Guidelines
1010

1111
Auto-test
12-
12+
1313
.. _Main-components::
1414

1515
.. toctree::
1616
:maxdepth: 2
1717
:caption: Main components
18-
18+
1919
Task-type
2020
Property-type
2121
Make-run-and-post
@@ -25,7 +25,7 @@ Auto test
2525
.. toctree::
2626
:maxdepth: 2
2727
:caption: Structure relaxation
28-
28+
2929
relaxation/index.rst
3030

3131
.. _Property::
@@ -41,13 +41,13 @@ Auto test
4141
.. toctree::
4242
:maxdepth: 2
4343
:caption: Refine
44-
44+
4545
refine/index.rst
4646

4747
.. _Reproduce::
4848

4949
.. toctree::
5050
:maxdepth: 2
5151
:caption: Reproduce
52-
52+
5353
reproduce/index.rst

doc/autotest/property/Property-get-started-and-input-examples.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Key words | data structure | example | description
6161
**type** | String | "eos" | property type
6262
skip | Boolean | true | whether to skip current property or not
6363
start_confs_path | String | "../vasp/confs" | start from the equilibrium configuration in other path only for the current property type
64-
cal_setting["input_prop"] | String | "lammps_input/lammps_high" |input commands file
64+
cal_setting["input_prop"] | String | "lammps_input/lammps_high" |input commands file
6565
cal_setting["overwrite_interaction"] | Dict | | overwrite the interaction in the `interaction` part only for the current property type
6666

6767
other parameters in `cal_setting` and `cal_type` in `relaxation` also apply in `property`.
@@ -116,4 +116,4 @@ Key words | data structure | example | description
116116
supercell_size | List of Int | [1,1,10] | the supercell to be constructed, default = [1,1,5]
117117
min_vacuum_size | Int or Float | 10 | minimum size of vacuum width, default = 20
118118
add_fix | List of String | ['true','true','false'] | whether to fix atoms in the direction, default = ['true','true','false'] (standard method)
119-
n_steps | Int | 20 | Number of points for gamma-line calculation, default = 10
119+
n_steps | Int | 20 | Number of points for gamma-line calculation, default = 10

doc/autotest/property/Property-post.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ Use command
44
```bash
55
dpgen autotest post property.json
66
```
7-
to post results as `result.json` and `result.out` in each property's path.
7+
to post results as `result.json` and `result.out` in each property's path.

doc/autotest/property/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ Property
99
Property-make
1010
Property-run
1111
Property-post
12-
properties/index.rst
12+
properties/index.rst

0 commit comments

Comments
 (0)