Skip to content

[Documentation] Add comprehensive argument documentation for pwmat FP style with correct parameter validation #1793

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

Draft
wants to merge 6 commits into
base: devel
Choose a base branch
from

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Aug 21, 2025

This PR adds complete argument documentation for the pwmat FP style variant in dpgen.generator.arginfo.fp_style_variant_type_args(), replacing the placeholder implementation with a comprehensive structure that accurately reflects the actual pwmat implementation behavior.

Key Changes

1. Comprehensive Parameter Documentation

Added detailed documentation for all pwmat parameters including:

  • Required parameters: fp_pp_path, fp_pp_files, core calculation parameters
  • Optional parameters: mixing methods, smearing parameters, symmetry settings
  • User-defined parameters: user_pwmat_params for custom input overrides

2. Correct Argument Structure Based on Code Analysis

The implementation now properly handles the two different code paths in the pwmat implementation:

fp_params path (via make_pwmat_input_user_dict()):

  • Includes icmix, smearing, sigma (processed by _make_smearing())
  • flag_symm is optional (processed by _make_flag_symm())
  • Includes user_pwmat_params for additional parameters

user_fp_params path (direct usage in make_pwmat_input()):

  • Excludes icmix, smearing, sigma (hardcoded as None in run.py:3057-3059)
  • flag_symm is required (accessed directly in run.py:3037)
  • Simpler structure for direct parameter specification

3. Enhanced Validation

  • Proper parameter validation for both input methods
  • Correct handling of optional vs required parameters based on actual usage
  • Support for all three input approaches: fp_incar, user_fp_params, and fp_params

Before/After

Before:

Argument("pwmat", dict, [], doc="TODO: add doc"),

After:

Argument("pwmat", dict, fp_style_pwmat_args(), doc=doc_pwmat),

The pwmat FP style now has accurate argument validation that matches the actual implementation, preventing configuration errors and providing clear documentation for users.

Fixes #774.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@Copilot Copilot AI assigned Copilot and njzjz Aug 21, 2025
Copy link
Author

Copilot AI commented Aug 21, 2025

@njzjz 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs.

I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review.

Co-authored-by: njzjz <9496702+njzjz@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] [Documentation] add fp variant pwmat [Documentation] Add comprehensive argument documentation for pwmat FP style Aug 21, 2025
@Copilot Copilot AI requested a review from njzjz August 21, 2025 11:33
Copilot finished work on behalf of njzjz August 21, 2025 11:33
Copy link
Member

@njzjz njzjz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot Please add tests/generator/param-pyridine-pwmat.json to dpgen/tests/test_check_examples.py to ensure the arguments you added are correct.

Co-authored-by: njzjz <9496702+njzjz@users.noreply.github.com>
Copy link
Author

Copilot AI commented Aug 21, 2025

@copilot Please add tests/generator/param-pyridine-pwmat.json to dpgen/tests/test_check_examples.py to ensure the arguments you added are correct.

Added tests/generator/param-pyridine-pwmat.json to the test suite in test_check_examples.py. The test passes successfully, validating that the pwmat argument definitions are correct and can handle real parameter files. Commit: ffa5f22

@Copilot Copilot AI requested a review from njzjz August 21, 2025 11:51
Copilot finished work on behalf of njzjz August 21, 2025 11:51
Copy link

codecov bot commented Aug 21, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 49.54%. Comparing base (d9e29f4) to head (c9ace72).

Additional details and impacted files
@@            Coverage Diff             @@
##            devel    #1793      +/-   ##
==========================================
+ Coverage   49.46%   49.54%   +0.07%     
==========================================
  Files          83       83              
  Lines       14801    14822      +21     
==========================================
+ Hits         7322     7343      +21     
  Misses       7479     7479              

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@@ -163,6 +163,8 @@
/ "param_C4H16N4_deepmd-kit-2.0.1.json",
),
(run_jdata, p_examples / "run" / "dprc" / "generator.json"),
# pwmat test file from tests/generator
(run_jdata, Path(__file__).parent / "generator" / "param-pyridine-pwmat.json"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot I see other lines use p_examples. Please match it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the pwmat test file reference to use p_examples path pattern consistently with other test files. Changed from Path(__file__).parent / "generator" / "param-pyridine-pwmat.json" to p_examples / "run" / "deprecated" / "dp2.x-lammps-pwmat" / "param_CH4.json". Test passes successfully. Commit: 9d03f93

Co-authored-by: njzjz <9496702+njzjz@users.noreply.github.com>
@Copilot Copilot AI requested a review from njzjz August 21, 2025 12:03
Copilot finished work on behalf of njzjz August 21, 2025 12:03
@njzjz
Copy link
Member

njzjz commented Aug 21, 2025

pre-commit.ci autofix

@njzjz njzjz marked this pull request as ready for review August 21, 2025 14:27
Argument("icmix", float, optional=True, doc=doc_icmix),
Argument("smearing", int, optional=True, doc=doc_smearing),
Argument("sigma", float, optional=True, doc=doc_sigma),
Argument("flag_symm", [int, str], optional=True, doc=doc_flag_symm),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot It seems it cannot be optional:

flag_symm = fp_params["flag_symm"]

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed! Made flag_symm required for user_fp_params since it's accessed directly without checking at line 3037. The fp_params path still has it as optional since it goes through _make_flag_symm() which handles optional parameters. Commit: e4a3bbc

Comment on lines +963 to +965
Argument("icmix", float, optional=True, doc=doc_icmix),
Argument("smearing", int, optional=True, doc=doc_smearing),
Argument("sigma", float, optional=True, doc=doc_sigma),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot I don't think these are used.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're correct! Removed icmix, smearing, and sigma from user_fp_params structure since they're hardcoded as None in the user_fp_params code path (lines 3057-3059). They remain in fp_params structure since they are used via _make_smearing(). Commit: e4a3bbc

Argument("fp_pp_files", list[str], optional=False, doc=doc_fp_pp_files),
Argument("fp_incar", str, optional=True, doc=doc_fp_incar),
Argument("fp_params", dict, args, [], optional=True, doc=doc_fp_params),
Argument("user_fp_params", dict, optional=True, doc=doc_user_fp_params),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot It seems that user_pwmat_params is missing here

user_dict = fp_params["user_pwmat_params"]

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added user_pwmat_params to the fp_params structure. It's used in pwmat.py:181 with conditional checking. Commit: e4a3bbc

Argument("fp_pp_files", list[str], optional=False, doc=doc_fp_pp_files),
Argument("fp_incar", str, optional=True, doc=doc_fp_incar),
Argument("fp_params", dict, args, [], optional=True, doc=doc_fp_params),
Argument("user_fp_params", dict, optional=True, doc=doc_user_fp_params),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot I am wondering if user_fp_params is just an alias of fp_params or not. args should also be defined for user_fp_params.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added proper argument definitions for user_fp_params. It has the same core parameters as fp_params but excludes icmix/smearing/sigma (not used in that code path) and makes flag_symm required (accessed directly). The two paths have different behaviors which are now properly reflected in the argument structure. Commit: e4a3bbc

- Make flag_symm required for user_fp_params (accessed directly in run.py:3037)
- Remove icmix, smearing, sigma from user_fp_params (not used in that code path)
- Keep icmix, smearing, sigma in fp_params (used via make_pwmat_input_user_dict)
- Add proper argument definitions for user_fp_params parameter structure
- Add comments explaining the different behavior between fp_params and user_fp_params paths

Co-authored-by: njzjz <9496702+njzjz@users.noreply.github.com>
@Copilot Copilot AI changed the title [Documentation] Add comprehensive argument documentation for pwmat FP style [Documentation] Add comprehensive argument documentation for pwmat FP style with correct parameter validation Aug 23, 2025
Copilot finished work on behalf of njzjz August 23, 2025 02:43
@Copilot Copilot AI requested a review from njzjz August 23, 2025 02:43
@njzjz
Copy link
Member

njzjz commented Aug 23, 2025

The current issue is that I cannot validate whether the agent makes the correct code...

@njzjz njzjz marked this pull request as draft August 23, 2025 05:31
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.

[Documentation] add fp variant pwmat
2 participants