prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Error when importing MindsDB in a Jupyter notebook
  **Your Environment**
  
  * Python version: 3.6
  * Operating system: Ubuntu
  * Mindsdb version: 2.12.2
  
  **Describe the bug**
  Importing MindsDB from a Jupyter Notebook fails, apparently because the HTTP API triggers.
  
  **To Reproduce**
  1. Run a new Jupyter notebook
  2. Execute a cell with `import mindsdb`
  
  The following error should occur:
  ```usage: ipykernel_launcher.py [-h] [--api API] [--config CONFIG] [--verbose] [-v]
  ipykernel_launcher.py: error: unrecognized arguments: -f /home/user/.local/share/jupyter/runtime/kernel.json
  
  An exception has occurred, use %tb to see the full traceback.
  SystemExit: 2
  
  /env/lib/python3.6/site-packages/IPython/core/interactiveshell.py:3351: UserWarning: To exit: use 'exit', 'quit', or Ctrl-D.
    warn("To exit: use 'exit', 'quit', or Ctrl-D.", stacklevel=1)
  ```
  
  **Expected behavior**
  MindsDB should import successfully.
  
  **Additional note**
  `import mindsdb_native` works fine.
  
  </issue>
  <code>
  [start of mindsdb/utilities/functions.py]
  1 import argparse
  2 import datetime
  3 import requests
  4 from functools import wraps
  5 
  6 from mindsdb.utilities.fs import create_process_mark, delete_process_mark
  7 
  8 
  9 def args_parse():
  10     parser = argparse.ArgumentParser(description='CL argument for mindsdb server')
  11     parser.add_argument('--api', type=str, default=None)
  12     parser.add_argument('--config', type=str, default=None)
  13     parser.add_argument('--verbose', action='store_true')
  14     parser.add_argument('--no_studio', action='store_true')
  15     parser.add_argument('-v', '--version', action='store_true')
  16     parser.add_argument('--ray', action='store_true', default=None)
  17     return parser.parse_args()
  18 
  19 
  20 def cast_row_types(row, field_types):
  21     '''
  22     '''
  23     keys = [x for x in row.keys() if x in field_types]
  24     for key in keys:
  25         t = field_types[key]
  26         if t == 'Timestamp' and isinstance(row[key], (int, float)):
  27             timestamp = datetime.datetime.utcfromtimestamp(row[key])
  28             row[key] = timestamp.strftime('%Y-%m-%d %H:%M:%S')
  29         elif t == 'Date' and isinstance(row[key], (int, float)):
  30             timestamp = datetime.datetime.utcfromtimestamp(row[key])
  31             row[key] = timestamp.strftime('%Y-%m-%d')
  32         elif t == 'Int' and isinstance(row[key], (int, float, str)):
  33             try:
  34                 print(f'cast {row[key]} to {int(row[key])}')
  35                 row[key] = int(row[key])
  36             except Exception:
  37                 pass
  38 
  39 
  40 def is_notebook():
  41     try:
  42         shell = get_ipython().__class__.__name__
  43         if shell == 'ZMQInteractiveShell':
  44             return True   # Jupyter notebook or qtconsole
  45         elif shell == 'TerminalInteractiveShell':
  46             return False  # Terminal running IPython
  47         else:
  48             return False  # Other type (?)
  49     except NameError:
  50         return False      # Probably standard Python interpreter
  51 
  52 
  53 def mark_process(name):
  54     def mark_process_wrapper(func):
  55         @wraps(func)
  56         def wrapper(*args, **kwargs):
  57             mark = create_process_mark(name)
  58             try:
  59                 return func(*args, **kwargs)
  60             finally:
  61                 delete_process_mark(name, mark)
  62         return wrapper
  63     return mark_process_wrapper
  64 
  65 
  66 def get_versions_where_predictors_become_obsolete():
  67     """ Get list of MindsDB versions in which predictors should be retrained
  68         Returns:
  69             list of str or False
  70     """
  71     versions_for_updating_predictors = []
  72     try:
  73         try:
  74             res = requests.get(
  75                 'https://mindsdb-cloud-public-service-files.s3.us-east-2.amazonaws.com/version_for_updating_predictors.txt',
  76                 timeout=0.5
  77             )
  78         except (ConnectionError, requests.exceptions.ConnectionError) as e:
  79             print(f'Is no connection. {e}')
  80             raise
  81         except Exception as e:
  82             print(f'Is something wrong with getting version_for_updating_predictors.txt: {e}')
  83             raise
  84 
  85         if res.status_code != 200:
  86             print(f'Cant get version_for_updating_predictors.txt: returned status code = {res.status_code}')
  87             raise
  88 
  89         try:
  90             versions_for_updating_predictors = res.text.replace(' \t\r', '').split('\n')
  91         except Exception as e:
  92             print(f'Cant decode compatible-config.json: {e}')
  93             raise
  94     except Exception:
  95         return False, versions_for_updating_predictors
  96 
  97     versions_for_updating_predictors = [x for x in versions_for_updating_predictors if len(x) > 0]
  98     return True, versions_for_updating_predictors
  99
  [end of mindsdb/utilities/functions.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/mindsdb/utilities/functions.py b/mindsdb/utilities/functions.py
  --- a/mindsdb/utilities/functions.py
  +++ b/mindsdb/utilities/functions.py
  @@ -39,13 +39,10 @@
   
   def is_notebook():
       try:
  -        shell = get_ipython().__class__.__name__
  -        if shell == 'ZMQInteractiveShell':
  -            return True   # Jupyter notebook or qtconsole
  -        elif shell == 'TerminalInteractiveShell':
  -            return False  # Terminal running IPython
  +        if 'IPKernelApp' in get_ipython().config:
  +            return True
           else:
  -            return False  # Other type (?)
  +            return False
       except NameError:
           return False      # Probably standard Python interpreter
  
verification_info: {"golden_diff": "diff --git a/mindsdb/utilities/functions.py b/mindsdb/utilities/functions.py\n--- a/mindsdb/utilities/functions.py\n+++ b/mindsdb/utilities/functions.py\n@@ -39,13 +39,10 @@\n \n def is_notebook():\n     try:\n-        shell = get_ipython().__class__.__name__\n-        if shell == 'ZMQInteractiveShell':\n-            return True   # Jupyter notebook or qtconsole\n-        elif shell == 'TerminalInteractiveShell':\n-            return False  # Terminal running IPython\n+        if 'IPKernelApp' in get_ipython().config:\n+            return True\n         else:\n-            return False  # Other type (?)\n+            return False\n     except NameError:\n         return False      # Probably standard Python interpreter\n", "issue": "Error when importing MindsDB in a Jupyter notebook\n**Your Environment**\r\n\r\n* Python version: 3.6\r\n* Operating system: Ubuntu\r\n* Mindsdb version: 2.12.2\r\n\r\n**Describe the bug**\r\nImporting MindsDB from a Jupyter Notebook fails, apparently because the HTTP API triggers.\r\n\r\n**To Reproduce**\r\n1. Run a new Jupyter notebook\r\n2. Execute a cell with `import mindsdb`\r\n\r\nThe following error should occur:\r\n```usage: ipykernel_launcher.py [-h] [--api API] [--config CONFIG] [--verbose] [-v]\r\nipykernel_launcher.py: error: unrecognized arguments: -f /home/user/.local/share/jupyter/runtime/kernel.json\r\n\r\nAn exception has occurred, use %tb to see the full traceback.\r\nSystemExit: 2\r\n\r\n/env/lib/python3.6/site-packages/IPython/core/interactiveshell.py:3351: UserWarning: To exit: use 'exit', 'quit', or Ctrl-D.\r\n  warn(\"To exit: use 'exit', 'quit', or Ctrl-D.\", stacklevel=1)\r\n```\r\n\r\n**Expected behavior**\r\nMindsDB should import successfully.\r\n\r\n**Additional note**\r\n`import mindsdb_native` works fine.\n", "before_files": [{"content": "import argparse\nimport datetime\nimport requests\nfrom functools import wraps\n\nfrom mindsdb.utilities.fs import create_process_mark, delete_process_mark\n\n\ndef args_parse():\n    parser = argparse.ArgumentParser(description='CL argument for mindsdb server')\n    parser.add_argument('--api', type=str, default=None)\n    parser.add_argument('--config', type=str, default=None)\n    parser.add_argument('--verbose', action='store_true')\n    parser.add_argument('--no_studio', action='store_true')\n    parser.add_argument('-v', '--version', action='store_true')\n    parser.add_argument('--ray', action='store_true', default=None)\n    return parser.parse_args()\n\n\ndef cast_row_types(row, field_types):\n    '''\n    '''\n    keys = [x for x in row.keys() if x in field_types]\n    for key in keys:\n        t = field_types[key]\n        if t == 'Timestamp' and isinstance(row[key], (int, float)):\n            timestamp = datetime.datetime.utcfromtimestamp(row[key])\n            row[key] = timestamp.strftime('%Y-%m-%d %H:%M:%S')\n        elif t == 'Date' and isinstance(row[key], (int, float)):\n            timestamp = datetime.datetime.utcfromtimestamp(row[key])\n            row[key] = timestamp.strftime('%Y-%m-%d')\n        elif t == 'Int' and isinstance(row[key], (int, float, str)):\n            try:\n                print(f'cast {row[key]} to {int(row[key])}')\n                row[key] = int(row[key])\n            except Exception:\n                pass\n\n\ndef is_notebook():\n    try:\n        shell = get_ipython().__class__.__name__\n        if shell == 'ZMQInteractiveShell':\n            return True   # Jupyter notebook or qtconsole\n        elif shell == 'TerminalInteractiveShell':\n            return False  # Terminal running IPython\n        else:\n            return False  # Other type (?)\n    except NameError:\n        return False      # Probably standard Python interpreter\n\n\ndef mark_process(name):\n    def mark_process_wrapper(func):\n        @wraps(func)\n        def wrapper(*args, **kwargs):\n            mark = create_process_mark(name)\n            try:\n                return func(*args, **kwargs)\n            finally:\n                delete_process_mark(name, mark)\n        return wrapper\n    return mark_process_wrapper\n\n\ndef get_versions_where_predictors_become_obsolete():\n    \"\"\" Get list of MindsDB versions in which predictors should be retrained\n        Returns:\n            list of str or False\n    \"\"\"\n    versions_for_updating_predictors = []\n    try:\n        try:\n            res = requests.get(\n                'https://mindsdb-cloud-public-service-files.s3.us-east-2.amazonaws.com/version_for_updating_predictors.txt',\n                timeout=0.5\n            )\n        except (ConnectionError, requests.exceptions.ConnectionError) as e:\n            print(f'Is no connection. {e}')\n            raise\n        except Exception as e:\n            print(f'Is something wrong with getting version_for_updating_predictors.txt: {e}')\n            raise\n\n        if res.status_code != 200:\n            print(f'Cant get version_for_updating_predictors.txt: returned status code = {res.status_code}')\n            raise\n\n        try:\n            versions_for_updating_predictors = res.text.replace(' \\t\\r', '').split('\\n')\n        except Exception as e:\n            print(f'Cant decode compatible-config.json: {e}')\n            raise\n    except Exception:\n        return False, versions_for_updating_predictors\n\n    versions_for_updating_predictors = [x for x in versions_for_updating_predictors if len(x) > 0]\n    return True, versions_for_updating_predictors\n", "path": "mindsdb/utilities/functions.py"}]}