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

chore: rename j_must_have to j_deprecated and only warn about deprecated keys #3816

Merged
merged 6 commits into from
May 24, 2024

Conversation

njzjz
Copy link
Member

@njzjz njzjz commented May 24, 2024

Fix #3523.

Summary by CodeRabbit

  • Refactor

    • Simplified code by removing the j_must_have function and directly accessing dictionary keys in various test files.
    • Replaced j_must_have with direct dictionary access for improved code readability and maintenance.
  • Chores

    • Updated test files to directly access dictionary values, enhancing code readability and maintainability.

…ted keys

Fix deepmodeling#3523.

Signed-off-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu>
@njzjz njzjz requested a review from wanghan-iapcm May 24, 2024 00:25
Copy link
Contributor

coderabbitai bot commented May 24, 2024

Warning

Rate Limit Exceeded

@njzjz has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 13 minutes and 16 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.
Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.
Please see our FAQ for further information.

Commits Files that changed from the base of the PR and between c7d560f and fa8b2a6.

Walkthrough

The changes involve the removal of the j_must_have function from various files in the deepmd project and replacing its usage with direct dictionary access. Additionally, the j_must_have function has been renamed to j_deprecated in deepmd/common.py, with updated parameter names and an optional deprecated_key parameter to issue warnings for deprecated keys.

Changes

File(s) Change Summary
deepmd/common.py Removed j_must_have function, renamed it to j_deprecated with updated parameters and added an optional deprecated_key.
deepmd/tf/common.py Removed j_must_have from the list of exported entities.
deepmd/tf/entrypoints/train.py, deepmd/tf/train/trainer.py Removed j_must_have function calls and directly accessed dictionary keys.
deepmd/utils/compat.py, deepmd/utils/data_system.py Replaced j_must_have with j_deprecated and updated direct dictionary key access.
source/tests/tf/... Removed j_must_have imports and calls, replaced with direct dictionary key access in multiple test files.

Assessment against linked issues

Objective (Issue #3523) Addressed Explanation
Rename j_must_have to j_deprecated and update parameters
Add optional deprecated_key parameter to j_deprecated
Remove j_must_have usage and replace with direct dictionary access

The changes meet the primary objectives of renaming the j_must_have function to j_deprecated, adding an optional deprecated_key parameter, and updating the codebase to remove j_must_have usage in favor of direct dictionary access.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@njzjz njzjz linked an issue May 24, 2024 that may be closed by this pull request
Copy link

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

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

CodeQL found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

Copy link

codecov bot commented May 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.48%. Comparing base (7b16911) to head (fa8b2a6).
Report is 134 commits behind head on devel.

Additional details and impacted files
@@            Coverage Diff             @@
##            devel    #3816      +/-   ##
==========================================
- Coverage   82.48%   82.48%   -0.01%     
==========================================
  Files         516      516              
  Lines       49057    49057              
  Branches     2987     2986       -1     
==========================================
- Hits        40466    40465       -1     
- Misses       7680     7681       +1     
  Partials      911      911              

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

deepmd/utils/compat.py Outdated Show resolved Hide resolved
Signed-off-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu>
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 28

Outside diff range and nitpick comments (4)
deepmd/utils/data_system.py (1)

794-797: Add detailed documentation for the get_batch method to clarify its behavior and parameters.

deepmd/tf/train/trainer.py (3)

Line range hint 93-125: Consider adding error handling for missing keys in jdata.

Using direct dictionary access (jdata["key"]) can lead to KeyError if the key is missing. Consider using jdata.get("key", default_value) to provide default values or handle missing keys gracefully.


Line range hint 184-186: Refine the assertion error message in build method.

The assertion assert isinstance(self.fitting, EnerFitting) could be more informative. Consider raising a specific exception with a clear error message if the condition is not met.

- assert isinstance(self.fitting, EnerFitting), "Data in mixed_type format must use ener fitting!"
+ if not isinstance(self.fitting, EnerFitting):
+     raise TypeError("Data in mixed_type format must use EnerFitting. Current fitting type: {}".format(type(self.fitting).__name__))

Line range hint 1015-1017: Consider replacing tf.py_func with tf.data API for better performance and compatibility.

tf.py_func is not recommended as it does not support graph optimizations and may not be compatible with TensorFlow 2.x. Consider using tf.data API for building data loading operations, which is more efficient and compatible with newer TensorFlow versions.

source/tests/tf/test_descrpt_se_atten.py Outdated Show resolved Hide resolved
source/tests/tf/test_descrpt_se_atten.py Outdated Show resolved Hide resolved
source/tests/tf/test_descrpt_se_atten.py Outdated Show resolved Hide resolved
source/tests/tf/test_descrpt_se_atten.py Outdated Show resolved Hide resolved
source/tests/tf/test_model_se_a.py Outdated Show resolved Hide resolved
source/tests/tf/test_dipole_se_a.py Outdated Show resolved Hide resolved
source/tests/tf/test_model_se_a_fparam.py Outdated Show resolved Hide resolved
source/tests/tf/test_model_se_a_srtab.py Outdated Show resolved Hide resolved
source/tests/tf/test_model_se_a_ebd_v2.py Outdated Show resolved Hide resolved
source/tests/tf/test_model_se_a_type.py Outdated Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

source/tests/tf/test_virtual_type.py Show resolved Hide resolved
source/tests/tf/test_data_modifier.py Show resolved Hide resolved
source/tests/tf/test_model_se_r.py Show resolved Hide resolved
source/tests/tf/test_dipole_se_a.py Outdated Show resolved Hide resolved
njzjz and others added 3 commits May 23, 2024 21:39
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Signed-off-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Signed-off-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Signed-off-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu>
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 27

source/tests/tf/test_descrpt_se_atten.py Show resolved Hide resolved
source/tests/tf/test_descrpt_se_atten.py Show resolved Hide resolved
source/tests/tf/test_descrpt_se_atten.py Show resolved Hide resolved
source/tests/tf/test_descrpt_se_atten.py Show resolved Hide resolved
source/tests/tf/test_model_se_atten.py Outdated Show resolved Hide resolved
source/tests/tf/test_model_se_atten.py Outdated Show resolved Hide resolved
source/tests/tf/test_polar_se_a_tebd.py Outdated Show resolved Hide resolved
source/tests/tf/test_model_dos.py Show resolved Hide resolved
source/tests/tf/test_descrpt_se_a_type.py Outdated Show resolved Hide resolved
source/tests/tf/test_descrpt_se_a_type.py Show resolved Hide resolved
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Signed-off-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu>
@njzjz
Copy link
Member Author

njzjz commented May 24, 2024

@coderabbitai resolve

Copy link
Contributor

coderabbitai bot commented May 24, 2024

Actions Performed

Comments resolved.

@wanghan-iapcm wanghan-iapcm added this pull request to the merge queue May 24, 2024
Merged via the queue into deepmodeling:devel with commit 6aac9f8 May 24, 2024
61 checks passed
mtaillefumier pushed a commit to mtaillefumier/deepmd-kit that referenced this pull request Sep 18, 2024
…ted keys (deepmodeling#3816)

Fix deepmodeling#3523.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit


- **Refactor**
- Simplified code by removing the `j_must_have` function and directly
accessing dictionary keys in various test files.
- Replaced `j_must_have` with direct dictionary access for improved code
readability and maintenance.

- **Chores**
- Updated test files to directly access dictionary values, enhancing
code readability and maintainability.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

rename j_must_have to j_deprecated and only warn about deprecated keys
2 participants