-
Notifications
You must be signed in to change notification settings - Fork 368
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
Added --aggregate option to attach #455
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #455 +/- ##
==========================================
+ Coverage 91.88% 91.90% +0.01%
==========================================
Files 90 91 +1
Lines 10766 10803 +37
Branches 1473 1485 +12
==========================================
+ Hits 9892 9928 +36
- Misses 872 873 +1
Partials 2 2
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
src/memray/commands/attach.py
Outdated
if args.aggregate and not hasattr(args, "output"): | ||
parser.error("Can't use aggregated mode without an output 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.
This parser.error()
never fires, because hasattr(args, "output")
is always True
.
Sometimes the attribute is None
, but it always exists. If it didn't, we'd get an AttributeError
on this line above:
memray/src/memray/commands/attach.py
Line 332 in 2751eb4
if args.output: |
We should add a unit test that exercises this case, too, so that we're not introducing a new, uncovered line of code.
src/memray/commands/attach.py
Outdated
file_format = ( | ||
f"file_format={FileFormat.AGGREGATED_ALLOCATIONS}" if args.aggregate else "" | ||
) |
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.
Oooh, this is interesting. This winds up passing file_format=1
, because:
>>> FileFormat.AGGREGATED_ALLOCATIONS
<FileFormat.AGGREGATED_ALLOCATIONS: 1>
>>> f"file_format={FileFormat.AGGREGATED_ALLOCATIONS}"
'file_format=1'
I'm surprised that works. I think it would be more robust to do:
file_format = (
"file_format=memray.FileFormat.AGGREGATED_ALLOCATIONS" if args.aggregate else ""
)
I'd rather pass around the enum by name than by value, in case a future version of the API changes the value associated with the enum, or changes the Tracker
constructor to reject ints and only accept enum members.
I'd like to see an integration test that exercises this, too - that should be as easy as parametrizing our current attach
test with a new flag for whether or not to use aggregated mode, passing --aggregate
in the attach_cmd
when the flag is set, and asserting that get_allocation_records()
fails when --aggregate
was passed but succeeds when it wasn't, and that get_high_watermark_allocation_records()
works in both cases.
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.
As we discussed offline I've modified the integration tests a bit, but otherwise this looks great to me! I'm going to squash and land this.
5a2cdef
to
d4b6d7b
Compare
Add --aggregate option which allows user to request aggregated mode for in-memory aggregation. Signed-off-by: Ivona Stojanovic <istojanovic2@bloomberg.net>
d4b6d7b
to
689b8c3
Compare
Added --aggregate option which allows user to request aggregated mode for in-memory aggregation.
Issue number of the reported bug or feature request: #
Describe your changes
A clear and concise description of the changes you have made.
Testing performed
Describe the testing you have performed to ensure that the bug has been addressed, or that the new feature works as planned.
Additional context
Add any other context about your contribution here.