<?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: Run a Databricks notebook from another notebook with ipywidget in Machine Learning</title>
    <link>https://community.databricks.com/t5/machine-learning/run-a-databricks-notebook-from-another-notebook-with-ipywidget/m-p/7162#M336</link>
    <description>&lt;P&gt;Hello, &lt;/P&gt;&lt;P&gt;Thank you for this. I tried running it but now I am getting the error:&lt;/P&gt;&lt;P&gt;AttributeError: 'NotebookHandler' object has no attribute 'setContext'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
    <pubDate>Sat, 25 Mar 2023 09:44:08 GMT</pubDate>
    <dc:creator>mbejarano89</dc:creator>
    <dc:date>2023-03-25T09:44:08Z</dc:date>
    <item>
      <title>Run a Databricks notebook from another notebook with ipywidget</title>
      <link>https://community.databricks.com/t5/machine-learning/run-a-databricks-notebook-from-another-notebook-with-ipywidget/m-p/7160#M334</link>
      <description>&lt;P&gt;0&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to run a notebook from another notebook using the dbutils.notebook.run as follows:&lt;/P&gt;&lt;P&gt;import ipywidgets as widgets&lt;/P&gt;&lt;P&gt;from ipywidgets import interact&lt;/P&gt;&lt;P&gt;from ipywidgets import Box&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;button = widgets.Button(description='Run model')&lt;/P&gt;&lt;P&gt;out = widgets.Output()&lt;/P&gt;&lt;P&gt;def on_button_clicked(b):&lt;/P&gt;&lt;P&gt;    button.description = 'Run model'&lt;/P&gt;&lt;P&gt;    with out:&lt;/P&gt;&lt;P&gt;        dbutils.notebook.run("/mynotebookpath",60)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;button.on_click(on_button_clicked)&lt;/P&gt;&lt;P&gt;widgets.VBox([button, out])&lt;/P&gt;&lt;P&gt;However, I am getting the following error:&lt;/P&gt;&lt;P&gt;IllegalArgumentException: Context not valid. If you are calling this outside the main thread, you must set the Notebook context via dbutils.notebook.setContext(ctx), where ctx is a value retrieved from the main thread (and the same cell)&lt;/P&gt;&lt;P&gt;I can run the notebook just fine when I do&amp;nbsp;&lt;/P&gt;&lt;P&gt;%run&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;on a single cell and even&amp;nbsp;&lt;/P&gt;&lt;P&gt;dbutils.notebook.run("/mynotebook", 60)&lt;/P&gt;&lt;P&gt;&amp;nbsp;on a single cell. However I cannot get it to run within the ipywidget context&lt;/P&gt;</description>
      <pubDate>Thu, 23 Mar 2023 20:32:07 GMT</pubDate>
      <guid>https://community.databricks.com/t5/machine-learning/run-a-databricks-notebook-from-another-notebook-with-ipywidget/m-p/7160#M334</guid>
      <dc:creator>mbejarano89</dc:creator>
      <dc:date>2023-03-23T20:32:07Z</dc:date>
    </item>
    <item>
      <title>Re: Run a Databricks notebook from another notebook with ipywidget</title>
      <link>https://community.databricks.com/t5/machine-learning/run-a-databricks-notebook-from-another-notebook-with-ipywidget/m-p/7161#M335</link>
      <description>&lt;P&gt;@Marcela Bejarano​&amp;nbsp;:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The error you are seeing is because the dbutils module requires a valid notebook context to run the notebook. When running code from an ipywidget context, the main thread and the widget thread are different. To solve this, you can try setting the notebook context before calling dbutils.notebook.run()&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;import ipywidgets as widgets
from ipywidgets import interact, Box
from pyspark.sql import SparkSession
&amp;nbsp;
button = widgets.Button(description='Run model')
out = widgets.Output()
&amp;nbsp;
def on_button_clicked(b):
    button.description = 'Run model'
    with out:
        # Get the current notebook context
        current_notebook = get_ipython().get_parent()
        # Set the notebook context for dbutils
        dbutils.notebook.setContext(current_notebook)
        # Run the notebook
        dbutils.notebook.run("/mynotebookpath",60)
&amp;nbsp;
button.on_click(on_button_clicked)
widgets.VBox([button, out])&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This should set the notebook context correctly and allow you to run the notebook from the ipywidget context.&lt;/P&gt;</description>
      <pubDate>Sat, 25 Mar 2023 06:47:02 GMT</pubDate>
      <guid>https://community.databricks.com/t5/machine-learning/run-a-databricks-notebook-from-another-notebook-with-ipywidget/m-p/7161#M335</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-03-25T06:47:02Z</dc:date>
    </item>
    <item>
      <title>Re: Run a Databricks notebook from another notebook with ipywidget</title>
      <link>https://community.databricks.com/t5/machine-learning/run-a-databricks-notebook-from-another-notebook-with-ipywidget/m-p/7162#M336</link>
      <description>&lt;P&gt;Hello, &lt;/P&gt;&lt;P&gt;Thank you for this. I tried running it but now I am getting the error:&lt;/P&gt;&lt;P&gt;AttributeError: 'NotebookHandler' object has no attribute 'setContext'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 25 Mar 2023 09:44:08 GMT</pubDate>
      <guid>https://community.databricks.com/t5/machine-learning/run-a-databricks-notebook-from-another-notebook-with-ipywidget/m-p/7162#M336</guid>
      <dc:creator>mbejarano89</dc:creator>
      <dc:date>2023-03-25T09:44:08Z</dc:date>
    </item>
    <item>
      <title>Re: Run a Databricks notebook from another notebook with ipywidget</title>
      <link>https://community.databricks.com/t5/machine-learning/run-a-databricks-notebook-from-another-notebook-with-ipywidget/m-p/7163#M337</link>
      <description>&lt;P&gt;Hi @Marcela Bejarano​&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm sorry you could not find a solution to your problem in the answers provided.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Our community strives to provide helpful and accurate information, but sometimes an immediate solution may only be available for some issues.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I suggest providing more information about your problem, such as specific error messages, error logs or details about the steps you have taken. This can help our community members better understand the issue and provide more targeted solutions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Alternatively, you can consider contacting the &lt;A href="https://help.databricks.com/s/login/?ec=302&amp;amp;startURL=%2Fs%2Fsubmitrequest%3F_ga%3D2.21602814.410387879.1677483027-1154058422.1670836178" alt="https://help.databricks.com/s/login/?ec=302&amp;amp;startURL=%2Fs%2Fsubmitrequest%3F_ga%3D2.21602814.410387879.1677483027-1154058422.1670836178" target="_blank"&gt;support team&lt;/A&gt; for your product or service. They may be able to provide additional assistance or escalate the issue to the appropriate section for further investigation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for your patience and understanding, and please let us know if there is anything else we can do to assist you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Mar 2023 05:38:59 GMT</pubDate>
      <guid>https://community.databricks.com/t5/machine-learning/run-a-databricks-notebook-from-another-notebook-with-ipywidget/m-p/7163#M337</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-03-30T05:38:59Z</dc:date>
    </item>
    <item>
      <title>Re: Run a Databricks notebook from another notebook with ipywidget</title>
      <link>https://community.databricks.com/t5/machine-learning/run-a-databricks-notebook-from-another-notebook-with-ipywidget/m-p/42787#M2099</link>
      <description>&lt;P&gt;Hey !&lt;BR /&gt;&lt;BR /&gt;Have you found a solution for that isssue?&lt;BR /&gt;I am facing the same problem...&lt;BR /&gt;&lt;SPAN&gt;"AttributeError: 'NotebookHandler' object has no attribute 'setContext'"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Tue, 29 Aug 2023 11:54:38 GMT</pubDate>
      <guid>https://community.databricks.com/t5/machine-learning/run-a-databricks-notebook-from-another-notebook-with-ipywidget/m-p/42787#M2099</guid>
      <dc:creator>TheDarkKnight</dc:creator>
      <dc:date>2023-08-29T11:54:38Z</dc:date>
    </item>
    <item>
      <title>Re: Run a Databricks notebook from another notebook with ipywidget</title>
      <link>https://community.databricks.com/t5/machine-learning/run-a-databricks-notebook-from-another-notebook-with-ipywidget/m-p/42796#M2100</link>
      <description>&lt;P&gt;I am also getting the same error&lt;/P&gt;</description>
      <pubDate>Tue, 29 Aug 2023 14:11:14 GMT</pubDate>
      <guid>https://community.databricks.com/t5/machine-learning/run-a-databricks-notebook-from-another-notebook-with-ipywidget/m-p/42796#M2100</guid>
      <dc:creator>Sreekanth_N</dc:creator>
      <dc:date>2023-08-29T14:11:14Z</dc:date>
    </item>
    <item>
      <title>Re: Run a Databricks notebook from another notebook with ipywidget</title>
      <link>https://community.databricks.com/t5/machine-learning/run-a-databricks-notebook-from-another-notebook-with-ipywidget/m-p/42797#M2101</link>
      <description>&lt;P&gt;As I could see the pyspark stream is not supporting this setContext, ideally it should have alternative approach. please suggest what is approach where pyspark stream is internally calling to another notebook parallel&lt;/P&gt;</description>
      <pubDate>Tue, 29 Aug 2023 14:16:32 GMT</pubDate>
      <guid>https://community.databricks.com/t5/machine-learning/run-a-databricks-notebook-from-another-notebook-with-ipywidget/m-p/42797#M2101</guid>
      <dc:creator>Sreekanth_N</dc:creator>
      <dc:date>2023-08-29T14:16:32Z</dc:date>
    </item>
  </channel>
</rss>

