-
Notifications
You must be signed in to change notification settings - Fork 0
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
v0.0.24 #27
Conversation
WalkthroughThe updates to the Changes
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
Poem
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? TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Additionally, you can add CodeRabbit Configuration File (
|
There was a problem hiding this 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
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 thecli_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
andload
options provide clearer instructions for the users.
38-38
: LGTM!The addition of the
description
parameter to theargparse.ArgumentParser
improves the usability of the CLI tool.
157-159
: LGTM!Including
cli_args.dir
when callingpp.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 thecli_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 takingdirectory
andglobbing
arguments instead ofcli_args
.
There was a problem hiding this 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
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 theUSAGE
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 theUSAGE
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.
5d17f05
to
e3b7064
Compare
There was a problem hiding this 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 tosman.cli_args_parser
match the new signature with theUSAGE
string.The following files contain calls to
cli_args_parser
that need to be updated to include theUSAGE
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 tosman.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 tocli_args_parser
include theUSAGE
stringThe following instances of
cli_args_parser
need to be updated to include theUSAGE
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 tosman.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 +## installationTools
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
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 logicalor
operatorCombine
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 theoutfile
attribute enhance the argument verification process. Ensure that all calls toverify_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 thePHLOP_SCOPE_TIMER
macro and performs a sleep operation.
14-23
: LGTM!The function
fn0
correctly uses thePHLOP_SCOPE_TIMER
macro and performs a sleep operation along with a nested function call.
25-32
: LGTM!The function
fn1
correctly uses thePHLOP_SCOPE_TIMER
macro and performs a sleep operation along with a nested function call.
34-40
: LGTM!The function
fn2
correctly uses thePHLOP_SCOPE_TIMER
macro and performs a sleep operation along with a nested function call.
42-61
: LGTM!The
main
function correctly initializes theScopeTimerMan
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 adescription
parameter and specifying theformatter_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 ofScopeTimerMan
.
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 newdescription
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 thedump
option.The updated help message for the
dump
option enhances clarity.
38-40
: Ensure correct usage of thedescription
parameter.The addition of the
description
parameter to theArgumentParser
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 thepp.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.pyLength 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 ofargparse.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.
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") |
There was a problem hiding this comment.
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.
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 logicalor
operatorCombine
if
branches(SIM114)
There was a problem hiding this 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
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 nestedwith
statementsCombine
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 nestedwith
statementsCombine
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.
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) | ||
|
There was a problem hiding this comment.
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.
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 nestedwith
statementsCombine
with
statements(SIM117)
with open(outfile, "w") as f: | ||
with redirect_stdout(f): | ||
print_root_as_csv(scope_timer_file, headers, regex) |
There was a problem hiding this comment.
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.
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 nestedwith
statementsCombine
with
statements(SIM117)
There was a problem hiding this 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
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 nestedwith
statementsCombine
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 nestedwith
statementsCombine
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 functionwrite_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 nestedwith
statementsCombine
with
statements(SIM117)
89-115
: Functionprint_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 functionwrite_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 nestedwith
statementsCombine
with
statements(SIM117)
125-142
: Functionprint_root_as_csv
: Approved.The function modifications improve output formatting and add regex filtering.
with open(outfile, "w") as f: | ||
with redirect_stdout(f): |
There was a problem hiding this comment.
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.
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 nestedwith
statementsCombine
with
statements(SIM117)
with open(outfile, "w") as f: | ||
with redirect_stdout(f): |
There was a problem hiding this comment.
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.
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 nestedwith
statementsCombine
with
statements(SIM117)
phlop/timing/scope_timer.py
Outdated
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}") |
There was a problem hiding this comment.
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.
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)
There was a problem hiding this 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 variablelss
toloss_value
.The variable name
lss
is not descriptive. Renaming it toloss_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
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 nestedwith
statementsCombine
with
statements(SIM117)
120-121: Use a single
with
statement with multiple contexts instead of nestedwith
statementsCombine
with
statements(SIM117)
Additional comments not posted (3)
phlop/timing/scope_timer.py (3)
81-87
: Combinewith
statements.Use a single
with
statement with multiple contexts instead of nestedwith
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 nestedwith
statementsCombine
with
statements(SIM117)
117-123
: Combinewith
statements.Use a single
with
statement with multiple contexts instead of nestedwith
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 nestedwith
statementsCombine
with
statements(SIM117)
125-142
: LGTM!The code changes are approved.
There was a problem hiding this 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
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 incli_args_parser
enhances the CLI's usability by allowing more informative command descriptions.
201-235
: Introduction ofAttachableRuntimeStatsManager
.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)
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,)) | ||
|
There was a problem hiding this comment.
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.
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)
Summary by CodeRabbit
New Features
perf
andstats_man
tools, allowing for output file specification and tool selection.Documentation
phlop
package.phlop
package.Bug Fixes
dump
andload
options in the test cases CLI.Chores