<?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: How do I pass arguments/variables from widgets to notebooks? in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/how-do-i-pass-arguments-variables-from-widgets-to-notebooks/m-p/23545#M16269</link>
    <description>&lt;P&gt;That is a great option to use notebook workflows. I don't think you can pass a variable into the %run commands. It needs to be a literal string. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%run typically cannot access variables/objects from different languages. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One thing to point out is that this method executes in a different session from the parent notebook. %run executes within the same session as the parent notebook. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 06 Apr 2022 20:49:17 GMT</pubDate>
    <dc:creator>Ryan_Chynoweth</dc:creator>
    <dc:date>2022-04-06T20:49:17Z</dc:date>
    <item>
      <title>How do I pass arguments/variables from widgets to notebooks?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-do-i-pass-arguments-variables-from-widgets-to-notebooks/m-p/23543#M16267</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am looking for a solution to this problem, which is known since 7 years: &lt;A href="https://community.databricks.com/s/question/0D53f00001HKHZfCAP/how-do-i-pass-argumentsvariables-to-notebooks" target="test_blank"&gt;https://community.databricks.com/s/question/0D53f00001HKHZfCAP/how-do-i-pass-argumentsvariables-to-notebooks&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I need is to parametrize my notebooks using widget information. The parameters from the widgets should be passed to a %run of another notebook where all of the use case specific configurations are written.&lt;/P&gt;&lt;P&gt;Hence, I need solution to this problem, where the variable "john" is defined by a widget input.&lt;/P&gt;&lt;P&gt;&lt;I&gt;----Cell1------------------------&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;I&gt;john = 10&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;I&gt;-----Cell2--------------------&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;I&gt;%run path/to/NotebookB $VarA = john&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;I&gt;submits "john" to NotebookB not the value of 10&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have found a workaround for this, hovewer the workaround is also having a problem.&lt;/P&gt;&lt;P&gt;Here is an example. As you can see in cmd 6 when I run the notebook with "%run" and a value the notebook is loaded. &lt;/P&gt;&lt;P&gt;In cmd5 I have tried the same, but inside an if-statement, which is failing with the explanation, that the file is missing. However, it is obvious, that the file exists.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="example_if_run"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/1956i8D515B01BCD64D5F/image-size/large?v=v2&amp;amp;px=999" role="button" title="example_if_run" alt="example_if_run" /&gt;&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is anyone having the same issue and knows how to implement this?&lt;/P&gt;</description>
      <pubDate>Wed, 06 Apr 2022 15:42:23 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-do-i-pass-arguments-variables-from-widgets-to-notebooks/m-p/23543#M16267</guid>
      <dc:creator>lshar</dc:creator>
      <dc:date>2022-04-06T15:42:23Z</dc:date>
    </item>
    <item>
      <title>Re: How do I pass arguments/variables from widgets to notebooks?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-do-i-pass-arguments-variables-from-widgets-to-notebooks/m-p/23544#M16268</link>
      <description>&lt;P&gt;Can't you just use dbutils?&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;args = {}
args["VarA"] = dbutils.widgets.get("john")
dbutils.notebook.run("NotebookB", timeout=180, args)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Apr 2022 17:04:53 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-do-i-pass-arguments-variables-from-widgets-to-notebooks/m-p/23544#M16268</guid>
      <dc:creator>Hubert-Dudek</dc:creator>
      <dc:date>2022-04-06T17:04:53Z</dc:date>
    </item>
    <item>
      <title>Re: How do I pass arguments/variables from widgets to notebooks?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-do-i-pass-arguments-variables-from-widgets-to-notebooks/m-p/23545#M16269</link>
      <description>&lt;P&gt;That is a great option to use notebook workflows. I don't think you can pass a variable into the %run commands. It needs to be a literal string. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%run typically cannot access variables/objects from different languages. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One thing to point out is that this method executes in a different session from the parent notebook. %run executes within the same session as the parent notebook. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Apr 2022 20:49:17 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-do-i-pass-arguments-variables-from-widgets-to-notebooks/m-p/23545#M16269</guid>
      <dc:creator>Ryan_Chynoweth</dc:creator>
      <dc:date>2022-04-06T20:49:17Z</dc:date>
    </item>
    <item>
      <title>Re: How do I pass arguments/variables from widgets to notebooks?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-do-i-pass-arguments-variables-from-widgets-to-notebooks/m-p/23547#M16271</link>
      <description>&lt;P&gt;@Hubert Dudek​&amp;nbsp;@Kaniz Fatma​&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I use the dbutils.notebook.run(..) a new cluster is started, hence I can run some other code, but cannot use variable and functions as if I have just run them directly in the same notebook. Hence, my goal is not met.&lt;/P&gt;&lt;P&gt;I want to run a function and use parameters from the notebook that is in the dbutils.notebook.run(), but this is not possible because of running with new cluster.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2022 07:30:45 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-do-i-pass-arguments-variables-from-widgets-to-notebooks/m-p/23547#M16271</guid>
      <dc:creator>lshar</dc:creator>
      <dc:date>2022-04-28T07:30:45Z</dc:date>
    </item>
    <item>
      <title>Re: How do I pass arguments/variables from widgets to notebooks?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-do-i-pass-arguments-variables-from-widgets-to-notebooks/m-p/23548#M16272</link>
      <description>&lt;P&gt;Ishar, the dbutils.notebook.run() function is used to execute another notebook in a &lt;B&gt;different&lt;/B&gt; &lt;B&gt;session&lt;/B&gt; on the &lt;B&gt;same cluster&lt;/B&gt;. Since the child notebook has a different session the variables, functions, parameters, classes, etc. are not available in the parent notebook. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you wish to import a function from another notebook I would recommend using the %run functionality as that would execute the child notebook in the same session as the parent notebook. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To achieve your goal please use %run. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Additionally, if you are using python I would also look into our &lt;A href="https://docs.databricks.com/repos/index.html#work-with-python-and-r-modules" alt="https://docs.databricks.com/repos/index.html#work-with-python-and-r-modules" target="_blank"&gt;Python Import functionality that is available in Repos&lt;/A&gt;. &lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2022 16:15:44 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-do-i-pass-arguments-variables-from-widgets-to-notebooks/m-p/23548#M16272</guid>
      <dc:creator>Ryan_Chynoweth</dc:creator>
      <dc:date>2022-04-28T16:15:44Z</dc:date>
    </item>
    <item>
      <title>Re: How do I pass arguments/variables from widgets to notebooks?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-do-i-pass-arguments-variables-from-widgets-to-notebooks/m-p/23549#M16273</link>
      <description>&lt;P&gt;Yes, exactly. This is what I am saying. &lt;/P&gt;&lt;P&gt;I use %run, however I want to pass a parameter, which is selected from the user (or given in a scheduled run) to have different configuration from the notebook, that I am running (example: I want two pass the parameter "female" and load other parameters and functions from the notebook, that I am running with %run, than if I pass "male")&lt;/P&gt;&lt;P&gt;Now the issue is with this parameter as I have already described in the first comment: I pass subtype, but when it is a parameter with value from a widget it is not working.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2022 06:58:06 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-do-i-pass-arguments-variables-from-widgets-to-notebooks/m-p/23549#M16273</guid>
      <dc:creator>lshar</dc:creator>
      <dc:date>2022-04-29T06:58:06Z</dc:date>
    </item>
    <item>
      <title>Re: How do I pass arguments/variables from widgets to notebooks?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-do-i-pass-arguments-variables-from-widgets-to-notebooks/m-p/23550#M16274</link>
      <description>&lt;P&gt;Got it. So the only way to "pass a parameter" with %run is to define it as a variable in the parent notebook and use that variable in the child notebook. This works because both notebooks are executed in the same session so the variable my_var is available in both notebooks. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Parent Notebook: &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;my_var = "this is a parameter I want to pass" 
&amp;nbsp;
%run ./my_child_notebook&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Child Notebook: &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;print(my_var) 
&amp;nbsp;
&amp;gt;&amp;gt; "this is a parameter I want to pass"&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2022 17:58:25 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-do-i-pass-arguments-variables-from-widgets-to-notebooks/m-p/23550#M16274</guid>
      <dc:creator>Ryan_Chynoweth</dc:creator>
      <dc:date>2022-04-29T17:58:25Z</dc:date>
    </item>
    <item>
      <title>Re: How do I pass arguments/variables from widgets to notebooks?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-do-i-pass-arguments-variables-from-widgets-to-notebooks/m-p/83364#M36911</link>
      <description>&lt;P&gt;Can we create paginated reports with multiple parameters(one parameter can dynamically change other parameter) or we can pass one variable from one dataset to other dataset like power bi paginated report using Databricks dashboard, please let me know..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 18 Aug 2024 18:06:20 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-do-i-pass-arguments-variables-from-widgets-to-notebooks/m-p/83364#M36911</guid>
      <dc:creator>T_Ash</dc:creator>
      <dc:date>2024-08-18T18:06:20Z</dc:date>
    </item>
  </channel>
</rss>

