-
Notifications
You must be signed in to change notification settings - Fork 32
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
Infrastructure for memory usage tests #299
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #299 +/- ##
==========================================
+ Coverage 86.21% 86.30% +0.09%
==========================================
Files 47 49 +2
Lines 8812 8870 +58
==========================================
+ Hits 7597 7655 +58
Misses 1215 1215 ☔ View full report in Codecov by Sentry. |
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.
Since the parent ticket JP-3775 is for building out infrastructure for tests like this, what do you think about building out that infrastructure and using it here? Something like:
with memory_threshold(expected_mem):
computer = MedianComputer...
I can understand that the infrastructure is beyond the scope of this PR but I think an argument can be made that building the infrastructure first (before this PR) makes sense since:
- this is a useful test for the infrastructure
- if we merge this PR first a follow-up PR will modify this test again when we have the new infrastructure
I completely agree. I'll work on making a context manager that is called like you show |
@braingram I added the context manager and a fixture that calls it. I wasn't sure exactly how to structure this, because based on what I read it's not great practice to import from conftest.py directly. Let me know if the proposed helper.py and conftest.py look right to you. Also, do you think it's necessary/useful to add infrastructure for testing the fixture itself like in this StackOverflow answer? |
Since the fixture isn't needed for this test I'd say we leave it out of this PR. The class you added in |
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.
Thanks! LGTM.
status update: @penaguerrero is using this to write a test for the jump step, and in so doing is evaluating this PR. So this is awaiting her review |
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.
I tried the code in writing a test for jwst, and it works as intended. Other than suggesting to allow to present the result in other units I have no further comments. LGTM
5de32a3
to
0d5e58b
Compare
@penaguerrero can you test the units option I added and see if it covers your use-case? |
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.
I just tested again with the changes. It works as expected. LGTM!
This PR adds a context manager to more easily check the peak memory usage of a code block and raise an error if a memory limit is exceeded. A unit test of the memory usage in the median calculation in outlier detection provides an example use-case.
Relates to JP-3775 but only fixes one small part of that ticket.
Tasks
docs/
pageno-changelog-entry-needed
)changes/
:echo "changed something" > changes/<PR#>.<changetype>.rst
(see below for change types)"git+https://github.com/<fork>/stcal@<branch>"
)jwst
regression testromancal
regression testnews fragment change types...
changes/<PR#>.apichange.rst
: change to public APIchanges/<PR#>.bugfix.rst
: fixes an issuechanges/<PR#>.general.rst
: infrastructure or miscellaneous change