-
Notifications
You must be signed in to change notification settings - Fork 473
Open
Description
It happens rarely - but sometimes py-spy will produce stack traces where a single frame is incorrect. Here, instead of the usual form function (path:line number)
, a doctoring is somehow inserted.
I have pasted an example below case below.
It's not a big issue - usually rerunning the profiler will give clean stack traces again. But I'm curious what could be happening here.
This is on py-spy 0.4.0 and MacOs.
process 43739:"/opt/local/Library/Frameworks/Python.framework/Versions/3.10/Resources/Python.app/Contents/MacOS/Python /path/to/file/bloqade-circuit/test/qasm2/emit/test_qasm2.py";<module> (/path/to/file/bloqade-circuit/test/qasm2/emit/test_qasm2.py:1);_handle_fromlist (<frozen importlib._bootstrap>:1078);_call_with_frames_removed (<frozen importlib._bootstrap>:241);_find_and_load (<frozen importlib._bootstrap>:1027);_find_and_load_unlocked (<frozen importlib._bootstrap>:1006);_load_unlocked (<frozen importlib._bootstrap>:688);exec_module (<frozen importlib._bootstrap_external>:883);_call_with_frames_removed (<frozen importlib._bootstrap>:241);<module> (/path/to/file/bloqade-circuit/src/bloqade/qasm2/__init__.py:3);_handle_fromlist (<frozen importlib._bootstrap>:1078);_call_with_frames_removed (<frozen importlib._bootstrap>:241);_find_and_load (<frozen importlib._bootstrap>:1027);_find_and_load_unlocked (<frozen importlib._bootstrap>:1006);_load_unlocked (<frozen importlib._bootstrap>:688);exec_module (<frozen importlib._bootstrap_external>:883);_call_with_frames_removed (<frozen importlib._bootstrap>:241);<module> (/path/to/file/bloqade-circuit/src/bloqade/qasm2/emit/__init__.py:1);_find_and_load (<frozen importlib._bootstrap>:1027);_find_and_load_unlocked (<frozen importlib._bootstrap>:1006);_load_unlocked (<frozen importlib._bootstrap>:688);exec_module (<frozen importlib._bootstrap_external>:883);_call_with_frames_removed (<frozen importlib._bootstrap>:241);<module> (/path/to/file/bloqade-circuit/src/bloqade/qasm2/emit/target.py:9);_find_and_load (<frozen importlib._bootstrap>:1027);_find_and_load_unlocked (<frozen importlib._bootstrap>:992);_call_with_frames_removed (<frozen importlib._bootstrap>:241);_find_and_load (<frozen importlib._bootstrap>:1027);_find_and_load_unlocked (<frozen importlib._bootstrap>:1006);_load_unlocked (<frozen importlib._bootstrap>:688);exec_module (<frozen importlib._bootstrap_external>:883);_call_with_frames_removed (<frozen importlib._bootstrap>:241);<module> (/path/to/file/bloqade-circuit/src/bloqade/qasm2/passes/__init__.py:1);_find_and_load (<frozen importlib._bootstrap>:1027);_find_and_load_unlocked (<frozen importlib._bootstrap>:1006);_load_unlocked (<frozen importlib._bootstrap>:688);exec_module (<frozen importlib._bootstrap_external>:883);_call_with_frames_removed (<frozen importlib._bootstrap>:241);<module> (/path/to/file/bloqade-circuit/src/bloqade/qasm2/passes/fold.py:24);_find_and_load (<frozen importlib._bootstrap>:1027);_find_and_load_unlocked (<frozen importlib._bootstrap>:1006);_load_unlocked (<frozen importlib._bootstrap>:688);exec_module (<frozen importlib._bootstrap_external>:883);_call_with_frames_removed (<frozen importlib._bootstrap>:241);<module> (/path/to/file/bloqade-circuit/src/bloqade/qasm2/dialects/__init__.py:1);_handle_fromlist (<frozen importlib._bootstrap>:1078);_call_with_frames_removed (<frozen importlib._bootstrap>:241);_find_and_load (<frozen importlib._bootstrap>:1027);_find_and_load_unlocked (<frozen importlib._bootstrap>:1006);_load_unlocked (<frozen importlib._bootstrap>:688);exec_module (<frozen importlib._bootstrap_external>:883);_call_with_frames_removed (<frozen importlib._bootstrap>:241);<module> (/path/to/file/bloqade-circuit/src/bloqade/qasm2/dialects/uop/__init__.py:1);_handle_fromlist (<frozen importlib._bootstrap>:1078);_call_with_frames_removed (<frozen importlib._bootstrap>:241);_find_and_load (<frozen importlib._bootstrap>:1027);_find_and_load_unlocked (<frozen importlib._bootstrap>:1006);_load_unlocked (<frozen importlib._bootstrap>:688);exec_module (<frozen importlib._bootstrap_external>:883);_call_with_frames_removed (<frozen importlib._bootstrap>:241);<module> (/path/to/file/bloqade-circuit/src/bloqade/qasm2/dialects/uop/schedule.py:4);_find_and_load (<frozen importlib._bootstrap>:1027);_find_and_load_unlocked (<frozen importlib._bootstrap>:992);_call_with_frames_removed (<frozen importlib._bootstrap>:241);_find_and_load (<frozen importlib._bootstrap>:1027);_find_and_load_unlocked (<frozen importlib._bootstrap>:992);_call_with_frames_removed (<frozen importlib._bootstrap>:241);_find_and_load (<frozen importlib._bootstrap>:1027);_find_and_load_unlocked (<frozen importlib._bootstrap>:1006);_load_unlocked (<frozen importlib._bootstrap>:688);exec_module (<frozen importlib._bootstrap_external>:883);_call_with_frames_removed (<frozen importlib._bootstrap>:241);<module> (/path/to/file/bloqade-circuit/src/bloqade/squin/__init__.py:13);_find_and_load (<frozen importlib._bootstrap>:1027);_find_and_load_unlocked (<frozen importlib._bootstrap>:1006);_load_unlocked (<frozen importlib._bootstrap>:688);exec_module (<frozen importlib._bootstrap_external>:883);_call_with_frames_removed (<frozen importlib._bootstrap>:241);<module> (/path/to/file/bloqade-circuit/.venv/lib/python3.10/site-packages/cirq/__init__.py:19);_find_and_load (<frozen importlib._bootstrap>:1027);_find_and_load_unlocked (<frozen importlib._bootstrap>:1006);_load_unlocked (<frozen importlib._bootstrap>:688);exec_module (<frozen importlib._bootstrap_external>:883);_call_with_frames_removed (<frozen importlib._bootstrap>:241);<module> (/path/to/file/bloqade-circuit/.venv/lib/python3.10/site-packages/cirq/_compat.py:31);_find_and_load (<frozen importlib._bootstrap>:1027);_find_and_load_unlocked (<frozen importlib._bootstrap>:1006);_load_unlocked (<frozen importlib._bootstrap>:688);exec_module (<frozen importlib._bootstrap_external>:883);_call_with_frames_removed (<frozen importlib._bootstrap>:241);<module> (/path/to/file/bloqade-circuit/.venv/lib/python3.10/site-packages/pandas/__init__.py:49);_find_and_load (<frozen importlib._bootstrap>:1027);_find_and_load_unlocked (<frozen importlib._bootstrap>:1006);_load_unlocked (<frozen importlib._bootstrap>:688);exec_module (<frozen importlib._bootstrap_external>:883);_call_with_frames_removed (<frozen importlib._bootstrap>:241);<module> (/path/to/file/bloqade-circuit/.venv/lib/python3.10/site-packages/pandas/core/api.py:47);_find_and_load (<frozen importlib._bootstrap>:1027);_find_and_load_unlocked (<frozen importlib._bootstrap>:1006);_load_unlocked (<frozen importlib._bootstrap>:688);exec_module (<frozen importlib._bootstrap_external>:883);_call_with_frames_removed (<frozen importlib._bootstrap>:241);<module> (/path/to/file/bloqade-circuit/.venv/lib/python3.10/site-packages/pandas/core/groupby/__init__.py:1);_find_and_load (<frozen importlib._bootstrap>:1027);_find_and_load_unlocked (<frozen importlib._bootstrap>:1006);_load_unlocked (<frozen importlib._bootstrap>:688);exec_module (<frozen importlib._bootstrap_external>:883);_call_with_frames_removed (<frozen importlib._bootstrap>:241);<module> (/path/to/file/bloqade-circuit/.venv/lib/python3.10/site-packages/pandas/core/groupby/generic.py:73);_find_and_load (<frozen importlib._bootstrap>:1027);_find_and_load_unlocked (<frozen importlib._bootstrap>:1006);_load_unlocked (<frozen importlib._bootstrap>:688);exec_module (<frozen importlib._bootstrap_external>:883);_call_with_frames_removed (<frozen importlib._bootstrap>:241);<module> (/path/to/file/bloqade-circuit/.venv/lib/python3.10/site-packages/pandas/core/groupby/groupby.py:764);_find_and_load (<frozen importlib._bootstrap>:1024);_find_and_load_unlocked (<frozen importlib._bootstrap>:1016);_load_unlocked (<frozen importlib._bootstrap>:703);exec_module (<frozen importlib._bootstrap_external>:883);_call_with_frames_removed (<frozen importlib._bootstrap>:241);
>>> s = pd.Series([0, 1, 2], index='a a b'.split())
>>> g1 = s.groupby(s.index, group_keys=False)
>>> g2 = s.groupby(s.index, group_keys=True)
From ``s`` above we can see that ``g`` has two groups, ``a`` and ``b``.
Notice that ``g1`` have ``g2`` have two groups, ``a`` and ``b``, and only
differ in their ``group_keys`` argument. Calling `apply` in various ways,
we can get different grouping results:
Example 1: The function passed to `apply` takes a Series as
its argument and returns a Series. `apply` combines the result for
each group together into a new Series.
.. versionchanged:: 1.3.0
The resulting dtype will reflect the return value of the passed ``func``.
>>> g1.apply(lambda x: x * 2 if x.name == 'a' else x / 2)
a 0.0
a 2.0
b 1.0
dtype: float64
In the above, the groups are not part of the index. We can have them included
by using ``g2`` where ``group_keys=True``:
>>> g2.apply(lambda x: x * 2 if x.name == 'a' else x / 2)
a a 0.0
a 2.0
b b 1.0
dtype: float64
Example 2: The function passed to `apply` takes a Series as
its argument and returns a scalar. `apply` combines the result for
each group together into a Series, including setting the index as
appropriate:
>>> g1.apply(lambda x: x.max() - x.min())
a 1
b 0
dtype: int64
The ``group_keys`` argument has no effect here because the result is not
like-indexed (i.e. :ref:`a transform <groupby.transform>`) when compared
to the input.
>>> g2.apply(lambda x: x.max() - x.min())
a 1
b 0
dtype: int64 (series_examples);decorator (/path/to/file/bloqade-circuit/.venv/lib/python3.10/site-packages/pandas/util/_decorators.py:399);<listcomp> (/path/to/file/bloqade-circuit/.venv/lib/python3.10/site-packages/pandas/util/_decorators.py:387);dedent (/opt/local/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/textwrap.py:470);sub (/opt/local/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/re.py:209) 1
process 43739:"/opt/local/Library/Frameworks/Python.framework/Versions/3.10/Resources/Python.app/Contents/MacOS/Python /path/to/file/bloqade-circuit/test/qasm2/emit/test_qasm2.py";<module> (/path/to/file/bloqade-circuit/test/qasm2/emit/test_qasm2.py:34);__call__ (/path/to/file/bloqade-circuit/.venv/lib/python3.10/site-packages/kirin/ir/group.py:233);wrapper (/path/to/file/bloqade-circuit/.venv/lib/python3.10/site-packages/kirin/ir/group.py:226);run_pass (/path/to/file/bloqade-circuit/src/bloqade/qasm2/groups.py:110);fixpoint (/path/to/file/bloqade-circuit/.venv/lib/python3.10/site-packages/kirin/passes/abc.py:37);unsafe_run (/path/to/file/bloqade-circuit/.venv/lib/python3.10/site-packages/kirin/passes/fold.py:29);unsafe_run (/path/to/file/bloqade-circuit/.venv/lib/python3.10/site-packages/kirin/passes/hint_const.py:15);run_analysis (/path/to/file/bloqade-circuit/.venv/lib/python3.10/site-packages/kirin/analysis/forward.py:66);run_method (/path/to/file/bloqade-circuit/.venv/lib/python3.10/site-packages/kirin/analysis/const/prop.py:120);run_callable (/path/to/file/bloqade-circuit/.venv/lib/python3.10/site-packages/kirin/interp/base.py:228);run_callable_region (/path/to/file/bloqade-circuit/.venv/lib/python3.10/site-packages/kirin/interp/base.py:246);run_ssacfg_region (/path/to/file/bloqade-circuit/.venv/lib/python3.10/site-packages/kirin/interp/abstract.py:161);run_succ (/path/to/file/bloqade-circuit/.venv/lib/python3.10/site-packages/kirin/interp/abstract.py:189);eval_stmt (/path/to/file/bloqade-circuit/.venv/lib/python3.10/site-packages/kirin/analysis/const/prop.py:106);__call__ (/path/to/file/bloqade-circuit/.venv/lib/python3.10/site-packages/kirin/registry.py:25);for_loop (/path/to/file/bloqade-circuit/.venv/lib/python3.10/site-packages/kirin/dialects/scf/constprop.py:99);_prop_const_iterable_forloop (/path/to/file/bloqade-circuit/.venv/lib/python3.10/site-packages/kirin/dialects/scf/constprop.py:120);run_ssacfg_region (/path/to/file/bloqade-circuit/.venv/lib/python3.10/site-packages/kirin/interp/abstract.py:161);run_succ (/path/to/file/bloqade-circuit/.venv/lib/python3.10/site-packages/kirin/interp/abstract.py:195);eval_stmt (/path/to/file/bloqade-circuit/.venv/lib/python3.10/site-packages/kirin/analysis/const/prop.py:89);has_trait (/path/to/file/bloqade-circuit/.venv/lib/python3.10/site-packages/kirin/ir/nodes/stmt.py:682);__instancecheck__ (/opt/local/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/abc.py:119) 1
Metadata
Metadata
Assignees
Labels
No labels