plasma-umass / scalene

Scalene: a high-performance, high-precision CPU, GPU, and memory profiler for Python with AI-powered optimization proposals
Apache License 2.0
12.16k stars 399 forks source link

Running pytest on Charcoal-SE/Smokedetector under scalene fails #863

Open micsthepick opened 1 month ago

micsthepick commented 1 month ago

Describe the bug Pytest cannot run due to below error(s):

============================================================================================== test session starts ==============================================================================================
platform linux -- Python 3.8.19, pytest-8.3.2, pluggy-1.5.0
rootdir: /home/mike/sources/SmokeDetector
plugins: xdist-3.6.1, timeout-2.3.1, cov-5.0.0
timeout: 300.0s
timeout method: signal
timeout func_only: False
created: 3/3 workersScalene: could not find input file /home/mike/sources/SmokeDetector/-u
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/home/mike/.local/lib/python3.8/site-packages/_pytest/main.py", line 281, in wrap_session
INTERNALERROR>     config.hook.pytest_sessionstart(session=session)
INTERNALERROR>   File "/home/mike/.local/lib/python3.8/site-packages/pluggy/_hooks.py", line 513, in __call__
INTERNALERROR>     return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
INTERNALERROR>   File "/home/mike/.local/lib/python3.8/site-packages/pluggy/_manager.py", line 120, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR>   File "/home/mike/.local/lib/python3.8/site-packages/pluggy/_callers.py", line 139, in _multicall
INTERNALERROR>     raise exception.with_traceback(exception.__traceback__)
INTERNALERROR>   File "/home/mike/.local/lib/python3.8/site-packages/pluggy/_callers.py", line 122, in _multicall
INTERNALERROR>     teardown.throw(exception)  # type: ignore[union-attr]
INTERNALERROR>   File "/home/mike/.local/lib/python3.8/site-packages/_pytest/logging.py", line 784, in pytest_sessionstart
INTERNALERROR>     return (yield)
INTERNALERROR>   File "/home/mike/.local/lib/python3.8/site-packages/pluggy/_callers.py", line 103, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/home/mike/.local/lib/python3.8/site-packages/xdist/dsession.py", line 90, in pytest_sessionstart
INTERNALERROR>     nodes = self.nodemanager.setup_nodes(putevent=self.queue.put)
INTERNALERROR>   File "/home/mike/.local/lib/python3.8/site-packages/xdist/workermanage.py", line 88, in setup_nodes
INTERNALERROR>     return [self.setup_node(spec, putevent) for spec in self.specs]
INTERNALERROR>   File "/home/mike/.local/lib/python3.8/site-packages/xdist/workermanage.py", line 88, in <listcomp>
INTERNALERROR>     return [self.setup_node(spec, putevent) for spec in self.specs]
INTERNALERROR>   File "/home/mike/.local/lib/python3.8/site-packages/xdist/workermanage.py", line 97, in setup_node
INTERNALERROR>     gw = self.group.makegateway(spec)
INTERNALERROR>   File "/home/mike/.local/lib/python3.8/site-packages/execnet/multi.py", line 154, in makegateway
INTERNALERROR>     gw = gateway_bootstrap.bootstrap(io, spec)
INTERNALERROR>   File "/home/mike/.local/lib/python3.8/site-packages/execnet/gateway_bootstrap.py", line 88, in bootstrap
INTERNALERROR>     bootstrap_import(io, spec)
INTERNALERROR>   File "/home/mike/.local/lib/python3.8/site-packages/execnet/gateway_bootstrap.py", line 36, in bootstrap_import
INTERNALERROR>     s = io.read(1)
INTERNALERROR>   File "/home/mike/.local/lib/python3.8/site-packages/execnet/gateway_base.py", line 536, in read
INTERNALERROR>     raise EOFError("expected %d bytes, got %d" % (numbytes, len(buf)))
INTERNALERROR> EOFError: expected 1 bytes, got 0

To Reproduce Steps to reproduce the behavior: (tested in WSL2) - Setup a conda env with scalene, clone github.com:charcoal-se/smokedetector.git, pip install -r requirements.txt, and run the following command (modified from a CI yaml) scalene --profile-all -m pytest -W default::Warning --cov=chatcommunicate --cov=findspam --cov=globalvars --cov=spamhandling --cov=datahandling --cov=chatcommands --cov=helpers -n 3 --dist loadgroup --timeout=300 test

Please include a minimum working example if at all possible.

Expected behavior Runs like as if I'd replaced scalene --profile-all with just python.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

If you have not yet tried with the repository version (python3 -m pip install git+https://github.com/plasma-umass/scalene), please try that before reporting. (sidenote this may be more helpful at the top of the issue template) - replicates with latest.

Additional context SmokeDetector can take a while to clone (not too long), so if you think that this might be solvable without cloning it, I'd certainly recommend investigating that way.

micsthepick commented 1 month ago

possibly related: #82

micsthepick commented 1 month ago

... and what makes me think so, is the error from scalene:

Scalene: could not find input file /home/mike/sources/SmokeDetector/-u

emeryberger commented 1 month ago

Can you try putting --- after the Scalene flag(s) and before pytest?

micsthepick commented 1 month ago

@emeryberger still reproduces with the following: scalene --profile-all --- -m pytest -W default::Warning --cov=chatcommunicate --cov=findspam --cov=globalvars --cov=spamhandling --cov=datahandling --cov=chatcomm ands --cov=helpers -n 3 --dist loadgroup --timeout=300 test

micsthepick commented 1 month ago

just in case I needed to put -m pytest before the ---, the following doesn't work either:

scalene --profile-all -m pytest --- -W default::Warning --cov=chatcommunicate --cov=findspam --cov=globalvars --cov=spamhandling --cov=datahandling --cov=chatcomm
ands --cov=helpers -n 3 --dist loadgroup --timeout=300 test