<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Error when setting up OAuth profile for Databricks CLI in Get Started Discussions</title>
    <link>https://community.databricks.com/t5/get-started-discussions/error-when-setting-up-oauth-profile-for-databricks-cli/m-p/59916#M2536</link>
    <description>&lt;P&gt;Hello.&lt;/P&gt;&lt;P&gt;I'm currently trying to migrate a project from dbx to Databricks Asset Bundles. I have successfully created the required profile using U2M authentication with the command&lt;/P&gt;&lt;P&gt;```databricks auth login --host &amp;lt;host-name&amp;gt;```&lt;/P&gt;&lt;P&gt;I'm able to see the new profile adb-6779217299298465 when running&lt;/P&gt;&lt;P&gt;```databricks auth profiles```&lt;/P&gt;&lt;P&gt;but in column "Valid" I get no.&lt;/P&gt;&lt;P&gt;Moreover, when running databricks auth env I get the following error message:&lt;/P&gt;&lt;P&gt;Error: default auth: metadata-service: token request: Get "&lt;A href="http://127.0.0.1:63292/2448a16f-6491-48cb-b618-c183df2c89dc" target="_blank"&gt;http://127.0.0.1:63292/2448a16f-6491-48cb-b618-c183df2c89dc&lt;/A&gt;": dial tcp 127.0.0.1:63292: connect: connection refused. Config: host=&lt;A href="https://adb-6779217299298465.5.azuredatabricks.net" target="_blank"&gt;https://adb-6779217299298465.5.azuredatabricks.net&lt;/A&gt;, cluster_id=0323-081844-qaifark7, metadata_service_url=***, profile=DEFAULT. Env: DATABRICKS_HOST, DATABRICKS_CLUSTER_ID, DATABRICKS_METADATA_SERVICE_URL&lt;/P&gt;&lt;P&gt;Can someone tell me what I'm doing wrong.&lt;/P&gt;&lt;P&gt;I'm running Databricks CLI version 0.212.4&lt;/P&gt;&lt;P&gt;Kind regards&lt;/P&gt;</description>
    <pubDate>Mon, 12 Feb 2024 11:47:16 GMT</pubDate>
    <dc:creator>BLPedersen</dc:creator>
    <dc:date>2024-02-12T11:47:16Z</dc:date>
    <item>
      <title>Error when setting up OAuth profile for Databricks CLI</title>
      <link>https://community.databricks.com/t5/get-started-discussions/error-when-setting-up-oauth-profile-for-databricks-cli/m-p/59916#M2536</link>
      <description>&lt;P&gt;Hello.&lt;/P&gt;&lt;P&gt;I'm currently trying to migrate a project from dbx to Databricks Asset Bundles. I have successfully created the required profile using U2M authentication with the command&lt;/P&gt;&lt;P&gt;```databricks auth login --host &amp;lt;host-name&amp;gt;```&lt;/P&gt;&lt;P&gt;I'm able to see the new profile adb-6779217299298465 when running&lt;/P&gt;&lt;P&gt;```databricks auth profiles```&lt;/P&gt;&lt;P&gt;but in column "Valid" I get no.&lt;/P&gt;&lt;P&gt;Moreover, when running databricks auth env I get the following error message:&lt;/P&gt;&lt;P&gt;Error: default auth: metadata-service: token request: Get "&lt;A href="http://127.0.0.1:63292/2448a16f-6491-48cb-b618-c183df2c89dc" target="_blank"&gt;http://127.0.0.1:63292/2448a16f-6491-48cb-b618-c183df2c89dc&lt;/A&gt;": dial tcp 127.0.0.1:63292: connect: connection refused. Config: host=&lt;A href="https://adb-6779217299298465.5.azuredatabricks.net" target="_blank"&gt;https://adb-6779217299298465.5.azuredatabricks.net&lt;/A&gt;, cluster_id=0323-081844-qaifark7, metadata_service_url=***, profile=DEFAULT. Env: DATABRICKS_HOST, DATABRICKS_CLUSTER_ID, DATABRICKS_METADATA_SERVICE_URL&lt;/P&gt;&lt;P&gt;Can someone tell me what I'm doing wrong.&lt;/P&gt;&lt;P&gt;I'm running Databricks CLI version 0.212.4&lt;/P&gt;&lt;P&gt;Kind regards&lt;/P&gt;</description>
      <pubDate>Mon, 12 Feb 2024 11:47:16 GMT</pubDate>
      <guid>https://community.databricks.com/t5/get-started-discussions/error-when-setting-up-oauth-profile-for-databricks-cli/m-p/59916#M2536</guid>
      <dc:creator>BLPedersen</dc:creator>
      <dc:date>2024-02-12T11:47:16Z</dc:date>
    </item>
    <item>
      <title>Re: Error when setting up OAuth profile for Databricks CLI</title>
      <link>https://community.databricks.com/t5/get-started-discussions/error-when-setting-up-oauth-profile-for-databricks-cli/m-p/60298#M2563</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/61288"&gt;@BLPedersen&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This looks like a known issue where&amp;nbsp;&lt;SPAN&gt;environment variables are not updated properly by VS Code in the terminal.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Can you please check the metadata_service url in the&amp;nbsp;Databricks configuration file and the&amp;nbsp;metadata_service_url from .databricks.env file.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Replace the metadata_service_url in databricks cfg file with metadata_service_url from .databricks.env file of a directory from visual studio code.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Let me know if that helps.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Regards&lt;BR /&gt;Allia&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Feb 2024 09:30:10 GMT</pubDate>
      <guid>https://community.databricks.com/t5/get-started-discussions/error-when-setting-up-oauth-profile-for-databricks-cli/m-p/60298#M2563</guid>
      <dc:creator>Allia</dc:creator>
      <dc:date>2024-02-15T09:30:10Z</dc:date>
    </item>
    <item>
      <title>Re: Error when setting up OAuth profile for Databricks CLI</title>
      <link>https://community.databricks.com/t5/get-started-discussions/error-when-setting-up-oauth-profile-for-databricks-cli/m-p/60299#M2564</link>
      <description>&lt;P&gt;Actually out of nowhere it started working. Question can be closed.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Feb 2024 09:35:42 GMT</pubDate>
      <guid>https://community.databricks.com/t5/get-started-discussions/error-when-setting-up-oauth-profile-for-databricks-cli/m-p/60299#M2564</guid>
      <dc:creator>BLPedersen</dc:creator>
      <dc:date>2024-02-15T09:35:42Z</dc:date>
    </item>
    <item>
      <title>Re: Error when setting up OAuth profile for Databricks CLI</title>
      <link>https://community.databricks.com/t5/get-started-discussions/error-when-setting-up-oauth-profile-for-databricks-cli/m-p/68825#M3004</link>
      <description>&lt;P&gt;I ran into a similar error just now, and in my case, Pycharm was running some iPython startup scripts each time it opened a console. There was, for some reason, a file at `~/.ipython/profile_default/startup/00-databricks-init-a5acf3baa440a896fa364d183279094b.py'` that I have no recollection of creating or configuring which all of a sudden became an issue when I installed iPython in my project (it may have something to do with Databricks configuring global variables to be available across both the cluster WebUI and local envs?). Removing the script allowed me to proceed through the documented auth methods. Here's the script in case it helps with any future bug fixing:&lt;/P&gt;&lt;P&gt;```&lt;/P&gt;&lt;P&gt;from contextlib import contextmanager&lt;BR /&gt;import functools&lt;BR /&gt;import json&lt;BR /&gt;from typing import Any, Union, List&lt;BR /&gt;import os&lt;BR /&gt;import shlex&lt;BR /&gt;import warnings&lt;BR /&gt;import tempfile&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;def logError(function_name: str, e: Union[str, Exception]):&lt;BR /&gt;import sys&lt;BR /&gt;msg = [function_name]&lt;/P&gt;&lt;P&gt;typ = type(e)&lt;BR /&gt;if hasattr(typ, '__name__'):&lt;BR /&gt;msg.append(typ.__name__)&lt;BR /&gt;else:&lt;BR /&gt;msg.append("Error")&lt;/P&gt;&lt;P&gt;msg.append(str(e))&lt;BR /&gt;print(':'.join(msg), file=sys.stderr)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;try:&lt;BR /&gt;from IPython import get_ipython&lt;BR /&gt;from IPython.core.magic import magics_class, Magics, line_magic, needs_local_scope&lt;BR /&gt;except Exception as e:&lt;BR /&gt;logError("Ipython Imports", e)&lt;/P&gt;&lt;P&gt;__disposables = []&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;def disposable(f):&lt;BR /&gt;if hasattr(f, '__name__'):&lt;BR /&gt;__disposables.append(f.__name__)&lt;BR /&gt;return f&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;def logErrorAndContinue(f):&lt;BR /&gt;@functools.wraps(f)&lt;BR /&gt;def wrapper(*args, **kwargs):&lt;BR /&gt;try:&lt;BR /&gt;return f(*args, **kwargs)&lt;BR /&gt;except Exception as e:&lt;BR /&gt;logError(f.__name__, e)&lt;/P&gt;&lt;P&gt;return wrapper&lt;/P&gt;&lt;P&gt;@logErrorAndContinue&lt;BR /&gt;@disposable&lt;BR /&gt;def load_env_from_leaf(path: str) -&amp;gt; bool:&lt;BR /&gt;curdir = path if os.path.isdir(path) else os.path.dirname(path)&lt;BR /&gt;env_file_path = os.path.join(curdir, ".databricks", ".databricks.env")&lt;BR /&gt;if os.path.exists(os.path.dirname(env_file_path)):&lt;BR /&gt;with open(env_file_path, "r") as f:&lt;BR /&gt;for line in f.readlines():&lt;BR /&gt;key, value = line.strip().split("=", 1)&lt;BR /&gt;os.environ[key] = value&lt;BR /&gt;return True&lt;BR /&gt;&lt;BR /&gt;parent = os.path.dirname(curdir)&lt;BR /&gt;if parent == curdir:&lt;BR /&gt;return False&lt;BR /&gt;return load_env_from_leaf(parent)&lt;/P&gt;&lt;P&gt;@logErrorAndContinue&lt;BR /&gt;@disposable&lt;BR /&gt;def create_and_register_databricks_globals():&lt;BR /&gt;from databricks.sdk.runtime import dbutils&lt;BR /&gt;from IPython.display import HTML&lt;BR /&gt;from pyspark.sql import functions as udf, SparkSession&lt;BR /&gt;from databricks.connect import DatabricksSession&lt;/P&gt;&lt;P&gt;# "table", "sc", "sqlContext" are missing&lt;BR /&gt;spark: SparkSession = DatabricksSession.builder.getOrCreate()&lt;BR /&gt;sql = spark.sql&lt;/P&gt;&lt;P&gt;# We do this to prevent importing widgets implementation prematurely&lt;BR /&gt;# The widget import should prompt users to use the implementation&lt;BR /&gt;# which has ipywidget support.&lt;BR /&gt;def getArgument(*args, **kwargs):&lt;BR /&gt;return dbutils.widgets.getArgument(*args, **kwargs)&lt;/P&gt;&lt;P&gt;globals()['dbutils'] = dbutils&lt;BR /&gt;globals()['spark'] = spark&lt;BR /&gt;globals()['sql'] = sql&lt;BR /&gt;globals()['getArgument'] = getArgument&lt;BR /&gt;globals()['displayHTML'] = HTML&lt;BR /&gt;globals()['udf'] = udf&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;@disposable&lt;BR /&gt;class EnvLoader:&lt;BR /&gt;transform: type = str&lt;/P&gt;&lt;P&gt;def __init__(self, env_name: str, default: any = None, required: bool = False):&lt;BR /&gt;self.env_name = env_name&lt;BR /&gt;self.default = default&lt;BR /&gt;self.required = required&lt;/P&gt;&lt;P&gt;def __get__(self, instance, owner):&lt;BR /&gt;if self.env_name in os.environ:&lt;BR /&gt;return self.transform(os.environ[self.env_name])&lt;/P&gt;&lt;P&gt;if self.required:&lt;BR /&gt;raise AttributeError(&lt;BR /&gt;"Missing required environment variable: " + self.env_name)&lt;/P&gt;&lt;P&gt;return self.default&lt;/P&gt;&lt;P&gt;def __set__(self, instance, value):&lt;BR /&gt;return AttributeError("Can't set a value for properties loaded from env: " + self.env_name)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;@disposable&lt;BR /&gt;class LocalDatabricksNotebookConfig:&lt;BR /&gt;project_root: str = EnvLoader("DATABRICKS_PROJECT_ROOT", required=True)&lt;BR /&gt;dataframe_display_limit: int = EnvLoader("DATABRICKS_DF_DISPLAY_LIMIT", 20)&lt;/P&gt;&lt;P&gt;def __new__(cls):&lt;BR /&gt;annotations = cls.__dict__['__annotations__']&lt;BR /&gt;for attr in annotations:&lt;BR /&gt;cls.__dict__[attr].transform = annotations[attr]&lt;BR /&gt;return object.__new__(cls)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;@magics_class&lt;BR /&gt;@disposable&lt;BR /&gt;class DatabricksMagics(Magics):&lt;BR /&gt;@needs_local_scope&lt;BR /&gt;@line_magic&lt;BR /&gt;def fs(self, line: str, local_ns):&lt;BR /&gt;args = shlex.split(line)&lt;BR /&gt;if len(args) == 0:&lt;BR /&gt;return&lt;BR /&gt;cmd_str = args[0]&lt;BR /&gt;dbutils = local_ns["dbutils"]&lt;BR /&gt;if not hasattr(dbutils.fs, cmd_str):&lt;BR /&gt;raise NameError(&lt;BR /&gt;cmd_str&lt;BR /&gt;+ " is not a valid command for %fs. Valid commands are "&lt;BR /&gt;+ ", ".join(&lt;BR /&gt;list(filter(lambda i: not i.startswith(&lt;BR /&gt;"_"), dbutils.fs.__dir__()))&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;cmd = dbutils.fs.__getattribute__(cmd_str)&lt;BR /&gt;return cmd(*args[1:])&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;def is_databricks_notebook(py_file: str):&lt;BR /&gt;if os.path.exists(py_file):&lt;BR /&gt;with open(py_file, "r") as f:&lt;BR /&gt;return "Databricks notebook source" in f.readline()&lt;/P&gt;&lt;P&gt;def strip_hash_magic(lines: List[str]) -&amp;gt; List[str]:&lt;BR /&gt;if len(lines) == 0:&lt;BR /&gt;return lines&lt;BR /&gt;if lines[0].startswith("# MAGIC"):&lt;BR /&gt;return [line.partition("# MAGIC ")[2] for line in lines]&lt;BR /&gt;return lines&lt;/P&gt;&lt;P&gt;def convert_databricks_notebook_to_ipynb(py_file: str):&lt;BR /&gt;cells: List[dict[str, Any]] = [&lt;BR /&gt;{&lt;BR /&gt;"cell_type": "code",&lt;BR /&gt;"source": "import os\nos.chdir('" + os.path.dirname(py_file) + "')\n",&lt;BR /&gt;"metadata": {},&lt;BR /&gt;'outputs': [],&lt;BR /&gt;'execution_count': None&lt;BR /&gt;}&lt;BR /&gt;]&lt;BR /&gt;with open(py_file) as file:&lt;BR /&gt;text = file.read()&lt;BR /&gt;for cell in text.split("# COMMAND ----------"):&lt;BR /&gt;cell = ''.join(strip_hash_magic(cell.strip().splitlines(keepends=True)))&lt;BR /&gt;cells.append(&lt;BR /&gt;{&lt;BR /&gt;"cell_type": "code",&lt;BR /&gt;"source": cell,&lt;BR /&gt;"metadata": {},&lt;BR /&gt;'outputs': [],&lt;BR /&gt;'execution_count': None&lt;BR /&gt;}&lt;BR /&gt;)&lt;BR /&gt;&lt;BR /&gt;return json.dumps({&lt;BR /&gt;'cells': cells,&lt;BR /&gt;'metadata': {},&lt;BR /&gt;'nbformat': 4,&lt;BR /&gt;'nbformat_minor': 2&lt;BR /&gt;})&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;@contextmanager&lt;BR /&gt;def databricks_notebook_exec_env(project_root: str, py_file: str):&lt;BR /&gt;import sys&lt;BR /&gt;old_sys_path = sys.path&lt;BR /&gt;old_cwd = os.getcwd()&lt;/P&gt;&lt;P&gt;sys.path.append(project_root)&lt;BR /&gt;sys.path.append(os.path.dirname(py_file))&lt;/P&gt;&lt;P&gt;try:&lt;BR /&gt;if is_databricks_notebook(py_file):&lt;BR /&gt;notebook = convert_databricks_notebook_to_ipynb(py_file)&lt;BR /&gt;with tempfile.NamedTemporaryFile(suffix=".ipynb") as f:&lt;BR /&gt;f.write(notebook.encode())&lt;BR /&gt;f.flush()&lt;BR /&gt;yield f.name&lt;BR /&gt;else:&lt;BR /&gt;yield py_file&lt;BR /&gt;finally:&lt;BR /&gt;sys.path = old_sys_path&lt;BR /&gt;os.chdir(old_cwd)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;@logErrorAndContinue&lt;BR /&gt;@disposable&lt;BR /&gt;def register_magics(cfg: LocalDatabricksNotebookConfig):&lt;BR /&gt;def warn_for_dbr_alternative(magic: str):&lt;BR /&gt;# Magics that are not supported on Databricks but work in jupyter notebooks.&lt;BR /&gt;# We show a warning, prompting users to use a databricks equivalent instead.&lt;BR /&gt;local_magic_dbr_alternative = {"%%sh": "%sh"}&lt;BR /&gt;if magic in local_magic_dbr_alternative:&lt;BR /&gt;warnings.warn(&lt;BR /&gt;"\n" + magic&lt;BR /&gt;+ " is not supported on Databricks. This notebook might fail when running on a Databricks cluster.\n"&lt;BR /&gt;"Consider using %"&lt;BR /&gt;+ local_magic_dbr_alternative[magic]&lt;BR /&gt;+ " instead."&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;def throw_if_not_supported(magic: str):&lt;BR /&gt;# These are magics that are supported on dbr but not locally.&lt;BR /&gt;unsupported_dbr_magics = ["%r", "%scala"]&lt;BR /&gt;if magic in unsupported_dbr_magics:&lt;BR /&gt;raise NotImplementedError(&lt;BR /&gt;magic&lt;BR /&gt;+ " is not supported for local Databricks Notebooks."&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;def is_cell_magic(lines: List[str]):&lt;BR /&gt;def get_cell_magic(lines: List[str]):&lt;BR /&gt;if len(lines) == 0:&lt;BR /&gt;return&lt;BR /&gt;if lines[0].strip().startswith("%%"):&lt;BR /&gt;return lines[0].split(" ")[0].strip()&lt;BR /&gt;&lt;BR /&gt;def handle(lines: List[str]):&lt;BR /&gt;cell_magic = get_cell_magic(lines)&lt;BR /&gt;if cell_magic is None:&lt;BR /&gt;return lines&lt;BR /&gt;warn_for_dbr_alternative(cell_magic)&lt;BR /&gt;throw_if_not_supported(cell_magic)&lt;BR /&gt;return lines&lt;/P&gt;&lt;P&gt;is_cell_magic.handle = handle&lt;BR /&gt;return get_cell_magic(lines) is not None&lt;/P&gt;&lt;P&gt;def is_line_magic(lines: List[str]):&lt;BR /&gt;def get_line_magic(lines: List[str]):&lt;BR /&gt;if len(lines) == 0:&lt;BR /&gt;return&lt;BR /&gt;if lines[0].strip().startswith("%"):&lt;BR /&gt;return lines[0].split(" ")[0].strip().strip("%")&lt;BR /&gt;&lt;BR /&gt;def handle(lines: List[str]):&lt;BR /&gt;lmagic = get_line_magic(lines)&lt;BR /&gt;if lmagic is None:&lt;BR /&gt;return lines&lt;BR /&gt;warn_for_dbr_alternative(lmagic)&lt;BR /&gt;throw_if_not_supported(lmagic)&lt;/P&gt;&lt;P&gt;if lmagic == "md" or lmagic == "md-sandbox":&lt;BR /&gt;lines[0] = (&lt;BR /&gt;"%%markdown" +&lt;BR /&gt;lines[0].partition("%" + lmagic)[2]&lt;BR /&gt;)&lt;BR /&gt;return lines&lt;/P&gt;&lt;P&gt;if lmagic == "sh":&lt;BR /&gt;lines[0] = "%%sh" + \&lt;BR /&gt;lines[0].partition("%" + lmagic)[2]&lt;BR /&gt;return lines&lt;/P&gt;&lt;P&gt;if lmagic == "sql":&lt;BR /&gt;lines = lines[1:]&lt;BR /&gt;spark_string = (&lt;BR /&gt;"global _sqldf\n"&lt;BR /&gt;+ "_sqldf = spark.sql('''"&lt;BR /&gt;+ "".join(lines).replace("'", "\\'")&lt;BR /&gt;+ "''')\n"&lt;BR /&gt;+ "_sqldf"&lt;BR /&gt;)&lt;BR /&gt;return spark_string.splitlines(keepends=True)&lt;/P&gt;&lt;P&gt;if lmagic == "python":&lt;BR /&gt;return lines[1:]&lt;BR /&gt;&lt;BR /&gt;if lmagic == "run":&lt;BR /&gt;rest = lines[0].strip().split(" ")[1:]&lt;BR /&gt;if len(rest) == 0:&lt;BR /&gt;return lines&lt;BR /&gt;&lt;BR /&gt;filename = rest[0]&lt;/P&gt;&lt;P&gt;for suffix in ["", ".py", ".ipynb", ".ipy"]:&lt;BR /&gt;if os.path.exists(os.path.join(os.getcwd(), filename + suffix)):&lt;BR /&gt;filename = filename + suffix&lt;BR /&gt;break&lt;BR /&gt;&lt;BR /&gt;return [&lt;BR /&gt;f"with databricks_notebook_exec_env('{cfg.project_root}', '{filename}') as file:\n",&lt;BR /&gt;"\t%run -i {file} " + lines[0].partition('%run')[2].partition(filename)[2] + "\n"&lt;BR /&gt;]&lt;BR /&gt;&lt;BR /&gt;return lines&lt;/P&gt;&lt;P&gt;is_line_magic.handle = handle&lt;BR /&gt;return get_line_magic(lines) is not None&lt;/P&gt;&lt;P&gt;def parse_line_for_databricks_magics(lines: List[str]):&lt;BR /&gt;if len(lines) == 0:&lt;BR /&gt;return lines&lt;BR /&gt;&lt;BR /&gt;lines = [line for line in lines&lt;BR /&gt;if line.strip() != "# Databricks notebook source" and \&lt;BR /&gt;line.strip() != "# COMMAND ----------"&lt;BR /&gt;]&lt;BR /&gt;lines = ''.join(lines).strip().splitlines(keepends=True)&lt;BR /&gt;lines = strip_hash_magic(lines)&lt;/P&gt;&lt;P&gt;for magic_check in [is_cell_magic, is_line_magic]:&lt;BR /&gt;if magic_check(lines):&lt;BR /&gt;return magic_check.handle(lines)&lt;/P&gt;&lt;P&gt;return lines&lt;/P&gt;&lt;P&gt;ip = get_ipython()&lt;BR /&gt;ip.register_magics(DatabricksMagics)&lt;BR /&gt;ip.input_transformers_cleanup.append(parse_line_for_databricks_magics)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;@logErrorAndContinue&lt;BR /&gt;@disposable&lt;BR /&gt;def register_formatters(notebook_config: LocalDatabricksNotebookConfig):&lt;BR /&gt;from pyspark.sql.connect.dataframe import DataFrame as SparkConnectDataframe&lt;BR /&gt;from pyspark.sql import DataFrame&lt;/P&gt;&lt;P&gt;def df_html(df):&lt;BR /&gt;return df.limit(notebook_config.dataframe_display_limit).toPandas().to_html()&lt;/P&gt;&lt;P&gt;html_formatter = get_ipython().display_formatter.formatters["text/html"]&lt;BR /&gt;html_formatter.for_type(SparkConnectDataframe, df_html)&lt;BR /&gt;html_formatter.for_type(DataFrame, df_html)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;@logErrorAndContinue&lt;BR /&gt;@disposable&lt;BR /&gt;def update_sys_path(notebook_config: LocalDatabricksNotebookConfig):&lt;BR /&gt;sys.path.append(notebook_config.project_root)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;@disposable&lt;BR /&gt;def make_matplotlib_inline():&lt;BR /&gt;try:&lt;BR /&gt;import matplotlib&lt;BR /&gt;get_ipython().run_line_magic("matplotlib", "inline")&lt;BR /&gt;except Exception as e:&lt;BR /&gt;pass&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;global _sqldf&lt;/P&gt;&lt;P&gt;try:&lt;BR /&gt;import sys&lt;/P&gt;&lt;P&gt;print(sys.modules[__name__])&lt;BR /&gt;if not load_env_from_leaf(os.getcwd()):&lt;BR /&gt;sys.exit(1)&lt;BR /&gt;cfg = LocalDatabricksNotebookConfig()&lt;BR /&gt;create_and_register_databricks_globals()&lt;BR /&gt;register_magics(cfg)&lt;BR /&gt;register_formatters(cfg)&lt;BR /&gt;update_sys_path(cfg)&lt;BR /&gt;make_matplotlib_inline()&lt;/P&gt;&lt;P&gt;for i in __disposables + ['__disposables']:&lt;BR /&gt;globals().pop(i)&lt;BR /&gt;globals().pop('i')&lt;BR /&gt;globals().pop('disposable')&lt;/P&gt;&lt;P&gt;except Exception as e:&lt;BR /&gt;logError("unknown", e)&lt;/P&gt;&lt;P&gt;```&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Sun, 12 May 2024 08:35:04 GMT</pubDate>
      <guid>https://community.databricks.com/t5/get-started-discussions/error-when-setting-up-oauth-profile-for-databricks-cli/m-p/68825#M3004</guid>
      <dc:creator>kunalmishra9</dc:creator>
      <dc:date>2024-05-12T08:35:04Z</dc:date>
    </item>
  </channel>
</rss>

