Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update deepmd input to v2; format JSON files #1315

Merged
merged 10 commits into from Aug 28, 2023

Conversation

njzjz
Copy link
Member

@njzjz njzjz commented Aug 27, 2023

This PR updates all JSON files:

  • convert default_training_param to v2 format
  • format JSON files
  • update _comment to _commentN to avoid duplicated keys
  • enable check-json and pretty-format-json hooks
import json
from glob import glob

from deepmd.utils.compat import update_deepmd_input, convert_input_v1_v2

for ii in glob("**/*.json", recursive=True):
    with open(ii) as f:
        content = f.read()
    count = 1
    while True:
        if r'"_comment"' not in content:
            break
        content = content.replace('"_comment"', '"_comment%d"' % count, 1)
        count += 1
    try:
        jdata = json.loads(content)
    except Exception as e:
        print(ii, e)
        continue
    if "default_training_param" in jdata:
        jdata["default_training_param"] = update_deepmd_input(
            jdata["default_training_param"], warning=False)
        if "decay_rate" in jdata["default_training_param"]["learning_rate"]:
            jdata["default_training_param"] = convert_input_v1_v2(
                jdata["default_training_param"], warning=False)
        if "load_ckpt" in jdata["default_training_param"]["training"]:
            del jdata["default_training_param"]["training"]["load_ckpt"]
    content = json.dumps(jdata, indent=2)

    with open(ii, "w") as f:
        f.write(content)

njzjz and others added 5 commits August 23, 2023 15:07
Signed-off-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu>
Signed-off-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu>
Signed-off-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu>
Signed-off-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu>
@codecov
Copy link

codecov bot commented Aug 27, 2023

Codecov Report

Patch and project coverage have no change.

Comparison is base (0761763) 48.24% compared to head (1eb347d) 48.24%.

Additional details and impacted files
@@           Coverage Diff           @@
##            devel    #1315   +/-   ##
=======================================
  Coverage   48.24%   48.24%           
=======================================
  Files          82       82           
  Lines       14601    14601           
=======================================
  Hits         7044     7044           
  Misses       7557     7557           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@njzjz njzjz marked this pull request as ready for review August 27, 2023 03:00
@wanghan-iapcm wanghan-iapcm merged commit 2a25606 into deepmodeling:devel Aug 28, 2023
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants