<?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 a function to another notebook using Repos without %run? in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/how-to-import-a-function-to-another-notebook-using-repos-without/m-p/12982#M7724</link>
    <description>&lt;P&gt;The thing in Repos is to point to the correct path.&lt;/P&gt;&lt;P&gt;Repos is just like in any local filesystem.&lt;/P&gt;&lt;P&gt;So in your case you need a notebook_in_repos folder with your .py files containing the functions.&lt;/P&gt;</description>
    <pubDate>Wed, 20 Oct 2021 09:59:22 GMT</pubDate>
    <dc:creator>-werners-</dc:creator>
    <dc:date>2021-10-20T09:59:22Z</dc:date>
    <item>
      <title>How to import a function to another notebook using Repos without %run?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-import-a-function-to-another-notebook-using-repos-without/m-p/12979#M7721</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was reading the Repos documentation: &lt;A href="https://docs.databricks.com/repos.html#migrate-from-run-commands" alt="https://docs.databricks.com/repos.html#migrate-from-run-commands" target="_blank"&gt;https://docs.databricks.com/repos.html#migrate-from-run-commands&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is explained that, one advantage of Repos is no longer necessary to use %run magic command to make funcions available in one notebook to another. That is to say, we can import them with:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"from notebook_in_repos import fun"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tested it out on Repos, but it doesn´t work. I get: "No module named notebook_in_repos"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I really want this feature. It is painfull to build an entire module just to do an import. And on the other hand, the %run magic command is not a good replace; it overwrites local variables and mess up namespaces.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can I make this work?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Oct 2021 20:41:18 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-import-a-function-to-another-notebook-using-repos-without/m-p/12979#M7721</guid>
      <dc:creator>maranBH</dc:creator>
      <dc:date>2021-10-19T20:41:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to import a function to another notebook using Repos without %run?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-import-a-function-to-another-notebook-using-repos-without/m-p/12981#M7723</link>
      <description>&lt;P&gt;You can import the functions using the example mentioned in the blog. &lt;A href="https://databricks.com/blog/2021/10/07/databricks-repos-is-now-generally-available.html" target="test_blank"&gt;https://databricks.com/blog/2021/10/07/databricks-repos-is-now-generally-available.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let me know if this helps with your use case?&lt;/P&gt;</description>
      <pubDate>Wed, 20 Oct 2021 08:38:25 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-import-a-function-to-another-notebook-using-repos-without/m-p/12981#M7723</guid>
      <dc:creator>User16829050420</dc:creator>
      <dc:date>2021-10-20T08:38:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to import a function to another notebook using Repos without %run?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-import-a-function-to-another-notebook-using-repos-without/m-p/12982#M7724</link>
      <description>&lt;P&gt;The thing in Repos is to point to the correct path.&lt;/P&gt;&lt;P&gt;Repos is just like in any local filesystem.&lt;/P&gt;&lt;P&gt;So in your case you need a notebook_in_repos folder with your .py files containing the functions.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Oct 2021 09:59:22 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-import-a-function-to-another-notebook-using-repos-without/m-p/12982#M7724</guid>
      <dc:creator>-werners-</dc:creator>
      <dc:date>2021-10-20T09:59:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to import a function to another notebook using Repos without %run?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-import-a-function-to-another-notebook-using-repos-without/m-p/12983#M7725</link>
      <description>&lt;P&gt;My solution was to tell Python of that additional module import path by adding a snippet like this one to the notebook:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;import os&lt;/P&gt;&lt;P&gt;import sys&lt;/P&gt;&lt;P&gt;module_path = os.path.abspath(os.path.join('..'))&lt;/P&gt;&lt;P&gt;if module_path not in sys.path:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;sys.path.append(module_path)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;         This allows you to import the desired function from the module hierarchy:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;from project1.lib.module import function&lt;/P&gt;&lt;P&gt;# use the function normally&lt;/P&gt;&lt;P&gt;function(...)&lt;/P&gt;&lt;P&gt;   &lt;/P&gt;&lt;P&gt;            Note that it is necessary to add empty __init__.py files to project1/ and lib/ folders if you don't have them already.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want to know more about functions in Python go through &lt;A href="https://encodingcompiler.com/" alt="https://encodingcompiler.com/" target="_blank"&gt;EncodingCompiler&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Oct 2021 10:46:11 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-import-a-function-to-another-notebook-using-repos-without/m-p/12983#M7725</guid>
      <dc:creator>madhuchennu</dc:creator>
      <dc:date>2021-10-20T10:46:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to import a function to another notebook using Repos without %run?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-import-a-function-to-another-notebook-using-repos-without/m-p/12984#M7726</link>
      <description>&lt;P&gt;Thank you all for your help! I tried all that was suggested; but I finally realized it was my fault in first place:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;I was testing Files in Repos with a runtime &amp;lt; 8.4.&lt;/LI&gt;&lt;LI&gt;I was trying to import a file from a DB Notebook instead of a static .py file.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Upgrading my runtime and migrating all my code to a .py file did the trick!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you all again!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Oct 2021 14:25:54 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-import-a-function-to-another-notebook-using-repos-without/m-p/12984#M7726</guid>
      <dc:creator>maranBH</dc:creator>
      <dc:date>2021-10-22T14:25:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to import a function to another notebook using Repos without %run?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-import-a-function-to-another-notebook-using-repos-without/m-p/97899#M39570</link>
      <description>&lt;P&gt;Due to new functionalies in Runtime 16.0 regarding autoload i came across this autoload.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Performaed a practical test. It works. However had some problems at first.&lt;/P&gt;&lt;P&gt;As in solution the key was that definitions are places in a&amp;nbsp;&lt;STRONG&gt;file.py&amp;nbsp;&lt;/STRONG&gt;not a notebook.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Nov 2024 10:25:26 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-import-a-function-to-another-notebook-using-repos-without/m-p/97899#M39570</guid>
      <dc:creator>JakubSkibicki</dc:creator>
      <dc:date>2024-11-06T10:25:26Z</dc:date>
    </item>
  </channel>
</rss>

