def __init__(self, shell): Configurable.__init__(self, config=shell.config) Magics.__init__(self, shell=shell) # Add ourself to the list of module configurable via %config self.shell.configurables.append(self) self.conn = None
def __init__(self, shell): Configurable.__init__(self, config=shell.config) Magics.__init__(self, shell=shell) self.shell.configurables.append(self) self.connection, self.engine = None, None self.username, self.password, self.account, self.warehouse = None, None, None, None
def __init__(self, shell): # this is same for all magic extensions Configurable.__init__(self, config=shell.config) Magics.__init__(self, shell=shell) # Add ourself to the list of module configurable via %config self.shell.configurables.append(self) self.connection, self.engine = None, None self.username, self.password, self.account = None, None, None
def __init__(self, shell): Configurable.__init__(self, config=shell.config) Magics.__init__(self, shell=shell) # Add ourself to the list of module configurable via %config self.shell.configurables.append(self) self.shell.ex('from gcc import ExecutableRunner')
def __init__(self, shell): """Initialize sql_magic as a magic function; and add shell to configurables Create connection object.""" self.shell = shell self.caller = None self.shell.configurables.append(self) Configurable.__init__(self, config=shell.config) Magics.__init__(self, shell=shell) self.conn = Connection(shell, available_connection_types, no_return_result_exceptions)
def __init__(self, shell): Configurable.__init__(self, config=shell.config) Magics.__init__(self, shell=shell) self._store = [] # Record sequence of SQL invocations shell.user_ns[ '__querylog'] = self._store # publish as notebook variable # Add ourself to the list of module configurable via %config self.shell.configurables.append(self)
def __init__(self, shell): # You must call the parent constructor Configurable.__init__(self, config=shell.config) Magics.__init__(self, shell=shell) self._tempdir = None self._execution_count = 0 # Add ourself to the list of module configurable via %config self.shell.configurables.append(self)
def __init__(self, shell): Configurable.__init__(self, config=shell.config) Magics.__init__(self, shell=shell) MyriaRelation.DefaultConnection = MyriaConnection( rest_url=self.rest_url, execution_url=self.execution_url, timeout=self.timeout) self.shell.configurables.append(self)
def initialize(config: Configurable): ActivateKernelCommand.config = config ActivateKernelCommand.is_kqlmagic_kernel_default = config.kqlmagic_kernel if config.is_magic is True: if config.kqlmagic_kernel: ActivateKernelCommand.execute(True) else: config.set_trait("kqlmagic_kernel", False, force=True) config.observe(ActivateKernelCommand.observe_is_magic, names=["is_magic"])
def __init__(self, shell): # constants Configurable.__init__(self, config=shell.config) Magics.__init__(self, shell=shell) set_logger(Logger()) get_ipython().magic('matplotlib inline') # Add ourself to the list of module configurable via %config self.shell.configurables.append(self)
def test_custom(self): config = Config() config.foo = 'foo' config.bar = 'bar' c1 = Configurable(config=config) c2 = Configurable(config=c1.config) c3 = Configurable(config=c2.config) self.assertEqual(c1.config, config) self.assertEqual(c2.config, config) self.assertEqual(c3.config, config) # Test that copies are not made self.assertTrue(c1.config is config) self.assertTrue(c2.config is config) self.assertTrue(c3.config is config) self.assertTrue(c1.config is c2.config) self.assertTrue(c2.config is c3.config)
def __init__(self, shell, global_ns=None, local_ns=None, is_magic=True): global kql_core_obj if kql_core_obj is None: Configurable.__init__( self, config=(shell.config if shell is not None else None)) # Add ourself to the list of module configurable via %config if shell is not None: shell.configurables.append(self) if is_magic: Magics.__init__(self, shell=shell) else: setattr(self, 'show_init_banner', False) kql_core_obj = kql_core_obj or Kqlmagic_core(global_ns=global_ns, local_ns=local_ns, shell=shell, default_options=self)
def __init__(self, shell, global_ns=None, local_ns=None, is_magic=True) -> None: global kql_core_obj, kql_core_count kql_core_count += 1 if kql_core_obj is None: Configurable.__init__( self, config=(shell.config if shell is not None else None)) self._config_traits = self.traits() self._read_only_config_trait_names = self._get_read_only_config_trait_names( ) self._set_read_only_config_traits(False) # Add ourself to the list of module configurable via %config if shell is not None: shell.configurables.append(self) default_options = self else: default_options = kql_core_obj.default_options if is_magic and is_magics_class and self.is_ipython_extension: Magics.__init__(self, shell=shell) default_options.set_trait("is_magic", True, force=True) else: default_options.set_trait("is_magic", False, force=True) default_options.set_trait("show_init_banner", False, force=True, lock=True) if kql_core_obj is None: kql_core_obj = Kqlmagic_core(global_ns=global_ns, local_ns=local_ns, shell=shell, default_options=self) self._set_read_only_config_traits(True)
def initialize(config:Configurable): AllowPyCommentsBeforeCell.config = config AllowPyCommentsBeforeCell.allow_py_comments_before_cell_default = config.allow_py_comments_before_cell if config.is_magic is True: AllowPyCommentsBeforeCell.allow_py_Comments_before_cell(config.allow_py_comments_before_cell) else: config.set_trait("allow_py_comments_before_cell", False, force=True) config.observe(AllowPyCommentsBeforeCell.observe_allow_py_comments_before_cell, names=["allow_py_comments_before_cell"]) config.observe(AllowPyCommentsBeforeCell.observe_is_magic, names=["is_magic"])
def initialize(config: Configurable): AllowSingleLineCell.config = config AllowSingleLineCell.allow_single_line_cell_default = config.allow_single_line_cell if config.is_magic is True: AllowSingleLineCell.allow_single_line_cell( config.allow_single_line_cell) else: config.set_trait("allow_single_line_cell", False, force=True) config.observe(AllowSingleLineCell.observe_allow_single_line_cell, names=["allow_single_line_cell"]) config.observe(AllowSingleLineCell.observe_is_magic, names=["is_magic"])
def __init__(self, shell): Configurable.__init__(self, config=shell.config) Magics.__init__(self, shell=shell) # Add ourself to the list of module configurable via %config self.shell.configurables.append(self)
def __init__(self, shell): # constants Configurable.__init__(self, config=shell.config) Magics.__init__(self, shell=shell) set_logger(Logger()) get_ipython().magic("matplotlib inline") # Add ourself to the list of module configurable via %config self.shell.configurables.append(self) ip = get_ipython() kql_magic_load_mode = _get_kql_magic_load_mode() if kql_magic_load_mode != "silent": html_str = """<html> <head> <style> .kqlmagic-banner { display: flex; background-color: #d9edf7; } .kqlmagic-banner > div { margin: 10px; padding: 20px; color: #3a87ad; font-size: 13px; } </style> </head> <body> <div class='kqlmagic-banner'> <div><img src='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAH8AAAB9CAIAAAFzEBvZAAAABGdBTUEAALGPC/xhBQAAAAZiS0dEAC8ALABpv+tl0gAAAAlwSFlzAAAOwwAADsMBx2+oZAAAAAd0SU1FB+AHBRQ2KY/vn7UAAAk5SURBVHja7V3bbxxXGT/fuc9tdz22MW7t5KFxyANRrUQ8IPFQqQihSLxERBQhVUU0qDZ1xKVJmiCBuTcpVdMkbUFFRQIJRYrUB4r6CHIRpU1DaQl/AH9BFYsGbO/MOTxMPGz2MjuzO7M7sz7f0+zszJzv+32X8507PP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zKmM7U+07Xc1n/QHto09f69w3O+FY8L9vQN9uSJPcpCdPOhLVOtW1+SjDQoStikoNfqFmvwAtU4m5MMw1C2EENo9jAHtdoNBedGvcpTX0XmfESmlWtAPo4XQ0ZFLCQqgBvqBoUe7549Eu0REu4xgjLVWCABpBIC11gkKoGWDvlK16/9jTox+dB9pQKBbj8GtQFu3OtDfxZQQ0hJw9G6wx/ceBAPVQL/Xicol7EIAAK0RpRRjHBl+jD7GZBfxPqMguIRmPuLNNAa3fwBCCKWUMcY5F0IIITjnse33HYDC5YwzIz7WZxgFYIzJvdS2PVN527rv3HxhmPhQKjXEVJmeBiHYzb9fSVZAhXRQvX4eSsl7H1y9dv38ZDhBxdCPWiiHDi38+a1n95oCStTH6XlO337/CdNBsfn+AJn7RPYkV8D29yAZ9A36Bn1Dk1brjp2G3Oex6BTA2L6JPAZ9Q7lQpvbggHH/o4+2giDY2moGQaiUphQ4Z4RQIQjnLFpTWIblFSVvGw+I/mc+/e2u93/2zFfvu3/Gn3ZrNZtzChAdo4AJuasPs+ilwJzn3NO/7vvMtevnpaRCMAAkBKOUAGDGCEKodT/MaMVor73pDfoD0iMnfpr8wLeeOu7YTErputL33XqjJgSzbSqliLQCgAEmQTFlzPef//lryQ88d+mkY0vblp5nSYtJyaNF6wCIMRIN9VUC/cnZGYwQjDFBSDWbobH9UVMYqhLuDG3yfYO+IYO+Qd+QQd+gb8igb9A36BsaPf0PJmoM1QL6Q/4AAAAASUVORK5CYII='></div> <div> <p>Kusto is a log analytics cloud platform optimized for ad-hoc big data queries. Read more about it here: http://aka.ms/kdocs</p> <p> • kql language reference: Click on 'Help' tab > and Select 'kql referece'<br> • Kqlmagic configuarion: Run in cell '%config kqlmagic'<br> • Kqlmagic syntax: Run in cell '%kql?'<br> • Kqlmagic upgrate syntax: Run 'pip install git+git://github.com/Microsoft/jupyter-Kqlmagic.git --upgrade'<br> </div> </div> </body> </html>""" Display.show_html(html_str) Display.showInfoMessage( """Kqlmagic package is updated frequently. Run pip install Kqlmagic --upgrade to use the latest version.<br>Kqlmagic version: """ + VERSION + """, source: https://github.com/Microsoft/jupyter-Kqlmagic""") # <div><img src='https://az818438.vo.msecnd.net/icons/kusto.png'></div> _override_default_configuration(ip, kql_magic_load_mode) root_path = get_ipython().starting_dir.replace("\\", "/") folder_name = ip.run_line_magic("config", "Kqlmagic.temp_folder_name") showfiles_folder_Full_name = root_path + "/" + folder_name if not os.path.exists(showfiles_folder_Full_name): os.makedirs(showfiles_folder_Full_name) # ipython will removed folder at shutdown or by restart ip.tempdirs.append(showfiles_folder_Full_name) Display.showfiles_base_path = root_path Display.showfiles_folder_name = folder_name Display.notebooks_host = Help_html.notebooks_host = os.getenv( "AZURE_NOTEBOOKS_HOST") app = ip.run_line_magic("config", "Kqlmagic.notebook_app") # add help link add_kql_ref_to_help = ip.run_line_magic( "config", "Kqlmagic.add_kql_ref_to_help") if add_kql_ref_to_help: Help_html.add_menu_item("kql Reference", "http://aka.ms/kdocs", notebook_app=app) if app is None or app != "jupyterlab": display( Javascript( """IPython.notebook.kernel.execute("NOTEBOOK_URL = '" + window.location + "'");""" )) time.sleep(5)
import os from six.moves import configparser try: from traitlets.config.configurable import Configurable except ImportError: from IPython.config.configurable import Configurable from azure.Kqlmagic.parser import Parser from azure.Kqlmagic.kusto_engine import KustoEngine TEST_URI_SCHEMA_NAME = "kusto" TEST_ENGINE = [KustoEngine] empty_config = Configurable() default_options = {'result_var': None} def test_parse_no_kql(): assert Parser.parse("dbname@clustername", empty_config, TEST_ENGINE, {}) == \ {'connection': "dbname@clustername", 'kql': '', 'options': default_options} query1 = "let T = view () { datatable(n:long, name:string)[1,'foo',2,'bar'] }; T" def test_parse_with_kql(): assert Parser.parse("dbname@clustername {}".format(query1),
def test_default(self): c1 = Configurable() c2 = Configurable(config=c1.config) c3 = Configurable(config=c2.config) self.assertEqual(c1.config, c2.config) self.assertEqual(c2.config, c3.config)
def __init__(self, shell): Configurable.__init__(self, config=shell.config) Magics.__init__(self, shell=shell) # Add self to list of modules configurable via %config self.shell.configurables.append(self)
def __init__(self, shell=None): Magics.__init__(self, shell) Configurable.__init__(self, config=shell.config)
def __init__(self, shell): Configurable.__init__(self, config=shell.config) Magics.__init__(self, shell=shell) # Add ourself to the list of module configurable via %config self.shell.configurables.append(self) self._legal_cypher_identifier = re.compile(r'^[A-Za-z0-9#_$]+')
def __init__(self, shell): self.shell = shell self.shell.configurables.append(self) Configurable.__init__(self, config=shell.config) Magics.__init__(self, shell=shell)