Skip to content
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

Debug engine hangs randomly (race condition)? #99

Open
zmbc opened this issue Aug 2, 2024 · 0 comments
Open

Debug engine hangs randomly (race condition)? #99

zmbc opened this issue Aug 2, 2024 · 0 comments

Comments

@zmbc
Copy link

zmbc commented Aug 2, 2024

With a notebook with a single cell that says:

import pandas as pd

for foo in ["bar", "baz"]:
    pd.DataFrame({'foo': [1, 1]}).merge(pd.DataFrame({'foo': [1, 1]}), how="left", on="foo", validate="1:1")

The command papermill ploomber_test.ipynb out.ipynb -k python3 --engine debug frequently (but not always) hangs indefinitely. When I ctrl+c it, I get:

Input Notebook:  ploomber_test.ipynb
Output Notebook: out.ipynb
Executing:   0%|                                                                                                                                                                                                                                                                       | 0/3 [00:00<?, ?cell/s]Executing notebook with kernel: python3
Executing:  33%|█████████████████████████████████████████████████████████████████████████████████████                                                                                                                                                                          | 1/3 [00:01<00:03,  1.94s/cell]Executing:  67%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████                                                                                     | 2/3 [00:30<00:15, 15.37s/cell]

Aborted!
Task exception was never retrieved
future: <Task finished name='Task-8' coro=<PloomberNotebookClient.async_execute_cell() done, defined at ../.venv/lib/python3.11/site-packages/ploomber_engine/client.py:101> exception=CellExecutionError('An error occurred while executing the following cell:\n------------------\nimport pandas as pd\n\nfor foo in ["bar", "baz"]:\n    pd.DataFrame({\'foo\': [1, 1]}).merge(pd.DataFrame({\'foo\': [1, 1]}), how="left", on="foo", validate="1:1")\n------------------\n\n----- stdout -----\n> \x1b[0;32m../.venv/lib/python3.11/site-packages/pandas/core/reshape/merge.py\x1b[0m(1510)\x1b[0;36m_validate\x1b[0;34m()\x1b[0m\n\x1b[0;32m   1508 \x1b[0;31m        \x1b[0;32mif\x1b[0m \x1b[0mvalidate\x1b[0m \x1b[0;32min\x1b[0m \x1b[0;34m[\x1b[0m\x1b[0;34m"one_to_one"\x1b[0m\x1b[0;34m,\x1b[0m \x1b[0;34m"1:1"\x1b[0m\x1b[0;34m]\x1b[0m\x1b[0;34m:\x1b[0m\x1b[0;34m\x1b[0m\x1b[0;34m\x1b[0m\x1b[0m\n\x1b[0m\x1b[0;32m   1509 \x1b[0;31m            \x1b[0;32mif\x1b[0m \x1b[0;32mnot\x1b[0m \x1b[0mleft_unique\x1b[0m \x1b[0;32mand\x1b[0m \x1b[0;32mnot\x1b[0m \x1b[0mright_unique\x1b[0m\x1b[0;34m:\x1b[0m\x1b[0;34m\x1b[0m\x1b[0;34m\x1b[0m\x1b[0m\n\x1b[0m\x1b[0;32m-> 1510 \x1b[0;31m                raise MergeError(\n\x1b[0m\x1b[0;32m   1511 \x1b[0;31m                    \x1b[0;34m"Merge keys are not unique in either left "\x1b[0m\x1b[0;34m\x1b[0m\x1b[0;34m\x1b[0m\x1b[0m\n\x1b[0m\x1b[0;32m   1512 \x1b[0;31m                    \x1b[0;34m"or right dataset; not a one-to-one merge"\x1b[0m\x1b[0;34m\x1b[0m\x1b[0;34m\x1b[0m\x1b[0m\n\x1b[0m\n----- stdout -----\n--KeyboardInterrupt--\n\nKeyboardInterrupt: Interrupted by user\n------------------\n\n\x1b[0;31m---------------------------------------------------------------------------\x1b[0m\n\x1b[0;31mMergeError\x1b[0m                                Traceback (most recent call last)\nCell \x1b[0;32mIn[2], line 4\x1b[0m\n\x1b[1;32m      1\x1b[0m \x1b[38;5;28;01mimport\x1b[39;00m \x1b[38;5;21;01mpandas\x1b[39;00m \x1b[38;5;28;01mas\x1b[39;00m \x1b[38;5;21;01mpd\x1b[39;00m\n\x1b[1;32m      3\x1b[0m \x1b[38;5;28;01mfor\x1b[39;00m foo \x1b[38;5;129;01min\x1b[39;00m [\x1b[38;5;124m"\x1b[39m\x1b[38;5;124mbar\x1b[39m\x1b[38;5;124m"\x1b[39m, \x1b[38;5;124m"\x1b[39m\x1b[38;5;124mbaz\x1b[39m\x1b[38;5;124m"\x1b[39m]:\n\x1b[0;32m----> 4\x1b[0m     \x1b[43mpd\x1b[49m\x1b[38;5;241;43m.\x1b[39;49m\x1b[43mDataFrame\x1b[49m\x1b[43m(\x1b[49m\x1b[43m{\x1b[49m\x1b[38;5;124;43m\'\x1b[39;49m\x1b[38;5;124;43mfoo\x1b[39;49m\x1b[38;5;124;43m\'\x1b[39;49m\x1b[43m:\x1b[49m\x1b[43m \x1b[49m\x1b[43m[\x1b[49m\x1b[38;5;241;43m1\x1b[39;49m\x1b[43m,\x1b[49m\x1b[43m \x1b[49m\x1b[38;5;241;43m1\x1b[39;49m\x1b[43m]\x1b[49m\x1b[43m}\x1b[49m\x1b[43m)\x1b[49m\x1b[38;5;241;43m.\x1b[39;49m\x1b[43mmerge\x1b[49m\x1b[43m(\x1b[49m\x1b[43mpd\x1b[49m\x1b[38;5;241;43m.\x1b[39;49m\x1b[43mDataFrame\x1b[49m\x1b[43m(\x1b[49m\x1b[43m{\x1b[49m\x1b[38;5;124;43m\'\x1b[39;49m\x1b[38;5;124;43mfoo\x1b[39;49m\x1b[38;5;124;43m\'\x1b[39;49m\x1b[43m:\x1b[49m\x1b[43m \x1b[49m\x1b[43m[\x1b[49m\x1b[38;5;241;43m1\x1b[39;49m\x1b[43m,\x1b[49m\x1b[43m \x1b[49m\x1b[38;5;241;43m1\x1b[39;49m\x1b[43m]\x1b[49m\x1b[43m}\x1b[49m\x1b[43m)\x1b[49m\x1b[43m,\x1b[49m\x1b[43m \x1b[49m\x1b[43mhow\x1b[49m\x1b[38;5;241;43m=\x1b[39;49m\x1b[38;5;124;43m"\x1b[39;49m\x1b[38;5;124;43mleft\x1b[39;49m\x1b[38;5;124;43m"\x1b[39;49m\x1b[43m,\x1b[49m\x1b[43m \x1b[49m\x1b[43mon\x1b[49m\x1b[38;5;241;43m=\x1b[39;49m\x1b[38;5;124;43m"\x1b[39;49m\x1b[38;5;124;43mfoo\x1b[39;49m\x1b[38;5;124;43m"\x1b[39;49m\x1b[43m,\x1b[49m\x1b[43m \x1b[49m\x1b[43mvalidate\x1b[49m\x1b[38;5;241;43m=\x1b[39;49m\x1b[38;5;124;43m"\x1b[39;49m\x1b[38;5;124;43m1:1\x1b[39;49m\x1b[38;5;124;43m"\x1b[39;49m\x1b[43m)\x1b[49m\n\nFile \x1b[0;32m../.venv/lib/python3.11/site-packages/pandas/core/frame.py:10093\x1b[0m, in \x1b[0;36mDataFrame.merge\x1b[0;34m(self, right, how, on, left_on, right_on, left_index, right_index, sort, suffixes, copy, indicator, validate)\x1b[0m\n\x1b[1;32m  10074\x1b[0m \x1b[38;5;129m@Substitution\x1b[39m(\x1b[38;5;124m"\x1b[39m\x1b[38;5;124m"\x1b[39m)\n\x1b[1;32m  10075\x1b[0m \x1b[38;5;129m@Appender\x1b[39m(_merge_doc, indents\x1b[38;5;241m=\x1b[39m\x1b[38;5;241m2\x1b[39m)\n\x1b[1;32m  10076\x1b[0m \x1b[38;5;28;01mdef\x1b[39;00m \x1b[38;5;21mmerge\x1b[39m(\n\x1b[0;32m   (...)\x1b[0m\n\x1b[1;32m  10089\x1b[0m     validate: \x1b[38;5;28mstr\x1b[39m \x1b[38;5;241m|\x1b[39m \x1b[38;5;28;01mNone\x1b[39;00m \x1b[38;5;241m=\x1b[39m \x1b[38;5;28;01mNone\x1b[39;00m,\n\x1b[1;32m  10090\x1b[0m ) \x1b[38;5;241m-\x1b[39m\x1b[38;5;241m>\x1b[39m DataFrame:\n\x1b[1;32m  10091\x1b[0m     \x1b[38;5;28;01mfrom\x1b[39;00m \x1b[38;5;21;01mpandas\x1b[39;00m\x1b[38;5;21;01m.\x1b[39;00m\x1b[38;5;21;01mcore\x1b[39;00m\x1b[38;5;21;01m.\x1b[39;00m\x1b[38;5;21;01mreshape\x1b[39;00m\x1b[38;5;21;01m.\x1b[39;00m\x1b[38;5;21;01mmerge\x1b[39;00m \x1b[38;5;28;01mimport\x1b[39;00m merge\n\x1b[0;32m> 10093\x1b[0m     \x1b[38;5;28;01mreturn\x1b[39;00m \x1b[43mmerge\x1b[49m\x1b[43m(\x1b[49m\n\x1b[1;32m  10094\x1b[0m \x1b[43m        \x1b[49m\x1b[38;5;28;43mself\x1b[39;49m\x1b[43m,\x1b[49m\n\x1b[1;32m  10095\x1b[0m \x1b[43m        \x1b[49m\x1b[43mright\x1b[49m\x1b[43m,\x1b[49m\n\x1b[1;32m  10096\x1b[0m \x1b[43m        \x1b[49m\x1b[43mhow\x1b[49m\x1b[38;5;241;43m=\x1b[39;49m\x1b[43mhow\x1b[49m\x1b[43m,\x1b[49m\n\x1b[1;32m  10097\x1b[0m \x1b[43m        \x1b[49m\x1b[43mon\x1b[49m\x1b[38;5;241;43m=\x1b[39;49m\x1b[43mon\x1b[49m\x1b[43m,\x1b[49m\n\x1b[1;32m  10098\x1b[0m \x1b[43m        \x1b[49m\x1b[43mleft_on\x1b[49m\x1b[38;5;241;43m=\x1b[39;49m\x1b[43mleft_on\x1b[49m\x1b[43m,\x1b[49m\n\x1b[1;32m  10099\x1b[0m \x1b[43m        \x1b[49m\x1b[43mright_on\x1b[49m\x1b[38;5;241;43m=\x1b[39;49m\x1b[43mright_on\x1b[49m\x1b[43m,\x1b[49m\n\x1b[1;32m  10100\x1b[0m \x1b[43m        \x1b[49m\x1b[43mleft_index\x1b[49m\x1b[38;5;241;43m=\x1b[39;49m\x1b[43mleft_index\x1b[49m\x1b[43m,\x1b[49m\n\x1b[1;32m  10101\x1b[0m \x1b[43m        \x1b[49m\x1b[43mright_index\x1b[49m\x1b[38;5;241;43m=\x1b[39;49m\x1b[43mright_index\x1b[49m\x1b[43m,\x1b[49m\n\x1b[1;32m  10102\x1b[0m \x1b[43m        \x1b[49m\x1b[43msort\x1b[49m\x1b[38;5;241;43m=\x1b[39;49m\x1b[43msort\x1b[49m\x1b[43m,\x1b[49m\n\x1b[1;32m  10103\x1b[0m \x1b[43m        \x1b[49m\x1b[43msuffixes\x1b[49m\x1b[38;5;241;43m=\x1b[39;49m\x1b[43msuffixes\x1b[49m\x1b[43m,\x1b[49m\n\x1b[1;32m  10104\x1b[0m \x1b[43m        \x1b[49m\x1b[43mcopy\x1b[49m\x1b[38;5;241;43m=\x1b[39;49m\x1b[43mcopy\x1b[49m\x1b[43m,\x1b[49m\n\x1b[1;32m  10105\x1b[0m \x1b[43m        \x1b[49m\x1b[43mindicator\x1b[49m\x1b[38;5;241;43m=\x1b[39;49m\x1b[43mindicator\x1b[49m\x1b[43m,\x1b[49m\n\x1b[1;32m  10106\x1b[0m \x1b[43m        \x1b[49m\x1b[43mvalidate\x1b[49m\x1b[38;5;241;43m=\x1b[39;49m\x1b[43mvalidate\x1b[49m\x1b[43m,\x1b[49m\n\x1b[1;32m  10107\x1b[0m \x1b[43m    \x1b[49m\x1b[43m)\x1b[49m\n\nFile \x1b[0;32m../.venv/lib/python3.11/site-packages/pandas/core/reshape/merge.py:110\x1b[0m, in \x1b[0;36mmerge\x1b[0;34m(left, right, how, on, left_on, right_on, left_index, right_index, sort, suffixes, copy, indicator, validate)\x1b[0m\n\x1b[1;32m     93\x1b[0m \x1b[38;5;129m@Substitution\x1b[39m(\x1b[38;5;124m"\x1b[39m\x1b[38;5;130;01m\\n\x1b[39;00m\x1b[38;5;124mleft : DataFrame or named Series\x1b[39m\x1b[38;5;124m"\x1b[39m)\n\x1b[1;32m     94\x1b[0m \x1b[38;5;129m@Appender\x1b[39m(_merge_doc, indents\x1b[38;5;241m=\x1b[39m\x1b[38;5;241m0\x1b[39m)\n\x1b[1;32m     95\x1b[0m \x1b[38;5;28;01mdef\x1b[39;00m \x1b[38;5;21mmerge\x1b[39m(\n\x1b[0;32m   (...)\x1b[0m\n\x1b[1;32m    108\x1b[0m     validate: \x1b[38;5;28mstr\x1b[39m \x1b[38;5;241m|\x1b[39m \x1b[38;5;28;01mNone\x1b[39;00m \x1b[38;5;241m=\x1b[39m \x1b[38;5;28;01mNone\x1b[39;00m,\n\x1b[1;32m    109\x1b[0m ) \x1b[38;5;241m-\x1b[39m\x1b[38;5;241m>\x1b[39m DataFrame:\n\x1b[0;32m--> 110\x1b[0m     op \x1b[38;5;241m=\x1b[39m \x1b[43m_MergeOperation\x1b[49m\x1b[43m(\x1b[49m\n\x1b[1;32m    111\x1b[0m \x1b[43m        \x1b[49m\x1b[43mleft\x1b[49m\x1b[43m,\x1b[49m\n\x1b[1;32m    112\x1b[0m \x1b[43m        \x1b[49m\x1b[43mright\x1b[49m\x1b[43m,\x1b[49m\n\x1b[1;32m    113\x1b[0m \x1b[43m        \x1b[49m\x1b[43mhow\x1b[49m\x1b[38;5;241;43m=\x1b[39;49m\x1b[43mhow\x1b[49m\x1b[43m,\x1b[49m\n\x1b[1;32m    114\x1b[0m \x1b[43m        \x1b[49m\x1b[43mon\x1b[49m\x1b[38;5;241;43m=\x1b[39;49m\x1b[43mon\x1b[49m\x1b[43m,\x1b[49m\n\x1b[1;32m    115\x1b[0m \x1b[43m        \x1b[49m\x1b[43mleft_on\x1b[49m\x1b[38;5;241;43m=\x1b[39;49m\x1b[43mleft_on\x1b[49m\x1b[43m,\x1b[49m\n\x1b[1;32m    116\x1b[0m \x1b[43m        \x1b[49m\x1b[43mright_on\x1b[49m\x1b[38;5;241;43m=\x1b[39;49m\x1b[43mright_on\x1b[49m\x1b[43m,\x1b[49m\n\x1b[1;32m    117\x1b[0m \x1b[43m        \x1b[49m\x1b[43mleft_index\x1b[49m\x1b[38;5;241;43m=\x1b[39;49m\x1b[43mleft_index\x1b[49m\x1b[43m,\x1b[49m\n\x1b[1;32m    118\x1b[0m \x1b[43m        \x1b[49m\x1b[43mright_index\x1b[49m\x1b[38;5;241;43m=\x1b[39;49m\x1b[43mright_index\x1b[49m\x1b[43m,\x1b[49m\n\x1b[1;32m    119\x1b[0m \x1b[43m        \x1b[49m\x1b[43msort\x1b[49m\x1b[38;5;241;43m=\x1b[39;49m\x1b[43msort\x1b[49m\x1b[43m,\x1b[49m\n\x1b[1;32m    120\x1b[0m \x1b[43m        \x1b[49m\x1b[43msuffixes\x1b[49m\x1b[38;5;241;43m=\x1b[39;49m\x1b[43msuffixes\x1b[49m\x1b[43m,\x1b[49m\n\x1b[1;32m    121\x1b[0m \x1b[43m        \x1b[49m\x1b[43mindicator\x1b[49m\x1b[38;5;241;43m=\x1b[39;49m\x1b[43mindicator\x1b[49m\x1b[43m,\x1b[49m\n\x1b[1;32m    122\x1b[0m \x1b[43m        \x1b[49m\x1b[43mvalidate\x1b[49m\x1b[38;5;241;43m=\x1b[39;49m\x1b[43mvalidate\x1b[49m\x1b[43m,\x1b[49m\n\x1b[1;32m    123\x1b[0m \x1b[43m    \x1b[49m\x1b[43m)\x1b[49m\n\x1b[1;32m    124\x1b[0m     \x1b[38;5;28;01mreturn\x1b[39;00m op\x1b[38;5;241m.\x1b[39mget_result(copy\x1b[38;5;241m=\x1b[39mcopy)\n\nFile \x1b[0;32m../.venv/lib/python3.11/site-packages/pandas/core/reshape/merge.py:713\x1b[0m, in \x1b[0;36m_MergeOperation.__init__\x1b[0;34m(self, left, right, how, on, left_on, right_on, axis, left_index, right_index, sort, suffixes, indicator, validate)\x1b[0m\n\x1b[1;32m    709\x1b[0m \x1b[38;5;66;03m# If argument passed to validate,\x1b[39;00m\n\x1b[1;32m    710\x1b[0m \x1b[38;5;66;03m# check if columns specified as unique\x1b[39;00m\n\x1b[1;32m    711\x1b[0m \x1b[38;5;66;03m# are in fact unique.\x1b[39;00m\n\x1b[1;32m    712\x1b[0m \x1b[38;5;28;01mif\x1b[39;00m validate \x1b[38;5;129;01mis\x1b[39;00m \x1b[38;5;129;01mnot\x1b[39;00m \x1b[38;5;28;01mNone\x1b[39;00m:\n\x1b[0;32m--> 713\x1b[0m     \x1b[38;5;28;43mself\x1b[39;49m\x1b[38;5;241;43m.\x1b[39;49m\x1b[43m_validate\x1b[49m\x1b[43m(\x1b[49m\x1b[43mvalidate\x1b[49m\x1b[43m)\x1b[49m\n\nFile \x1b[0;32m../.venv/lib/python3.11/site-packages/pandas/core/reshape/merge.py:1510\x1b[0m, in \x1b[0;36m_MergeOperation._validate\x1b[0;34m(self, validate)\x1b[0m\n\x1b[1;32m   1508\x1b[0m \x1b[38;5;28;01mif\x1b[39;00m validate \x1b[38;5;129;01min\x1b[39;00m [\x1b[38;5;124m"\x1b[39m\x1b[38;5;124mone_to_one\x1b[39m\x1b[38;5;124m"\x1b[39m, \x1b[38;5;124m"\x1b[39m\x1b[38;5;124m1:1\x1b[39m\x1b[38;5;124m"\x1b[39m]:\n\x1b[1;32m   1509\x1b[0m     \x1b[38;5;28;01mif\x1b[39;00m \x1b[38;5;129;01mnot\x1b[39;00m left_unique \x1b[38;5;129;01mand\x1b[39;00m \x1b[38;5;129;01mnot\x1b[39;00m right_unique:\n\x1b[0;32m-> 1510\x1b[0m         \x1b[38;5;28;01mraise\x1b[39;00m MergeError(\n\x1b[1;32m   1511\x1b[0m             \x1b[38;5;124m"\x1b[39m\x1b[38;5;124mMerge keys are not unique in either left \x1b[39m\x1b[38;5;124m"\x1b[39m\n\x1b[1;32m   1512\x1b[0m             \x1b[38;5;124m"\x1b[39m\x1b[38;5;124mor right dataset; not a one-to-one merge\x1b[39m\x1b[38;5;124m"\x1b[39m\n\x1b[1;32m   1513\x1b[0m         )\n\x1b[1;32m   1514\x1b[0m     \x1b[38;5;28;01melif\x1b[39;00m \x1b[38;5;129;01mnot\x1b[39;00m left_unique:\n\x1b[1;32m   1515\x1b[0m         \x1b[38;5;28;01mraise\x1b[39;00m MergeError(\n\x1b[1;32m   1516\x1b[0m             \x1b[38;5;124m"\x1b[39m\x1b[38;5;124mMerge keys are not unique in left dataset; not a one-to-one merge\x1b[39m\x1b[38;5;124m"\x1b[39m\n\x1b[1;32m   1517\x1b[0m         )\n\n\x1b[0;31mMergeError\x1b[0m: Merge keys are not unique in either left or right dataset; not a one-to-one merge\n')>
Traceback (most recent call last):
  File "../.venv/lib/python3.11/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "../.venv/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "../.venv/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "../.venv/lib/python3.11/site-packages/click/decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "../.venv/lib/python3.11/site-packages/papermill/cli.py", line 235, in papermill
    execute_notebook(
  File "../.venv/lib/python3.11/site-packages/papermill/execute.py", line 116, in execute_notebook
    nb = papermill_engines.execute_notebook_with_engine(
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "../.venv/lib/python3.11/site-packages/papermill/engines.py", line 48, in execute_notebook_with_engine
    return self.get_engine(engine_name).execute_notebook(nb, kernel_name, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "../.venv/lib/python3.11/site-packages/papermill/engines.py", line 370, in execute_notebook
    cls.execute_managed_notebook(nb_man, kernel_name, log_output=log_output, **kwargs)
  File "../.venv/lib/python3.11/site-packages/ploomber_core/telemetry/telemetry.py", line 700, in wrapper
    result = func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^
  File "../.venv/lib/python3.11/site-packages/ploomber_engine/engine.py", line 53, in execute_managed_notebook
    return PapermillPloomberNotebookClient(nb_man, **final_kwargs).execute()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "../.venv/lib/python3.11/site-packages/papermill/clientwrap.py", line 45, in execute
    self.papermill_execute_cells()
  File "../.venv/lib/python3.11/site-packages/ploomber_engine/papermill.py", line 30, in papermill_execute_cells
    self.execute_cell(cell, index)
  File "../.venv/lib/python3.11/site-packages/jupyter_core/utils/__init__.py", line 165, in wrapped
    return loop.run_until_complete(inner)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "../.conda_env/lib/python3.11/asyncio/base_events.py", line 641, in run_until_complete
    self.run_forever()
  File "../.conda_env/lib/python3.11/asyncio/base_events.py", line 608, in run_forever
    self._run_once()
  File "../.conda_env/lib/python3.11/asyncio/base_events.py", line 1898, in _run_once
    event_list = self._selector.select(timeout)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "../.conda_env/lib/python3.11/selectors.py", line 468, in select
    fd_event_list = self._selector.poll(timeout, max_ev)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
KeyboardInterrupt

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "../.venv/lib/python3.11/site-packages/ploomber_engine/client.py", line 227, in async_execute_cell
    await self._check_raise_for_error(cell, cell_index, exec_reply)
  File "../.venv/lib/python3.11/site-packages/nbclient/client.py", line 918, in _check_raise_for_error
    raise CellExecutionError.from_cell_and_msg(cell, exec_reply_content)
nbclient.exceptions.CellExecutionError: An error occurred while executing the following cell:
------------------
import pandas as pd

for foo in ["bar", "baz"]:
    pd.DataFrame({'foo': [1, 1]}).merge(pd.DataFrame({'foo': [1, 1]}), how="left", on="foo", validate="1:1")
------------------

----- stdout -----
> ../.venv/lib/python3.11/site-packages/pandas/core/reshape/merge.py(1510)_validate()
   1508         if validate in ["one_to_one", "1:1"]:
   1509             if not left_unique and not right_unique:
-> 1510                 raise MergeError(
   1511                     "Merge keys are not unique in either left "
   1512                     "or right dataset; not a one-to-one merge"

----- stdout -----
--KeyboardInterrupt--

KeyboardInterrupt: Interrupted by user
------------------

---------------------------------------------------------------------------
MergeError                                Traceback (most recent call last)
Cell In[2], line 4
      1 import pandas as pd
      3 for foo in ["bar", "baz"]:
----> 4     pd.DataFrame({'foo': [1, 1]}).merge(pd.DataFrame({'foo': [1, 1]}), how="left", on="foo", validate="1:1")

File ../.venv/lib/python3.11/site-packages/pandas/core/frame.py:10093, in DataFrame.merge(self, right, how, on, left_on, right_on, left_index, right_index, sort, suffixes, copy, indicator, validate)
  10074 @Substitution("")
  10075 @Appender(_merge_doc, indents=2)
  10076 def merge(
   (...)
  10089     validate: str | None = None,
  10090 ) -> DataFrame:
  10091     from pandas.core.reshape.merge import merge
> 10093     return merge(
  10094         self,
  10095         right,
  10096         how=how,
  10097         on=on,
  10098         left_on=left_on,
  10099         right_on=right_on,
  10100         left_index=left_index,
  10101         right_index=right_index,
  10102         sort=sort,
  10103         suffixes=suffixes,
  10104         copy=copy,
  10105         indicator=indicator,
  10106         validate=validate,
  10107     )

File ../.venv/lib/python3.11/site-packages/pandas/core/reshape/merge.py:110, in merge(left, right, how, on, left_on, right_on, left_index, right_index, sort, suffixes, copy, indicator, validate)
     93 @Substitution("\nleft : DataFrame or named Series")
     94 @Appender(_merge_doc, indents=0)
     95 def merge(
   (...)
    108     validate: str | None = None,
    109 ) -> DataFrame:
--> 110     op = _MergeOperation(
    111         left,
    112         right,
    113         how=how,
    114         on=on,
    115         left_on=left_on,
    116         right_on=right_on,
    117         left_index=left_index,
    118         right_index=right_index,
    119         sort=sort,
    120         suffixes=suffixes,
    121         indicator=indicator,
    122         validate=validate,
    123     )
    124     return op.get_result(copy=copy)

File ../.venv/lib/python3.11/site-packages/pandas/core/reshape/merge.py:713, in _MergeOperation.__init__(self, left, right, how, on, left_on, right_on, axis, left_index, right_index, sort, suffixes, indicator, validate)
    709 # If argument passed to validate,
    710 # check if columns specified as unique
    711 # are in fact unique.
    712 if validate is not None:
--> 713     self._validate(validate)

File ../.venv/lib/python3.11/site-packages/pandas/core/reshape/merge.py:1510, in _MergeOperation._validate(self, validate)
   1508 if validate in ["one_to_one", "1:1"]:
   1509     if not left_unique and not right_unique:
-> 1510         raise MergeError(
   1511             "Merge keys are not unique in either left "
   1512             "or right dataset; not a one-to-one merge"
   1513         )
   1514     elif not left_unique:
   1515         raise MergeError(
   1516             "Merge keys are not unique in left dataset; not a one-to-one merge"
   1517         )

MergeError: Merge keys are not unique in either left or right dataset; not a one-to-one merge

To summarize: the MergeError I'm hoping to debug has already occurred, but somehow Python is stuck elsewhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant