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

Change default deepmd_version and make the screen output complete #1641

Merged
merged 6 commits into from
Sep 29, 2024
Merged

Conversation

scott-5
Copy link
Contributor

@scott-5 scott-5 commented Sep 23, 2024

  1. make default deepmd_version setting be consistent with the doc
  2. add StreamHandlers to root logger to make the screen output complete

Summary by CodeRabbit

  • New Features
    • Updated versioning information for improved clarity.
    • Added a versioning element in the configuration for tracking and compatibility.
  • Bug Fixes
    • Enhanced logging configuration to improve message handling and visibility during runtime.

make it to be consisten with the doc

Signed-off-by: Scott Wu <[email protected]>
dlog logger defaults to broadcasting logs to root logger causing unclear output. So disable propagation to keep the output clear.

Signed-off-by: Scott Wu <[email protected]>
Copy link
Contributor

coderabbitai bot commented Sep 23, 2024

📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough

Walkthrough

The changes involve modifications to the logging configuration in the dpgen/__init__.py file, specifically setting the propagate attribute of the dlog logger to False and configuring a file handler for logging. Additionally, the deepmd_version variable in the set_version function within dpgen/generator/run.py is updated from "1" to "2", reflecting a change in versioning information. A new key-value pair for deepmd_version is also added to the machine-local-v1.json configuration file.

Changes

File Change Summary
dpgen/init.py Modified logging configuration: set propagate to False, logging level to WARNING, and added a file handler for dpgen.log.
dpgen/generator/run.py Updated deepmd_version variable in set_version function from "1" to "2".
tests/generator/machine-local-v1.json Added key "deepmd_version": "1" to the JSON configuration file.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Logger
    participant FileHandler
    participant VersionManager

    User->>Logger: Initialize logging
    Logger->>Logger: Set propagate to False
    Logger->>FileHandler: Configure file handler for dpgen.log
    Logger->>User: Log messages at WARNING level

    User->>VersionManager: Call set_version()
    VersionManager->>VersionManager: Update deepmd_version from "1" to "2"
    VersionManager->>User: Return updated mdata
Loading

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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration 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.

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: 1

Outside diff range and nitpick comments (2)
dpgen/__init__.py (2)

Line range hint 12-13: Consider adding a debug formatter

There's a commented-out formatter that includes more detailed information (filename, function name, line number). Consider adding this as an optional debug formatter that can be enabled when more detailed logging is needed.

You could implement this by adding a condition to use the detailed formatter when a debug flag is set. For example:

debug_mode = False  # Set this to True when detailed logging is needed
if debug_mode:
    dlogf_formatter = logging.Formatter('%(asctime)s - %(name)s - [%(filename)s:%(funcName)s - %(lineno)d ] - %(levelname)s \n %(message)s')
else:
    dlogf_formatter = logging.Formatter("%(asctime)s - %(levelname)s : %(message)s")

Missing deepmd_version Change in dpgen/__init__.py

The PR objectives mention updating the default deepmd_version, but no changes related to deepmd_version are found in dpgen/__init__.py. Please ensure that the deepmd_version is properly updated in this file as intended.

Analysis chain

Line range hint 1-67: Query: Where is the deepmd_version change?

The PR objectives mention changing the default deepmd_version, but this change is not present in this file. Could you clarify where this change is implemented, or if it's supposed to be part of this file?


Follow-up: Correcting the search for deepmd_version

The previous command did not recognize the python file type. Please run the following command to search for deepmd_version in Python files:

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for deepmd_version in the codebase
rg --type python 'deepmd_version'

Length of output: 64


Script:

#!/bin/bash
# Search for deepmd_version in Python files
rg --type py 'deepmd_version'

Length of output: 3595

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between b5c6ea0 and ab01cc5.

Files selected for processing (2)
  • dpgen/init.py (1 hunks)
  • dpgen/generator/run.py (1 hunks)
Additional comments not posted (1)
dpgen/__init__.py (1)

8-8: LGTM: Prevents duplicate logging as intended

This change sets dlog.propagate = False, which prevents log messages from being passed to parent loggers. This effectively addresses the PR objective of preventing duplicate output by ensuring that log messages are only written to the dpgen.log file and not propagated to stderr or other handlers.

@scott-5 scott-5 changed the title Change default deepmd_version and prevent from duplicate output Change default deepmd_version and make the output complete Sep 26, 2024
@scott-5 scott-5 changed the title Change default deepmd_version and make the output complete Change default deepmd_version and make the screen output complete Sep 26, 2024
@scott-5 scott-5 requested a review from njzjz September 26, 2024 03:25
Copy link
Contributor Author

@scott-5 scott-5 left a comment

Choose a reason for hiding this comment

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

The original screen is unchanged but root logger is configured

@scott-5 scott-5 marked this pull request as draft September 27, 2024 04:14
@scott-5 scott-5 marked this pull request as ready for review September 27, 2024 04:23
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: 0

🧹 Outside diff range and nitpick comments (2)
tests/generator/machine-local-v1.json (2)

2-2: LGTM! Consider adding a comment for clarity.

The addition of "deepmd_version": "1" is consistent with the PR objective to change the default deepmd_version. This change improves the configuration file by explicitly specifying the version.

Consider adding a comment above this line to explain the purpose and potential values of deepmd_version. This would enhance maintainability and user understanding. For example:

+    // Specifies the version of DeePMD-kit to use. Valid values: "0", "1", "2"
     "deepmd_version": "1",

Line range hint 1-47: Consider using standard JSON comments for improved readability.

The JSON structure is valid and the addition of deepmd_version is consistent with the file structure. However, the file uses non-standard comment keys (e.g., "_comment1", "_comment2") for documentation.

Consider using standard JSON comments (starting with //) instead of comment keys. This would improve readability and maintain proper JSON structure. For example:

     "source_list": [
         "/home/wanghan/study/deep.md/venvs/py3.6-tf1.8/bin/active"
     ],
     "envs": {},
-    "_comment1": "that's All"
+    // that's All
 },

Apply this change throughout the file for all comment keys.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between c8b3dbe and 00cc227.

📒 Files selected for processing (1)
  • tests/generator/machine-local-v1.json (1 hunks)

Copy link

codecov bot commented Sep 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 49.53%. Comparing base (1c1e385) to head (00cc227).
Report is 21 commits behind head on devel.

Additional details and impacted files
@@            Coverage Diff             @@
##            devel    #1641      +/-   ##
==========================================
- Coverage   49.54%   49.53%   -0.02%     
==========================================
  Files          83       83              
  Lines       14848    14849       +1     
==========================================
- Hits         7357     7356       -1     
- Misses       7491     7493       +2     

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

@wanghan-iapcm wanghan-iapcm merged commit 4a3775d into deepmodeling:devel Sep 29, 2024
7 checks passed
@scott-5 scott-5 deleted the devel branch September 29, 2024 06:51
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.

The default version settings are inconsistent with what is described in the doc
3 participants