microsoft / jupyter-Kqlmagic

Extension (Magic) to Jupyter notebook and Jupyter lab, that enable notebook experience working with Kusto, ApplicationInsights, and LogAnalytics data.
Other
85 stars 31 forks source link

Python 3.10.0 breaks Kqlmagic dependency (AttributeError: module 'collections' has no attribute 'Iterator' exception) #79

Closed AlenaMarchuk closed 2 years ago

AlenaMarchuk commented 3 years ago

When jupyter notebook's python kernel got automatically updated to 3.10.0 version (from 3.9.7), the update broke Kqlmagic dependency. Exception gets thrown on this command: %reload_ext Kqlmagic

Full exception trace:


AttributeError Traceback (most recent call last) /tmp/ipykernel_6965/107116530.py in 1 # Connect to Kusto using cached az cli creds if they exist 2 get_ipython().run_line_magic('env', 'KQLMAGIC_LOAD_MODE=silent') ----> 3 get_ipython().run_line_magic('reload_ext', 'Kqlmagic') 4 get_ipython().run_line_magic('kql', "AzureDataExplorer://code;cluster='VSO';database='VSO' -try_vscode_login")

/workspaces/c2c-actions-abuse/.venv/lib/python3.10/site-packages/IPython/core/interactiveshell.py in run_line_magic(self, magic_name, line, _stack_depth) 2349 kwargs['local_ns'] = self.get_local_scope(stack_depth) 2350 with self.builtin_trap: -> 2351 result = fn(*args, **kwargs) 2352 return result 2353

/workspaces/c2c-actions-abuse/.venv/lib/python3.10/site-packages/decorator.py in fun(*args, *kw) 230 if not kwsyntax: 231 args, kw = fix(args, kw, sig) --> 232 return caller(func, (extras + args), **kw) 233 fun.name = func.name 234 fun.doc = func.doc

/workspaces/c2c-actions-abuse/.venv/lib/python3.10/site-packages/IPython/core/magic.py in (f, *a, k) 185 # but it's overkill for just that one bit of state. 186 def magic_deco(arg): --> 187 call = lambda f, *a, *k: f(a, k) 188 189 if callable(arg):

/workspaces/c2c-actions-abuse/.venv/lib/python3.10/site-packages/IPython/core/magics/extension.py in reload_ext(self, module_str) 61 if not module_str: 62 raise UsageError('Missing module name.') ---> 63 self.shell.extension_manager.reload_extension(module_str)

/workspaces/c2c-actions-abuse/.venv/lib/python3.10/site-packages/IPython/core/extensions.py in reload_extension(self, module_str) 128 self.loaded.add(module_str) 129 else: --> 130 self.load_extension(module_str) 131 132 def _call_load_ipython_extension(self, mod):

/workspaces/c2c-actions-abuse/.venv/lib/python3.10/site-packages/IPython/core/extensions.py in load_extension(self, module_str) 78 if module_str not in sys.modules: 79 with prepended_to_syspath(self.ipython_extension_dir): ---> 80 mod = import_module(module_str) 81 if mod.file.startswith(self.ipython_extension_dir): 82 print(("Loading extensions from {dir} is deprecated. "

/usr/local/lib/python3.10/importlib/init.py in import_module(name, package) 124 break 125 level += 1 --> 126 return _bootstrap._gcd_import(name[level:], package, level) 127 128

/usr/local/lib/python3.10/importlib/_bootstrap.py in _gcd_import(name, package, level)

/usr/local/lib/python3.10/importlib/_bootstrap.py in _find_andload(name, import)

/usr/local/lib/python3.10/importlib/_bootstrap.py in _find_and_loadunlocked(name, import)

/usr/local/lib/python3.10/importlib/_bootstrap.py in _load_unlocked(spec)

/usr/local/lib/python3.10/importlib/_bootstrap_external.py in exec_module(self, module)

/usr/local/lib/python3.10/importlib/_bootstrap.py in _call_with_frames_removed(f, *args, **kwds)

/workspaces/c2c-actions-abuse/.venv/lib/python3.10/site-packages/Kqlmagic/init.py in 12 pass 13 ---> 14 from .magic_extension import load_ipython_extension, unload_ipython_extension 15 from .version import version 16 from .kql_magic import kql, kql_stop

/workspaces/c2c-actions-abuse/.venv/lib/python3.10/site-packages/Kqlmagic/magic_extension.py in 7 from .constants import Constants 8 from .log import logger ----> 9 from .kql_magic import Kqlmagic 10 11

/workspaces/c2c-actions-abuse/.venv/lib/python3.10/site-packages/Kqlmagic/kql_magic.py in 24 from .ipython_api import IPythonAPI 25 ---> 26 from .kql_magic_core import Kqlmagic_core 27 from .constants import Constants, Cloud 28 from .palette import Palettes, Palette

/workspaces/c2c-actions-abuse/.venv/lib/python3.10/site-packages/Kqlmagic/kql_magic_core.py in 24 25 from .ipython_api import IPythonAPI ---> 26 from .sso_storage import clear_sso_store 27 from ._version import version 28 from .version import get_pypi_latest_version, is_stable_version, pre_version_label, compare_version, execute_version_command, validate_required_python_version_running

/workspaces/c2c-actions-abuse/.venv/lib/python3.10/site-packages/Kqlmagic/sso_storage.py in 11 12 ---> 13 from .parser import Parser 14 from .display import Display 15 from .ipython_api import IPythonAPI

/workspaces/c2c-actions-abuse/.venv/lib/python3.10/site-packages/Kqlmagic/parser.py in 19 from .constants import Constants, Schema 20 from .my_utils import split_lex, adjust_path, is_env_var, get_env_var, is_collection, strip_if_quoted ---> 21 from .engine import Engine 22 23

/workspaces/c2c-actions-abuse/.venv/lib/python3.10/site-packages/Kqlmagic/engine.py in 8 9 ---> 10 from .kql_response import KqlQueryResponse, KqlSchemaResponse 11 from .kql_proxy import KqlResponse 12 from .kql_client import KqlClient

/workspaces/c2c-actions-abuse/.venv/lib/python3.10/site-packages/Kqlmagic/kql_response.py in 49 50 ---> 51 class KqlResponseTable(collections.Iterator): 52 """ Iterator over returned rows """ 53

AttributeError: module 'collections' has no attribute 'Iterator'

Also attaching an image with exception in IDE. There's a 'Runtime dependency of PyGObject is missing.' error as well, but it's a non-blocking error, please ignore. Screen Shot 2021-10-28 at 3 42 13 PM

David-Noble-at-work commented 3 years ago

I wanted to note that I hit the same issue and hope that it is assigned and addressed soon.

mbnshtck commented 3 years ago

Please once you fail, execute ‘%kql –bugreport’ And send me the output

mbnshtck commented 3 years ago

send the bug report directly to my email: michabin@microsoft.com

mbnshtck commented 3 years ago

Python 3.10 is currently not supported. Please use older version of Python. If you MUST use Python 3.10, please let me know, and I will see how I can help you.

mbnshtck commented 2 years ago

Fixed in 0.1.114.post8