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

v0.0.24 #27

Merged
merged 6 commits into from
Aug 10, 2024
Merged

v0.0.24 #27

merged 6 commits into from
Aug 10, 2024

Conversation

PhilipDeegan
Copy link
Owner

@PhilipDeegan PhilipDeegan commented Jul 14, 2024

Summary by CodeRabbit

  • New Features

    • Added usage descriptions to various command-line interface parsers for improved user guidance.
    • Introduced a scoped timing management system for performance measurement in multithreaded applications.
    • Enhanced command-line options for the perf and stats_man tools, allowing for output file specification and tool selection.
    • Improved timing data output functionalities, enabling file redirection and detailed performance metrics.
  • Documentation

    • Updated README with structured installation instructions and usage information for the phlop package.
    • Improved documentation for command-line options and modules available in the phlop package.
  • Bug Fixes

    • Clarified help messages for dump and load options in the test cases CLI.
  • Chores

    • Bumped project version from "0.0.23" to "0.0.24".

Copy link

coderabbitai bot commented Jul 14, 2024

Walkthrough

The updates to the phlop package significantly enhance user experience with improved documentation, refined command-line interface (CLI) handling, and the introduction of a new scoped timing framework. Key modifications include clearer command descriptions, enhanced test-loading capabilities, and an increment in the project version to 0.0.24. Collectively, these changes boost usability and introduce robust performance monitoring features.

Changes

File Path Change Summary
README.md Added installation instructions, test runner guidelines, and module/command descriptions for phlop.
mkn.yaml Removed unnecessary blank line, cleaning up formatting.
phlop/app/*.py Enhanced cli_args_parser in various modules with descriptive parameters and improved usability.
phlop/run/*.py Introduced USAGE constants and improved CLI context in mpirun_stats_man.py and stats_man.py.
phlop/run/test_cases.py Improved extract_load function signatures and added USAGE for CLI parser.
phlop/testing/test_cases.py Updated extract_load to accept directory and globbing parameters for clarity.
pyproject.toml Updated project version from "0.0.23" to "0.0.24".
setup.py Version updated from "0.0.23" to "0.0.24".
inc/phlop/timing/threaded_scope_timer.hpp Introduced a scoped timing framework with new structures and macros for performance measurement.
src/phlop/timing/thread_scope_timer.cpp Implemented scoped timer management with a singleton instance for execution time tracking.
tests/timing/test_scope_timer.py Enhanced output handling by adjusting timing output operations.
tests/timing/test_threaded_scope_timer.cpp Implemented performance measurement functions using the new timing framework.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI
    participant TestRunner

    User->>CLI: Run command with options
    CLI->>CLI: Parse arguments
    CLI->>TestRunner: Execute tests based on parsed arguments
    TestRunner->>User: Display results
Loading

Poem

In the world of code where changes brew,
Versions rise and features grew.
A parser's tale with descriptions anew,
Phlop’s journey to 0.0.24 is now true.
The rabbits rejoice, with a joyful hop,
For every improvement, they never stop.
Hooray for progress, code on top! 🐇✨


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.
    • @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 as 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.

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

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

@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, codebase verification and nitpick comments (1)
README.md (1)

15-15: Fix the abbreviation style.

In American English, abbreviations like "etc." require a period.

- ### etc
+ ### etc.
Tools
LanguageTool

[style] ~15-~15: In American English, abbreviations like “etc.” require a period.
Context: ...t_cases -c 20 -d build --cmake ### etc shell python3 -m phlop Available: ...

(ETC_PERIOD)

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 09fb1e9 and 7899cce.

Files selected for processing (11)
  • README.md (1 hunks)
  • mkn.yaml (1 hunks)
  • phlop/app/perf.py (2 hunks)
  • phlop/app/stats_man.py (2 hunks)
  • phlop/run/mpirun_stats_man.py (2 hunks)
  • phlop/run/stats_man.py (1 hunks)
  • phlop/run/test_cases.py (3 hunks)
  • phlop/run/valgrind.py (1 hunks)
  • phlop/testing/test_cases.py (1 hunks)
  • pyproject.toml (1 hunks)
  • setup.py (1 hunks)
Files skipped from review due to trivial changes (3)
  • mkn.yaml
  • pyproject.toml
  • setup.py
Additional context used
LanguageTool
README.md

[style] ~15-~15: In American English, abbreviations like “etc.” require a period.
Context: ...t_cases -c 20 -d build --cmake ### etc shell python3 -m phlop Available: ...

(ETC_PERIOD)

Markdownlint
README.md

3-3: Expected: h2; Actual: h3
Heading levels should only increment by one level at a time

(MD001, heading-increment)

Additional comments not posted (12)
phlop/run/stats_man.py (1)

11-12: LGTM! The changes improve the CLI parser description.

The addition of the USAGE variable enhances the help message for the CLI parser.

Also applies to: 15-15

phlop/run/mpirun_stats_man.py (1)

14-14: LGTM! The changes improve the CLI parser description.

The addition of the USAGE variable enhances the help message for the CLI parser.

Also applies to: 30-30

phlop/run/valgrind.py (1)

13-13: LGTM! The changes improve the CLI parser description.

The addition of the description parameter enhances the help message for the CLI parser.

Also applies to: 21-21

README.md (2)

1-1: LGTM! The quick guide is clear and concise.

The addition of the quick guide enhances the documentation.


9-13: LGTM! The cmake test runner instructions are clear and concise.

The addition of the cmake test runner instructions enhances the documentation.

phlop/app/perf.py (1)

Line range hint 107-120: LGTM!

The addition of the description parameter to the cli_args_parser function improves the usability of the CLI tool.

phlop/run/test_cases.py (4)

18-18: LGTM!

The addition of the USAGE constant provides a clear description of the CLI tool's purpose.


31-32: LGTM!

The updated help messages for the dump and load options provide clearer instructions for the users.


38-38: LGTM!

The addition of the description parameter to the argparse.ArgumentParser improves the usability of the CLI tool.


157-159: LGTM!

Including cli_args.dir when calling pp.extract_load ensures that the correct directory is used when loading test cases.

phlop/app/stats_man.py (1)

Line range hint 37-46: LGTM!

The addition of the description parameter to the cli_args_parser function improves the usability of the CLI tool.

phlop/testing/test_cases.py (1)

196-199: LGTM!

The changes to the extract_load function improve its flexibility and reusability by taking directory and globbing arguments instead of cli_args.

Copy link

@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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 7899cce and 622a16c.

Files selected for processing (11)
  • README.md (1 hunks)
  • mkn.yaml (1 hunks)
  • phlop/app/perf.py (2 hunks)
  • phlop/app/stats_man.py (2 hunks)
  • phlop/run/mpirun_stats_man.py (2 hunks)
  • phlop/run/stats_man.py (1 hunks)
  • phlop/run/test_cases.py (3 hunks)
  • phlop/run/valgrind.py (1 hunks)
  • phlop/testing/test_cases.py (1 hunks)
  • pyproject.toml (1 hunks)
  • setup.py (1 hunks)
Files skipped from review as they are similar to previous changes (7)
  • mkn.yaml
  • phlop/app/perf.py
  • phlop/app/stats_man.py
  • phlop/run/test_cases.py
  • phlop/run/valgrind.py
  • pyproject.toml
  • setup.py
Additional context used
LanguageTool
README.md

[style] ~15-~15: In American English, abbreviations like “etc.” require a period.
Context: ..._cases -c 20 -d build --cmake #### etc shell python3 -m phlop Available: ...

(ETC_PERIOD)

Markdownlint
README.md

3-3: Expected: h2; Actual: h4
Heading levels should only increment by one level at a time

(MD001, heading-increment)

Additional comments not posted (10)
phlop/run/stats_man.py (2)

11-12: LGTM! The USAGE constant is well-defined.

The USAGE constant provides a clear description for the stats manager.


15-15: LGTM! The main function now includes a description for the CLI parser.

The parser now includes the USAGE constant, improving the clarity of the CLI argument parser.

phlop/run/mpirun_stats_man.py (2)

14-14: LGTM! The USAGE constant is well-defined.

The USAGE constant provides a clear description for the MPI stats manager.


30-30: LGTM! The main function now includes a description for the CLI parser.

The parser now includes the USAGE constant, improving the clarity of the CLI argument parser.

README.md (4)

1-7: LGTM! The installation instructions are clear.

The instructions for installing the phlop package are straightforward and easy to follow.

Tools
Markdownlint

3-3: Expected: h2; Actual: h4
Heading levels should only increment by one level at a time

(MD001, heading-increment)


9-13: LGTM! The CMake test runner instructions are clear.

The instructions for running tests with CMake projects are straightforward and easy to follow.


15-32: LGTM! The list of available modules and commands is comprehensive.

The list provides a good overview of the available modules and commands in the phlop package.

Tools
LanguageTool

[style] ~15-~15: In American English, abbreviations like “etc.” require a period.
Context: ..._cases -c 20 -d build --cmake #### etc shell python3 -m phlop Available: ...

(ETC_PERIOD)


34-52: LGTM! The usage instructions for test_cases.py are clear.

The instructions provide detailed information about the available options for the test_cases.py script.

phlop/testing/test_cases.py (2)

196-199: LGTM! The extract_load function now accepts directory and globbing parameters.

The change improves the flexibility of the function by allowing the user to specify the directory and globbing pattern directly.


199-199: LGTM! The extract_load function correctly handles the new parameters.

The function correctly processes the directory and globbing pattern to find the load files.

@PhilipDeegan PhilipDeegan force-pushed the next branch 2 times, most recently from 5d17f05 to e3b7064 Compare July 14, 2024 11:36
Copy link

@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, codebase verification and nitpick comments (4)
phlop/run/stats_man.py (1)

11-12: Update required: Ensure all calls to sman.cli_args_parser match the new signature with the USAGE string.

The following files contain calls to cli_args_parser that need to be updated to include the USAGE string:

  • phlop/run/test_cases.py
  • phlop/run/valgrind.py
  • phlop/run/perf.py
  • phlop/run/mpirun_perf.py
  • phlop/app/stats_man.py

Please update these instances to ensure consistency across the codebase.

Analysis chain

LGTM! But verify the function usage in the codebase.

The addition of the USAGE string improves the CLI user experience by providing a clear description of the Stats Manager. Ensure that all calls to sman.cli_args_parser are updated to match the new signature.

Also applies to: 15-15

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `sman.cli_args_parser` match the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type python -A 5 $'cli_args_parser'

Length of output: 70


Script:

#!/bin/bash
# Description: Verify all function calls to `sman.cli_args_parser` match the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type py -A 5 $'cli_args_parser'

Length of output: 3419

phlop/run/mpirun_stats_man.py (1)

14-14: Update required: Ensure all calls to cli_args_parser include the USAGE string

The following instances of cli_args_parser need to be updated to include the USAGE string for consistency and proper functionality:

  • phlop/run/valgrind.py (line 18)
  • phlop/run/mpirun_perf.py (line 15)
  • phlop/run/test_cases.py (line 18)
  • phlop/run/perf.py (line 14)

Please update these instances to match the new signature.

Analysis chain

LGTM! But verify the function usage in the codebase.

The addition of the USAGE string improves the CLI user experience by providing a clear description of the MPI Stats Manager. Ensure that all calls to sman.cli_args_parser are updated to match the new signature.

Also applies to: 30-30

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `sman.cli_args_parser` match the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type python -A 5 $'cli_args_parser'

Length of output: 70


Script:

#!/bin/bash
# Description: Verify all function calls to `sman.cli_args_parser` match the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type-add 'py:*.py' -tpy -A 5 $'cli_args_parser'

Length of output: 3435

README.md (2)

3-3: Correct heading level increment.

The heading level should increment by one level at a time.

-#### installation
+## installation
Tools
Markdownlint

3-3: Expected: h2; Actual: h4
Heading levels should only increment by one level at a time

(MD001, heading-increment)


15-15: Add a period after "etc".

In American English, abbreviations like "etc." require a period.

-#### etc
+#### etc.
Tools
LanguageTool

[style] ~15-~15: In American English, abbreviations like “etc.” require a period.
Context: ..._cases -c 20 -d build --cmake #### etc shell python3 -m phlop Available: ...

(ETC_PERIOD)

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 622a16c and a7fd11b.

Files selected for processing (16)
  • README.md (1 hunks)
  • inc/phlop/timing/threaded_scope_timer.hpp (1 hunks)
  • mkn.yaml (1 hunks)
  • phlop/app/perf.py (3 hunks)
  • phlop/app/stats_man.py (2 hunks)
  • phlop/run/mpirun_perf.py (1 hunks)
  • phlop/run/mpirun_stats_man.py (2 hunks)
  • phlop/run/stats_man.py (1 hunks)
  • phlop/run/test_cases.py (3 hunks)
  • phlop/run/valgrind.py (1 hunks)
  • phlop/testing/test_cases.py (1 hunks)
  • pyproject.toml (1 hunks)
  • setup.py (1 hunks)
  • src/phlop/timing/thread_scope_timer.cpp (1 hunks)
  • tests/timing/test_scope_timer.py (1 hunks)
  • tests/timing/test_threaded_scope_timer.cpp (1 hunks)
Files skipped from review due to trivial changes (4)
  • mkn.yaml
  • pyproject.toml
  • setup.py
  • tests/timing/test_scope_timer.py
Additional context used
Ruff
phlop/run/mpirun_perf.py

33-36: Combine if branches using logical or operator

Combine if branches

(SIM114)

LanguageTool
README.md

[style] ~15-~15: In American English, abbreviations like “etc.” require a period.
Context: ..._cases -c 20 -d build --cmake #### etc shell python3 -m phlop Available: ...

(ETC_PERIOD)

Markdownlint
README.md

3-3: Expected: h2; Actual: h4
Heading levels should only increment by one level at a time

(MD001, heading-increment)

Additional comments not posted (23)
phlop/run/mpirun_perf.py (1)

17-23: LGTM! But verify the function usage in the codebase.

The delegation to p.verify_cli_args and the handling of the outfile attribute enhance the argument verification process. Ensure that all calls to verify_cli_args are updated to match the new logic.

tests/timing/test_threaded_scope_timer.cpp (5)

7-12: LGTM!

The function fny correctly uses the PHLOP_SCOPE_TIMER macro and performs a sleep operation.


14-23: LGTM!

The function fn0 correctly uses the PHLOP_SCOPE_TIMER macro and performs a sleep operation along with a nested function call.


25-32: LGTM!

The function fn1 correctly uses the PHLOP_SCOPE_TIMER macro and performs a sleep operation along with a nested function call.


34-40: LGTM!

The function fn2 correctly uses the PHLOP_SCOPE_TIMER macro and performs a sleep operation along with a nested function call.


42-61: LGTM!

The main function correctly initializes the ScopeTimerMan instance, creates threads, and calls the defined functions.

phlop/run/valgrind.py (1)

13-23: LGTM!

The changes to the cli_args_parser function enhance the usability and clarity of the command-line interface by adding a description parameter and specifying the formatter_class.

src/phlop/timing/thread_scope_timer.cpp (3)

8-12: LGTM!

The function ScopeTimerMan::INSTANCE correctly implements the singleton pattern by returning a static instance of ScopeTimerMan.


20-32: LGTM!

The constructor scope_timer::scope_timer correctly initializes the scoped timer and sets the parent scope if active.


34-53: LGTM!

The destructor scope_timer::~scope_timer correctly finalizes the scoped timer and updates the parent scope if active.

phlop/app/perf.py (2)

Line range hint 107-119:
Ensure correct usage of the new description parameter.

The addition of the description parameter enhances the flexibility of the CLI argument parser.


Line range hint 122-134:
Verify the integration of new command-line options.

The new -o/--outfile and -t/--tool options enhance the usability of the CLI. Ensure these options are correctly integrated and used in the codebase.

Verification successful

Verification successful for new command-line options.

The new -o/--outfile and -t/--tool options are correctly integrated and used in the codebase. Here are the relevant locations:

  • phlop/run/valgrind.py
  • phlop/run/mpirun_perf.py
  • phlop/app/valgrind.py
  • phlop/app/perf.py
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of new command-line options.

# Test: Search for the usage of the new options. Expect: Correct usage in the codebase.
rg --type python -A 5 $'--outfile'
rg --type python -A 5 $'--tool'

Length of output: 913


Script:

#!/bin/bash
# Description: Verify the usage of new command-line options.

# Test: Search for the usage of the new options. Expect: Correct usage in the codebase.
rg --type py 'outfile'
rg --type py 'tool'

Length of output: 1837

phlop/run/test_cases.py (4)

18-19: LGTM! The usage string improves user guidance.

The addition of the USAGE constant provides a clear description of the test runner's purpose.


31-32: Clarify the help message for the dump option.

The updated help message for the dump option enhances clarity.


38-40: Ensure correct usage of the description parameter.

The addition of the description parameter to the ArgumentParser improves the CLI's usability.


158-160: Verify the updated logic for loading test cases.

The explicit passing of cli_args.dir ensures the directory argument is used correctly. Verify the integration of this change.

Verification successful

The updated logic for loading test cases is correctly integrated.

The cli_args.dir parameter is correctly passed to and utilized by the pp.extract_load function to locate and process test case files.

  • phlop/run/test_cases.py
  • phlop/testing/test_cases.py
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the updated logic for loading test cases.

# Test: Search for the usage of the `cli_args.dir` parameter in `pp.extract_load`. Expect: Correct usage in the codebase.
rg --type python -A 5 $'pp.extract_load'

Length of output: 70


Script:

#!/bin/bash
# Description: Verify the updated logic for loading test cases.

# Test: Search for the usage of the `cli_args.dir` parameter in `pp.extract_load`. Expect: Correct usage in the codebase.
rg --type py -A 5 'pp.extract_load'

Length of output: 388


Script:

#!/bin/bash
# Description: Verify the implementation of `pp.extract_load`.

# Search for the definition of `extract_load` in the `pp` module.
rg --type py 'def extract_load'

Length of output: 100


Script:

#!/bin/bash
# Description: Verify the implementation of `pp.extract_load`.

# Extract the implementation of the `extract_load` function in `phlop/testing/test_cases.py`.
rg --type py -A 20 'def extract_load' phlop/testing/test_cases.py

Length of output: 712

phlop/app/stats_man.py (1)

Line range hint 37-48:
LGTM! But verify the function usage in the codebase.

The code changes are approved. The addition of the description parameter and the use of argparse.ArgumentDefaultsHelpFormatter enhance the usability of the CLI.

However, ensure that all function calls to cli_args_parser match the new signature.

phlop/testing/test_cases.py (1)

196-199: LGTM! But verify the function usage in the codebase.

The code changes are approved. The modifications improve the function's usability and maintainability by providing clearer parameter definitions and reducing complexity in file path generation.

However, ensure that all function calls to extract_load match the new signature.

Verification successful

Function usage matches the new signature.

The function extract_load is correctly called with the new signature in the codebase.

  • phlop/run/test_cases.py: pp.extract_load(cli_args.dir, cli_args.load)
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `extract_load` match the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type python -A 5 $'extract_load'

Length of output: 67


Script:

#!/bin/bash
# Description: Verify all function calls to `extract_load` match the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type py -A 5 $'extract_load'

Length of output: 696

inc/phlop/timing/threaded_scope_timer.hpp (5)

35-148: LGTM!

The ScopeTimerMan class is well-structured and includes appropriate methods for managing scope timers.


151-166: LGTM!

The RunTimerReportSnapshot structure is simple and includes appropriate fields for storing the snapshot data.


168-188: LGTM!

The RunTimerReport structure is well-structured and includes appropriate fields and methods for managing timer reports and their snapshots.


193-222: LGTM!

The scope_timer structure is well-structured and includes appropriate fields and methods for managing scope timers.


239-343: LGTM!

The BinaryTimerFile structure is well-structured and includes appropriate methods for writing the timer data to a file.

Comment on lines +31 to +38
cli_args = verify_cli_args(parser.parse_args())
try:
...
if cli_args.tool == "stat":
...
elif cli_args.tool == "record":
...
else:
raise RuntimeError("PHLOP ERROR: Perf tool not recognized")
Copy link

Choose a reason for hiding this comment

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

LGTM! Consider combining the if branches.

The re-enabling of argument verification and the addition of error handling for unrecognized tools improve robustness. Consider combining the if branches using a logical or operator to simplify the code.

-    if cli_args.tool == "stat":
-        ...
-    elif cli_args.tool == "record":
-        ...
+    if cli_args.tool == "stat" or cli_args.tool == "record":
+        ...
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
cli_args = verify_cli_args(parser.parse_args())
try:
...
if cli_args.tool == "stat":
...
elif cli_args.tool == "record":
...
else:
raise RuntimeError("PHLOP ERROR: Perf tool not recognized")
cli_args = verify_cli_args(parser.parse_args())
try:
if cli_args.tool == "stat" or cli_args.tool == "record":
...
else:
raise RuntimeError("PHLOP ERROR: Perf tool not recognized")
Tools
Ruff

33-36: Combine if branches using logical or operator

Combine if branches

(SIM114)

Copy link

@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: 3

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between a7fd11b and 1edc4a2.

Files selected for processing (5)
  • inc/phlop/timing/threaded_scope_timer.hpp (1 hunks)
  • phlop/timing/scope_timer.py (1 hunks)
  • src/phlop/timing/threaded_scope_timer.cpp (1 hunks)
  • tests/timing/test_scope_timer.py (1 hunks)
  • tests/timing/test_threaded_scope_timer.cpp (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • inc/phlop/timing/threaded_scope_timer.hpp
  • tests/timing/test_threaded_scope_timer.cpp
Additional context used
Ruff
phlop/timing/scope_timer.py

84-85: Use a single with statement with multiple contexts instead of nested with statements

Combine with statements

(SIM117)


96-96: Ambiguous variable name: l

(E741)


98-98: Ambiguous variable name: l

(E741)


121-122: Use a single with statement with multiple contexts instead of nested with statements

Combine with statements

(SIM117)

Additional comments not posted (5)
src/phlop/timing/threaded_scope_timer.cpp (3)

8-12: Singleton pattern implementation is correct.

The INSTANCE method correctly implements the singleton pattern.


20-32: Constructor logic is correct.

The constructor initializes the scope timer and updates the thread-local variable.


34-53: Destructor logic is correct.

The destructor updates the thread-local variable and manages the snapshots and child nodes.

tests/timing/test_scope_timer.py (1)

25-33: Test function changes are approved.

The test function now writes scope timings to files instead of asserting a specific value. This change enhances the test's functionality by providing more detailed output.

phlop/timing/scope_timer.py (1)

127-145: Function logic is correct.

The function print_root_as_csv correctly outputs root timing data in CSV format and handles optional headers and regex filtering.

Comment on lines +81 to +87
def write_scope_timings(scope_timer_file, outfile, sort_worst_first=True):
from contextlib import redirect_stdout

with open(outfile, "w") as f:
with redirect_stdout(f):
print_scope_timings(scope_timer_file, sort_worst_first)

Copy link

Choose a reason for hiding this comment

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

Combine with statements.

Use a single with statement with multiple contexts instead of nested with statements.

-  with open(outfile, "w") as f:
-      with redirect_stdout(f):
+  with open(outfile, "w") as f, redirect_stdout(f):
          print_scope_timings(scope_timer_file, sort_worst_first)
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
def write_scope_timings(scope_timer_file, outfile, sort_worst_first=True):
from contextlib import redirect_stdout
with open(outfile, "w") as f:
with redirect_stdout(f):
print_scope_timings(scope_timer_file, sort_worst_first)
def write_scope_timings(scope_timer_file, outfile, sort_worst_first=True):
from contextlib import redirect_stdout
with open(outfile, "w") as f, redirect_stdout(f):
print_scope_timings(scope_timer_file, sort_worst_first)
Tools
Ruff

84-85: Use a single with statement with multiple contexts instead of nested with statements

Combine with statements

(SIM117)

Comment on lines +121 to +123
with open(outfile, "w") as f:
with redirect_stdout(f):
print_root_as_csv(scope_timer_file, headers, regex)
Copy link

Choose a reason for hiding this comment

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

Combine with statements.

Use a single with statement with multiple contexts instead of nested with statements.

-  with open(outfile, "w") as f:
-      with redirect_stdout(f):
+  with open(outfile, "w") as f, redirect_stdout(f):
          print_root_as_csv(scope_timer_file, headers, regex)
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
with open(outfile, "w") as f:
with redirect_stdout(f):
print_root_as_csv(scope_timer_file, headers, regex)
with open(outfile, "w") as f, redirect_stdout(f):
print_root_as_csv(scope_timer_file, headers, regex)
Tools
Ruff

121-122: Use a single with statement with multiple contexts instead of nested with statements

Combine with statements

(SIM117)

Copy link

@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: 3

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 1edc4a2 and 1f134fc.

Files selected for processing (2)
  • phlop/timing/scope_timer.py (1 hunks)
  • tests/timing/test_scope_timer.py (2 hunks)
Additional context used
Ruff
phlop/timing/scope_timer.py

84-85: Use a single with statement with multiple contexts instead of nested with statements

Combine with statements

(SIM117)


95-95: Ambiguous variable name: l

(E741)


97-97: Ambiguous variable name: l

(E741)


120-121: Use a single with statement with multiple contexts instead of nested with statements

Combine with statements

(SIM117)

Additional comments not posted (6)
tests/timing/test_scope_timer.py (2)

Line range hint 14-14:
Commented-out assertion: Verify its necessity.

The assertion np.testing.assert_equal(scope_timer_file(scope_timer_file.roots[0].k), "fn1") has been commented out. Ensure that this validation is no longer needed or has been moved elsewhere.


Line range hint 15-15:
New output operations: Approved.

The new output operations enhance the functionality by providing detailed output.

phlop/timing/scope_timer.py (4)

81-87: New function write_scope_timings: Approved.

The function enhances functionality by enabling file output.

Tools
Ruff

84-85: Use a single with statement with multiple contexts instead of nested with statements

Combine with statements

(SIM117)


89-115: Function print_scope_timings: Approved.

The function modifications provide more detailed performance metrics.

Tools
Ruff

95-95: Ambiguous variable name: l

(E741)


97-97: Ambiguous variable name: l

(E741)


117-123: New function write_root_as_csv: Approved.

The function enhances functionality by enabling file output.

Tools
Ruff

120-121: Use a single with statement with multiple contexts instead of nested with statements

Combine with statements

(SIM117)


125-142: Function print_root_as_csv: Approved.

The function modifications improve output formatting and add regex filtering.

Comment on lines +84 to +85
with open(outfile, "w") as f:
with redirect_stdout(f):
Copy link

Choose a reason for hiding this comment

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

Combine with statements.

Use a single with statement with multiple contexts instead of nested with statements.

-  with open(outfile, "w") as f:
-      with redirect_stdout(f):
+  with open(outfile, "w") as f, redirect_stdout(f):
          print_scope_timings(scope_timer_file, sort_worst_first)
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
with open(outfile, "w") as f:
with redirect_stdout(f):
with open(outfile, "w") as f, redirect_stdout(f):
print_scope_timings(scope_timer_file, sort_worst_first)
Tools
Ruff

84-85: Use a single with statement with multiple contexts instead of nested with statements

Combine with statements

(SIM117)

Comment on lines +120 to +121
with open(outfile, "w") as f:
with redirect_stdout(f):
Copy link

Choose a reason for hiding this comment

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

Combine with statements.

Use a single with statement with multiple contexts instead of nested with statements.

-  with open(outfile, "w") as f:
-      with redirect_stdout(f):
+  with open(outfile, "w") as f, redirect_stdout(f):
          print_root_as_csv(scope_timer_file, headers, regex)
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
with open(outfile, "w") as f:
with redirect_stdout(f):
with open(outfile, "w") as f, redirect_stdout(f):
print_root_as_csv(scope_timer_file, headers, regex)
Tools
Ruff

120-121: Use a single with statement with multiple contexts instead of nested with statements

Combine with statements

(SIM117)

Comment on lines 94 to 99
def loss(n):
l = n.t if n.c else 0
for c in n.c:
l -= c.t

return "-" if l < 1e-2 else float(f"{l / n.t * 100:.2f}")
Copy link

Choose a reason for hiding this comment

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

Avoid ambiguous variable name.

The variable name l is ambiguous and should be renamed to something more descriptive.

-  def loss(n):
-      l = n.t if n.c else 0
-      for c in n.c:
-          l -= c.t
+  def loss(node):
+      loss_value = node.t if node.c else 0
+      for child in node.c:
+          loss_value -= child.t
          return "-" if loss_value < 1e-2 else float(f"{loss_value / node.t * 100:.2f}")
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
def loss(n):
l = n.t if n.c else 0
for c in n.c:
l -= c.t
return "-" if l < 1e-2 else float(f"{l / n.t * 100:.2f}")
def loss(node):
loss_value = node.t if node.c else 0
for child in node.c:
loss_value -= child.t
return "-" if loss_value < 1e-2 else float(f"{loss_value / node.t * 100:.2f}")
Tools
Ruff

95-95: Ambiguous variable name: l

(E741)


97-97: Ambiguous variable name: l

(E741)

Copy link

@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, codebase verification and nitpick comments (1)
phlop/timing/scope_timer.py (1)

89-100: Rename variable lss to loss_value.

The variable name lss is not descriptive. Renaming it to loss_value improves readability.

-  def loss(n):
-      lss = n.t if n.c else 0
-      for c in n.c:
-          lss -= c.t
-      return "-" if lss < 1e-2 else float(f"{lss / n.t * 100:.2f}")
+  def loss(n):
+      loss_value = n.t if n.c else 0
+      for c in n.c:
+          loss_value -= c.t
+      return "-" if loss_value < 1e-2 else float(f"{loss_value / n.t * 100:.2f}")
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 1f134fc and 02250f4.

Files selected for processing (1)
  • phlop/timing/scope_timer.py (1 hunks)
Additional context used
Ruff
phlop/timing/scope_timer.py

84-85: Use a single with statement with multiple contexts instead of nested with statements

Combine with statements

(SIM117)


120-121: Use a single with statement with multiple contexts instead of nested with statements

Combine with statements

(SIM117)

Additional comments not posted (3)
phlop/timing/scope_timer.py (3)

81-87: Combine with statements.

Use a single with statement with multiple contexts instead of nested with statements.

-  with open(outfile, "w") as f:
-      with redirect_stdout(f):
+  with open(outfile, "w") as f, redirect_stdout(f):
          print_scope_timings(scope_timer_file, sort_worst_first)
Tools
Ruff

84-85: Use a single with statement with multiple contexts instead of nested with statements

Combine with statements

(SIM117)


117-123: Combine with statements.

Use a single with statement with multiple contexts instead of nested with statements.

-  with open(outfile, "w") as f:
-      with redirect_stdout(f):
+  with open(outfile, "w") as f, redirect_stdout(f):
          print_root_as_csv(scope_timer_file, headers, regex)
Tools
Ruff

120-121: Use a single with statement with multiple contexts instead of nested with statements

Combine with statements

(SIM117)


125-142: LGTM!

The code changes are approved.

Copy link

@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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 02250f4 and 85f69b2.

Files selected for processing (1)
  • phlop/app/stats_man.py (3 hunks)
Additional context used
Ruff
phlop/app/stats_man.py

202-202: Do not use mutable data structures for argument defaults

Replace with None; initialize within function

(B006)

Additional comments not posted (2)
phlop/app/stats_man.py (2)

Line range hint 37-48: Enhancement to CLI argument parser.

The addition of the description parameter in cli_args_parser enhances the CLI's usability by allowing more informative command descriptions.


201-235: Introduction of AttachableRuntimeStatsManager.

The new class encapsulates process management functionalities, improving the structure and maintainability of the code. Methods for starting, killing, and joining processes are well-defined.

Tools
Ruff

202-202: Do not use mutable data structures for argument defaults

Replace with None; initialize within function

(B006)

Comment on lines +202 to +208
def __init__(self, cli_args, info={}):
self.pid = os.getpid()
self.cli_args = cli_args
init_yaml(self.cli_args, self.pid, info)
self.data = {}
self.p = Process(target=AttachableRuntimeStatsManager._run, args=(self,))

Copy link

Choose a reason for hiding this comment

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

Avoid mutable default arguments.

The info parameter in the __init__ method should not use a mutable default value. This can lead to unexpected behavior if the default value is modified.

- def __init__(self, cli_args, info={}):
+ def __init__(self, cli_args, info=None):
+     if info is None:
+         info = {}
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
def __init__(self, cli_args, info={}):
self.pid = os.getpid()
self.cli_args = cli_args
init_yaml(self.cli_args, self.pid, info)
self.data = {}
self.p = Process(target=AttachableRuntimeStatsManager._run, args=(self,))
def __init__(self, cli_args, info=None):
if info is None:
info = {}
self.pid = os.getpid()
self.cli_args = cli_args
init_yaml(self.cli_args, self.pid, info)
self.data = {}
self.p = Process(target=AttachableRuntimeStatsManager._run, args=(self,))
Tools
Ruff

202-202: Do not use mutable data structures for argument defaults

Replace with None; initialize within function

(B006)

@PhilipDeegan PhilipDeegan merged commit f757e00 into master Aug 10, 2024
4 checks passed
@PhilipDeegan PhilipDeegan deleted the next branch August 10, 2024 13:00
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.

1 participant