<?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 Re: databricks.sql.exc.RequestError OpenSession error None in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/databricks-sql-exc-requesterror-opensession-error-none/m-p/58575#M31203</link>
    <description>&lt;P&gt;The issue was that the new version of databricks-sql-connector (3.0.1) does not handle well error messages. So It gave a generic error and a timeout where it should have given me 403 and instant error message without a 900 second timeout.&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/databricks/databricks-sql-python/issues/333" target="_blank"&gt;https://github.com/databricks/databricks-sql-python/issues/333&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I've commented on a github issue for more debugging.&lt;/P&gt;&lt;P&gt;But I'm still wondering why I got 403 error from my compute cluster and not my compute instance where they have the same roles. So I had to add a role on the group handling both Service Principal in databricks to user SQL warehouse. Which is odd.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 29 Jan 2024 08:39:25 GMT</pubDate>
    <dc:creator>Etyr</dc:creator>
    <dc:date>2024-01-29T08:39:25Z</dc:date>
    <item>
      <title>databricks.sql.exc.RequestError OpenSession error None</title>
      <link>https://community.databricks.com/t5/data-engineering/databricks-sql-exc-requesterror-opensession-error-none/m-p/58164#M31030</link>
      <description>&lt;P&gt;I'm trying to access to a Databricks SQL Warehouse with python. I'm able to connect with a token on a Compute Instance on Azure Machine Learning. It's a VM with conda installed, I create an env in python 3.10.&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;from&lt;/SPAN&gt; databricks &lt;SPAN class=""&gt;import&lt;/SPAN&gt; sql &lt;SPAN class=""&gt;as&lt;/SPAN&gt; dbsql

dbsql.connect(
        server_hostname=&lt;SPAN class=""&gt;"databricks_address"&lt;/SPAN&gt;,
        http_path=&lt;SPAN class=""&gt;"http_path"&lt;/SPAN&gt;,
        access_token=&lt;SPAN class=""&gt;"dapi...."&lt;/SPAN&gt;,
    )&lt;/PRE&gt;&lt;P&gt;But once I create a job and I Launch it in a compute Cluster with a custom Dockerfile&lt;/P&gt;&lt;PRE&gt;FROM mcr.microsoft.com/azureml/openmpi4&lt;SPAN class=""&gt;.1&lt;/SPAN&gt;&lt;SPAN class=""&gt;.0&lt;/SPAN&gt;-ubuntu22&lt;SPAN class=""&gt;.04&lt;/SPAN&gt;:latest


ENV https_proxy http://xxxxxx:yyyy
ENV no_proxy xxxxxx

RUN mkdir -p /usr/share/man/man1

RUN wget https://download.java.net/java/GA/jdk19&lt;SPAN class=""&gt;.0&lt;/SPAN&gt;&lt;SPAN class=""&gt;.1&lt;/SPAN&gt;/afdd2e245b014143b62ccb916125e3ce/&lt;SPAN class=""&gt;10&lt;/SPAN&gt;/GPL/openjdk-&lt;SPAN class=""&gt;19.0&lt;/SPAN&gt;&lt;SPAN class=""&gt;.1&lt;/SPAN&gt;_linux-x64_bin.tar.gz \
    &amp;amp;&amp;amp; tar xvf openjdk-&lt;SPAN class=""&gt;19.0&lt;/SPAN&gt;&lt;SPAN class=""&gt;.1&lt;/SPAN&gt;_linux-x64_bin.tar.gz \
    &amp;amp;&amp;amp; mv jdk-&lt;SPAN class=""&gt;19.0&lt;/SPAN&gt;&lt;SPAN class=""&gt;.1&lt;/SPAN&gt; /opt/

ENV JAVA_HOME /opt/jdk-&lt;SPAN class=""&gt;19.0&lt;/SPAN&gt;&lt;SPAN class=""&gt;.1&lt;/SPAN&gt;
ENV PATH=&lt;SPAN class=""&gt;"${PATH}:$JAVA_HOME/bin"&lt;/SPAN&gt;

&lt;SPAN class=""&gt;# Install requirements with pip conf for Jfrog&lt;/SPAN&gt;
COPY pip.conf pip.conf
ENV PIP_CONFIG_FILE pip.conf


&lt;SPAN class=""&gt;# python installs (python 3.10 inside all azure ubuntu images)&lt;/SPAN&gt;
COPY requirements.txt .
RUN pip install -r requirements.txt &amp;amp;&amp;amp; rm requirements.txt

&lt;SPAN class=""&gt;# set command&lt;/SPAN&gt;
CMD [&lt;SPAN class=""&gt;"bash"&lt;/SPAN&gt;]&lt;/PRE&gt;&lt;P&gt;My image is created and starts to run my code, but fails on previous code sample. I am using the same values of https_proxy and no_poxy in my compute instance and compute cluster.&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;2024&lt;/SPAN&gt;-01-&lt;SPAN class=""&gt;22&lt;/SPAN&gt; &lt;SPAN class=""&gt;13&lt;/SPAN&gt;:&lt;SPAN class=""&gt;30&lt;/SPAN&gt;:&lt;SPAN class=""&gt;13&lt;/SPAN&gt;,&lt;SPAN class=""&gt;520&lt;/SPAN&gt; - thrift_backend - Error during request to server: {&lt;SPAN class=""&gt;"method"&lt;/SPAN&gt;: &lt;SPAN class=""&gt;"OpenSession"&lt;/SPAN&gt;, &lt;SPAN class=""&gt;"session-id"&lt;/SPAN&gt;: null, &lt;SPAN class=""&gt;"query-id"&lt;/SPAN&gt;: null, &lt;SPAN class=""&gt;"http-code"&lt;/SPAN&gt;: null, &lt;SPAN class=""&gt;"error-message"&lt;/SPAN&gt;: &lt;SPAN class=""&gt;""&lt;/SPAN&gt;, &lt;SPAN class=""&gt;"original-exception"&lt;/SPAN&gt;: &lt;SPAN class=""&gt;"Retry request would exceed Retry policy max retry duration of 900.0 seconds"&lt;/SPAN&gt;, &lt;SPAN class=""&gt;"no-retry-reason"&lt;/SPAN&gt;: &lt;SPAN class=""&gt;"non-retryable error"&lt;/SPAN&gt;, &lt;SPAN class=""&gt;"bounded-retry-delay"&lt;/SPAN&gt;: null, &lt;SPAN class=""&gt;"attempt"&lt;/SPAN&gt;: &lt;SPAN class=""&gt;"1/30"&lt;/SPAN&gt;, &lt;SPAN class=""&gt;"elapsed-seconds"&lt;/SPAN&gt;: &lt;SPAN class=""&gt;"846.7684090137482/900.0"&lt;/SPAN&gt;}
Traceback (most recent call last):
  File &lt;SPAN class=""&gt;"/mnt/azureml/cr/j/67f1e8c93a8942d582fb7babc030101b/exe/wd/main.py"&lt;/SPAN&gt;, line &lt;SPAN class=""&gt;198&lt;/SPAN&gt;, &lt;SPAN class=""&gt;in&lt;/SPAN&gt; &amp;lt;module&amp;gt;
    main()
  File &lt;SPAN class=""&gt;"/mnt/azureml/cr/j/67f1e8c93a8942d582fb7babc030101b/exe/wd/main.py"&lt;/SPAN&gt;, line &lt;SPAN class=""&gt;31&lt;/SPAN&gt;, &lt;SPAN class=""&gt;in&lt;/SPAN&gt; main
    &lt;SPAN class=""&gt;return&lt;/SPAN&gt; dbsql.connect(
  File &lt;SPAN class=""&gt;"/opt/miniconda/lib/python3.10/site-packages/databricks/sql/__init__.py"&lt;/SPAN&gt;, line &lt;SPAN class=""&gt;51&lt;/SPAN&gt;, &lt;SPAN class=""&gt;in&lt;/SPAN&gt; connect
    &lt;SPAN class=""&gt;return&lt;/SPAN&gt; Connection(server_hostname, http_path, access_token, **kwargs)
  File &lt;SPAN class=""&gt;"/opt/miniconda/lib/python3.10/site-packages/databricks/sql/client.py"&lt;/SPAN&gt;, line &lt;SPAN class=""&gt;235&lt;/SPAN&gt;, &lt;SPAN class=""&gt;in&lt;/SPAN&gt; __init__
    self._open_session_resp = self.thrift_backend.open_session(
  File &lt;SPAN class=""&gt;"/opt/miniconda/lib/python3.10/site-packages/databricks/sql/thrift_backend.py"&lt;/SPAN&gt;, line &lt;SPAN class=""&gt;576&lt;/SPAN&gt;, &lt;SPAN class=""&gt;in&lt;/SPAN&gt; open_session
    response = self.make_request(self._client.OpenSession, open_session_req)
  File &lt;SPAN class=""&gt;"/opt/miniconda/lib/python3.10/site-packages/databricks/sql/thrift_backend.py"&lt;/SPAN&gt;, line &lt;SPAN class=""&gt;505&lt;/SPAN&gt;, &lt;SPAN class=""&gt;in&lt;/SPAN&gt; make_request
    self._handle_request_error(error_info, attempt, elapsed)
  File &lt;SPAN class=""&gt;"/opt/miniconda/lib/python3.10/site-packages/databricks/sql/thrift_backend.py"&lt;/SPAN&gt;, line &lt;SPAN class=""&gt;335&lt;/SPAN&gt;, &lt;SPAN class=""&gt;in&lt;/SPAN&gt; _handle_request_error
    &lt;SPAN class=""&gt;raise&lt;/SPAN&gt; network_request_error
databricks.sql.exc.RequestError: Error during request to server&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;In both, I am using the lastest version of&amp;nbsp;databricks-sql-connector (3.0.1)&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jan 2024 14:59:05 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/databricks-sql-exc-requesterror-opensession-error-none/m-p/58164#M31030</guid>
      <dc:creator>Etyr</dc:creator>
      <dc:date>2024-01-22T14:59:05Z</dc:date>
    </item>
    <item>
      <title>Re: databricks.sql.exc.RequestError OpenSession error None</title>
      <link>https://community.databricks.com/t5/data-engineering/databricks-sql-exc-requesterror-opensession-error-none/m-p/58214#M31056</link>
      <description>&lt;P&gt;Hi, Could you please try&amp;nbsp;&lt;A href="https://github.com/databricks/databricks-sql-python/issues/23" target="_blank"&gt;https://github.com/databricks/databricks-sql-python/issues/23&lt;/A&gt;&amp;nbsp;and let us know if this helps (adding a new token)?&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jan 2024 03:32:24 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/databricks-sql-exc-requesterror-opensession-error-none/m-p/58214#M31056</guid>
      <dc:creator>Debayan</dc:creator>
      <dc:date>2024-01-23T03:32:24Z</dc:date>
    </item>
    <item>
      <title>Re: databricks.sql.exc.RequestError OpenSession error None</title>
      <link>https://community.databricks.com/t5/data-engineering/databricks-sql-exc-requesterror-opensession-error-none/m-p/58237#M31061</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am already recreating a new token at each time I init my Spark session. I do this using the Azure's oauth2 service to get a token lasting 1 hour and then using databricks API 2.0 to generate a new PAT.&lt;BR /&gt;And this code is working in local and in compute instances in Azure, but not Compute Clusters.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;What I also tried: To generate a token in UI, working in local, then using it in my code in my compute cluster, and not working with the above error.&lt;/P&gt;&lt;P&gt;Cloud it be a network issue? I'm creating both compute instance/cluster in terraform:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;resource "azurerm_machine_learning_compute_cluster" "cluster" {
  for_each = local.compute_cluster_configurations

  name     = each.key
  location = var.context.location

  vm_priority                   = each.value.vm_priority
  vm_size                       = each.value.vm_size
  machine_learning_workspace_id = module.mlw_01.id
  subnet_resource_id            = module.subnet_aml.id

  # AML-05
  ssh_public_access_enabled = false
  node_public_ip_enabled    = false

  identity {
    type = "UserAssigned"
    identity_ids = [
      azurerm_user_assigned_identity.compute_cluster_managed_identity.id
    ]
  }

  scale_settings {
    min_node_count                       = each.value.min_node_count
    max_node_count                       = each.value.max_node_count
    scale_down_nodes_after_idle_duration = each.value.scale_down_nodes_after_idle_duration
  }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;# For each user, create a compute instance
resource "azurerm_machine_learning_compute_instance" "this" {
  for_each = local.all_users

  name                          = "${split("@", trimspace(local.all_users[each.key]["user_principal_name"]))[0]}-DS2-V2"
  location                      = var.context.location
  machine_learning_workspace_id = module.mlw_01.id
  virtual_machine_size          = "STANDARD_DS2_V2"
  identity {
    type = "UserAssigned"
    identity_ids = [
      azurerm_user_assigned_identity.this[each.key].id
    ]
  }
  assign_to_user {
    object_id = each.key
    tenant_id = var.tenant_id
  }
  node_public_ip_enabled = false
  subnet_resource_id     = module.subnet_aml.id
  description            = "Compute instance generated by Terraform for : ${local.all_users[each.key]["display_name"]} | ${local.all_users[each.key]["user_principal_name"]} | ${each.key} "
}&lt;/LI-CODE&gt;&lt;P&gt;I'm using the same subnet, so it should react the same in network.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jan 2024 07:57:57 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/databricks-sql-exc-requesterror-opensession-error-none/m-p/58237#M31061</guid>
      <dc:creator>Etyr</dc:creator>
      <dc:date>2024-01-23T07:57:57Z</dc:date>
    </item>
    <item>
      <title>Re: databricks.sql.exc.RequestError OpenSession error None</title>
      <link>https://community.databricks.com/t5/data-engineering/databricks-sql-exc-requesterror-opensession-error-none/m-p/58575#M31203</link>
      <description>&lt;P&gt;The issue was that the new version of databricks-sql-connector (3.0.1) does not handle well error messages. So It gave a generic error and a timeout where it should have given me 403 and instant error message without a 900 second timeout.&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/databricks/databricks-sql-python/issues/333" target="_blank"&gt;https://github.com/databricks/databricks-sql-python/issues/333&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I've commented on a github issue for more debugging.&lt;/P&gt;&lt;P&gt;But I'm still wondering why I got 403 error from my compute cluster and not my compute instance where they have the same roles. So I had to add a role on the group handling both Service Principal in databricks to user SQL warehouse. Which is odd.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jan 2024 08:39:25 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/databricks-sql-exc-requesterror-opensession-error-none/m-p/58575#M31203</guid>
      <dc:creator>Etyr</dc:creator>
      <dc:date>2024-01-29T08:39:25Z</dc:date>
    </item>
  </channel>
</rss>

