pcdsutils.profile add_function call can be noisy
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2
- Forks
- 6
- Avg merge
- 7d 11h
- Merged PRs (30d)
- 1
Description
Issue
Can result in hundreds of warnings when used with wrapped functions/methods:
happi/tests/test_cli.py: 48 warnings
/opt/hostedtoolcache/Python/3.11.4/x64/lib/python3.11/site-packages/pcdsutils/profile.py:156: UserWarning: Adding a function with a __wrapped__ attribute. You may want to profile the wrapped function by adding happi_cfg_abs.__wrapped__ instead.
profiler_to_setup.add_function(function)
We should probably use warning capturing to ignore this specific warning (memory is probably faulty regarding UserWarning and the ability to ignore it so I won't suggest a full fix here)
Alternatively, we can heed the warning and profile the inner function by default. I'm not sold that it's the correct way of doing things, though.
Reference
The warning comes from here: https://github.com/pyutils/line_profiler/blob/c48f643e0fd44335705bfb48fe78995c72ecd858/line_profiler/_line_profiler.pyx#L211-L217
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Inspect pcdsutils/profile.py around line 156 and the warning source referenced in line_profiler. Reproduce the noisy warning using the scenario shown from happi/tests/test_cli.py, then verify that profiling wrapped functions no longer emits repeated instances of this specific warning.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100