<?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 to import one databricks python notebook into another? in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/how-to-import-one-databricks-python-notebook-into-another/m-p/28291#M20114</link>
    <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Created a package to do exactly this. Have a look: &lt;A href="https://pypi.org/project/libify/" target="test_blank"&gt;https://pypi.org/project/libify/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;(Relies on dbutils.notebook.run, so won't work with the Databricks community edition)&lt;/P&gt; 
&lt;P&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 14 Sep 2020 15:36:24 GMT</pubDate>
    <dc:creator>m96</dc:creator>
    <dc:date>2020-09-14T15:36:24Z</dc:date>
    <item>
      <title>How to import one databricks python notebook into another?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-import-one-databricks-python-notebook-into-another/m-p/28286#M20109</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;I have a python notebook A in Azure Databricks having import statement as below:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;import xyz, datetime,...&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I have another notebook xyz being imported in notebook A as shown in above code. When I run notebook A, it throws the following error:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;ImportError:No module named xyz  &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Both notebooks are in the same workspace directory. Can anyone help in resolving this?&lt;/P&gt; 
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Apr 2019 10:29:38 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-import-one-databricks-python-notebook-into-another/m-p/28286#M20109</guid>
      <dc:creator>amanpreetkaur</dc:creator>
      <dc:date>2019-04-15T10:29:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to import one databricks python notebook into another?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-import-one-databricks-python-notebook-into-another/m-p/28287#M20110</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Can you please answer this? @jurmu&lt;/P&gt; 
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Apr 2019 12:23:19 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-import-one-databricks-python-notebook-into-another/m-p/28287#M20110</guid>
      <dc:creator>amanpreetkaur</dc:creator>
      <dc:date>2019-04-15T12:23:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to import one databricks python notebook into another?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-import-one-databricks-python-notebook-into-another/m-p/28288#M20111</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;I belive this is not possible. You can run a notebook passing parameters as:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;result = dbutils.notebook.run("notebook-name", 60, {"argument": "data", "argument2": "data2", ...})&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But notebooks can only return strings. What you need is to upload a Python module as a library and them import the module in your notebook.&lt;/P&gt; 
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Oct 2019 16:29:18 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-import-one-databricks-python-notebook-into-another/m-p/28288#M20111</guid>
      <dc:creator>jbsilva</dc:creator>
      <dc:date>2019-10-23T16:29:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to import one databricks python notebook into another?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-import-one-databricks-python-notebook-into-another/m-p/28289#M20112</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;For me worked well solution:&lt;/P&gt;
&lt;P&gt;1) Create library notebook. For example - "&lt;B&gt;Lib&lt;/B&gt;" with any functions/classes there (no runnable code).&lt;/P&gt;
&lt;P&gt;2) Create main notebook. For example - "&lt;B&gt;Main&lt;/B&gt;"&lt;/P&gt;
&lt;P&gt;3) To import into main all classes &amp;amp; functions from Lib to Main use command:&lt;/P&gt;
&lt;P&gt;&lt;B&gt;%run "./Lib"&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;(this will works like: &lt;B&gt;from Lib import *&lt;/B&gt;)&lt;/P&gt;
&lt;P&gt;4) After that you can call any functions/ use classes that used in Lib from Main notebook.&lt;/P&gt;
&lt;P&gt;PS: &lt;/P&gt;
&lt;P&gt;1.1) recursion enabled - i.e. you lib notebook may contain code that runs any other notebooks the same way&lt;/P&gt;
&lt;P&gt;1.2) for reload changed code from Lib module - just re-run command &lt;B&gt;%run "./Lib"&lt;/B&gt;&lt;/P&gt; 
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Dec 2019 11:18:14 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-import-one-databricks-python-notebook-into-another/m-p/28289#M20112</guid>
      <dc:creator>MikhailKolomaso</dc:creator>
      <dc:date>2019-12-23T11:18:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to import one databricks python notebook into another?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-import-one-databricks-python-notebook-into-another/m-p/28290#M20113</link>
      <description>&lt;P&gt;@Mikhail Kolomasov​&amp;nbsp;, I tried exactly this, it worked until step 4. I'm trying to import variables in a py file into my "Main" notebook. What am i missing here?&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.databricks.com/s/contentdocument/0693f000007PPdHAAW" alt="https://community.databricks.com/s/contentdocument/0693f000007PPdHAAW" target="_blank"&gt;2019-12-30-12-18-45-emr-pseg.png&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Dec 2019 11:42:00 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-import-one-databricks-python-notebook-into-another/m-p/28290#M20113</guid>
      <dc:creator>awaiskaleem</dc:creator>
      <dc:date>2019-12-30T11:42:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to import one databricks python notebook into another?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-import-one-databricks-python-notebook-into-another/m-p/28291#M20114</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Created a package to do exactly this. Have a look: &lt;A href="https://pypi.org/project/libify/" target="test_blank"&gt;https://pypi.org/project/libify/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;(Relies on dbutils.notebook.run, so won't work with the Databricks community edition)&lt;/P&gt; 
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Sep 2020 15:36:24 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-import-one-databricks-python-notebook-into-another/m-p/28291#M20114</guid>
      <dc:creator>m96</dc:creator>
      <dc:date>2020-09-14T15:36:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to import one databricks python notebook into another?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-import-one-databricks-python-notebook-into-another/m-p/28292#M20115</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Thank you it worked like a charm! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt; 
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Apr 2021 15:30:34 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-import-one-databricks-python-notebook-into-another/m-p/28292#M20115</guid>
      <dc:creator>virgilus</dc:creator>
      <dc:date>2021-04-22T15:30:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to import one databricks python notebook into another?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-import-one-databricks-python-notebook-into-another/m-p/28293#M20116</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Thanks, worked like a charm! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt; 
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Apr 2021 15:31:12 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-import-one-databricks-python-notebook-into-another/m-p/28293#M20116</guid>
      <dc:creator>virgilus</dc:creator>
      <dc:date>2021-04-22T15:31:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to import one databricks python notebook into another?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-import-one-databricks-python-notebook-into-another/m-p/28294#M20117</link>
      <description>&lt;P&gt;&lt;B&gt;NoebookA:&lt;/B&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;def func1():
&amp;nbsp;
     pass&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;NotebookB:&lt;/B&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;%run /NotebookA
&amp;nbsp;
func1()&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 25 Dec 2022 15:18:19 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-import-one-databricks-python-notebook-into-another/m-p/28294#M20117</guid>
      <dc:creator>ramravi</dc:creator>
      <dc:date>2022-12-25T15:18:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to import one databricks python notebook into another?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-import-one-databricks-python-notebook-into-another/m-p/28295#M20118</link>
      <description>&lt;OL&gt;&lt;LI&gt;Create a repository containing an __init__.py file&lt;/LI&gt;&lt;LI&gt;Add your library as .py file(s). Let's imagine that our library is composed by multiple sub-folders consolidated in "my_folder", one of sub-folders is named as "math_library" and contains my_awesome_lib.py&lt;/LI&gt;&lt;LI&gt;In caller Notebook import as a module :&lt;/LI&gt;&lt;/OL&gt;&lt;PRE&gt;&lt;CODE&gt;import os
import sys
sys.path.append(os.path.abspath("/Workspace/Repos/&amp;lt;usename&amp;gt;/&amp;lt;repo-name&amp;gt;/&amp;lt;path&amp;gt;/my_folder"))&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or use pathlib to adress the folder you need&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;import os
import sys
from pathlib import Path
&amp;nbsp;
sys.path.append(str(Path(os.getcwd()).parent.absolute()))&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;4. Make a call to the function in question : &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;from math_library import my_awesome_lib
&amp;nbsp;
my_awesome_lib.&amp;lt;function needed name&amp;gt;()&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 11 May 2023 14:46:41 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-import-one-databricks-python-notebook-into-another/m-p/28295#M20118</guid>
      <dc:creator>artsheiko</dc:creator>
      <dc:date>2023-05-11T14:46:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to import one databricks python notebook into another?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-import-one-databricks-python-notebook-into-another/m-p/28296#M20119</link>
      <description>&lt;P&gt;Why does the description &lt;A href="https://docs.databricks.com/notebooks/share-code.html" alt="https://docs.databricks.com/notebooks/share-code.html" target="_blank"&gt;here&lt;/A&gt; look much simpler than described above?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 12 May 2023 19:11:36 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-import-one-databricks-python-notebook-into-another/m-p/28296#M20119</guid>
      <dc:creator>Mumrel</dc:creator>
      <dc:date>2023-05-12T19:11:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to import one databricks python notebook into another?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-import-one-databricks-python-notebook-into-another/m-p/28297#M20120</link>
      <description>&lt;P&gt;&lt;A href="https://savastan0.pw/" alt="https://savastan0.pw/" target="_blank"&gt;savastan0 cc shop&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 14 May 2023 03:52:23 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-import-one-databricks-python-notebook-into-another/m-p/28297#M20120</guid>
      <dc:creator>kinka007</dc:creator>
      <dc:date>2023-05-14T03:52:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to import one databricks python notebook into another?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-import-one-databricks-python-notebook-into-another/m-p/28298#M20121</link>
      <description>&lt;P&gt;The documentation article covers the case when the file to import is located in the same directory. The step-by-step process I described shows how to import a file from an independent repository. Both are same in principle&lt;/P&gt;</description>
      <pubDate>Sun, 14 May 2023 18:40:28 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-import-one-databricks-python-notebook-into-another/m-p/28298#M20121</guid>
      <dc:creator>artsheiko</dc:creator>
      <dc:date>2023-05-14T18:40:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to import one databricks python notebook into another?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-import-one-databricks-python-notebook-into-another/m-p/28299#M20122</link>
      <description>&lt;P&gt;Got it, thanks for the quick response&lt;/P&gt;</description>
      <pubDate>Mon, 15 May 2023 07:30:31 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-import-one-databricks-python-notebook-into-another/m-p/28299#M20122</guid>
      <dc:creator>Mumrel</dc:creator>
      <dc:date>2023-05-15T07:30:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to import one databricks python notebook into another?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-import-one-databricks-python-notebook-into-another/m-p/41070#M27291</link>
      <description>&lt;P&gt;I followed those descriptions and got the error "[Errno 95] Operation not supported" on the import line using DBR 12.2 LTS. I think there may be a bug in the runtime or the content of the descriptions is obsolete.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Aug 2023 22:01:24 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-import-one-databricks-python-notebook-into-another/m-p/41070#M27291</guid>
      <dc:creator>TimThein</dc:creator>
      <dc:date>2023-08-22T22:01:24Z</dc:date>
    </item>
  </channel>
</rss>

