<?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 import a python module when deploying with DAB? in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/how-do-i-import-a-python-module-when-deploying-with-dab/m-p/142902#M52045</link>
    <description>&lt;P&gt;Under src I would add the parent directory for pipeline and&amp;nbsp; utils and put there&amp;nbsp;__init__.py&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;resources/
  |- etl_event/
     |- etl_event.job.yml
src/
  |- project/
    __init__.py
    |- pipeline/
       |- etl_event/
          |- transformers/
            |- transformer_1.py
     |- utils/
       __init__.py
       |- logger.py
databricks.yml&lt;/LI-CODE&gt;</description>
    <pubDate>Sat, 03 Jan 2026 20:29:11 GMT</pubDate>
    <dc:creator>Hubert-Dudek</dc:creator>
    <dc:date>2026-01-03T20:29:11Z</dc:date>
    <item>
      <title>How do I import a python module when deploying with DAB?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-do-i-import-a-python-module-when-deploying-with-dab/m-p/142877#M52041</link>
      <description>&lt;P&gt;Below is how the folder structure of my project looks like:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;resources/
  |- etl_event/
     |- etl_event.job.yml
src/
  |- pipeline/
     |- etl_event/
        |- transformers/
          |- transformer_1.py
  |- utils/
     |- logger.py
databricks.yml&lt;/LI-CODE&gt;&lt;P&gt;I created a python module,&amp;nbsp;&lt;EM&gt;logger.py,&lt;/EM&gt;&amp;nbsp;that I want to reuse in many transformers, so I put it in &lt;EM&gt;utils&lt;/EM&gt; folder. I want&amp;nbsp;&lt;EM&gt;transformer_1.py&lt;/EM&gt;&amp;nbsp;to import&amp;nbsp;&lt;EM&gt;get_logger()&lt;/EM&gt;&amp;nbsp;function from the module:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# transformer_1.py
from pyspark import pipelines as dp
from utils.logger import get_logger

@dp.table
def load_events():
    logger = get_logger(__name__)
    logger.info('Loading events...')
    ...&lt;/LI-CODE&gt;&lt;P&gt;After I deploy my project using DAB, running "etl_event" job fails because 'utils' module is not found.&lt;/P&gt;&lt;P&gt;I learned the following from researching the documents:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&amp;nbsp;PYTHONPATH is not set to the root of the bundle.&lt;/LI&gt;&lt;LI&gt;One suggestion is to use `sys.path.append()` before each import. This feels rather a hack that I must remember to manipulate system path before each import.&lt;/LI&gt;&lt;LI&gt;Another suggestion is to build a &lt;A href="https://docs.databricks.com/aws/en/dev-tools/bundles/python-wheel/" target="_self"&gt;python wheel file&lt;/A&gt;. I'm not sure if that applies to my project because the module(utils/logger.py) is already included in bundle deployed. I should not need to build a separate wheel file.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;My question is what is the proper way to configure my project/bundle so that I can have reusable python modules to be used in pipeline transformers?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jan 2026 23:33:38 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-do-i-import-a-python-module-when-deploying-with-dab/m-p/142877#M52041</guid>
      <dc:creator>kenny_hero</dc:creator>
      <dc:date>2026-01-02T23:33:38Z</dc:date>
    </item>
    <item>
      <title>Re: How do I import a python module when deploying with DAB?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-do-i-import-a-python-module-when-deploying-with-dab/m-p/142902#M52045</link>
      <description>&lt;P&gt;Under src I would add the parent directory for pipeline and&amp;nbsp; utils and put there&amp;nbsp;__init__.py&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;resources/
  |- etl_event/
     |- etl_event.job.yml
src/
  |- project/
    __init__.py
    |- pipeline/
       |- etl_event/
          |- transformers/
            |- transformer_1.py
     |- utils/
       __init__.py
       |- logger.py
databricks.yml&lt;/LI-CODE&gt;</description>
      <pubDate>Sat, 03 Jan 2026 20:29:11 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-do-i-import-a-python-module-when-deploying-with-dab/m-p/142902#M52045</guid>
      <dc:creator>Hubert-Dudek</dc:creator>
      <dc:date>2026-01-03T20:29:11Z</dc:date>
    </item>
    <item>
      <title>Re: How do I import a python module when deploying with DAB?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-do-i-import-a-python-module-when-deploying-with-dab/m-p/142916#M52049</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/25346"&gt;@Hubert-Dudek&lt;/a&gt;&amp;nbsp;. This is very useful.&lt;/P&gt;</description>
      <pubDate>Sun, 04 Jan 2026 06:05:58 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-do-i-import-a-python-module-when-deploying-with-dab/m-p/142916#M52049</guid>
      <dc:creator>Sanjeeb2024</dc:creator>
      <dc:date>2026-01-04T06:05:58Z</dc:date>
    </item>
    <item>
      <title>Re: How do I import a python module when deploying with DAB?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-do-i-import-a-python-module-when-deploying-with-dab/m-p/143050#M52083</link>
      <description>&lt;P&gt;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/25346"&gt;@Hubert-Dudek&lt;/a&gt;, thank you for your response. I really appreciate it.&lt;/P&gt;&lt;P&gt;However, I still cannot get the import to work even after I follow your instructions. Here is the folder structure:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="import_test_project_structure.png" style="width: 514px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/22701i2ECA83082BECC8DF/image-size/large?v=v2&amp;amp;px=999" role="button" title="import_test_project_structure.png" alt="import_test_project_structure.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The transformer code is below:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from pyspark import pipelines as dp

from project.utils.logger import get_logger
#from utils.logger import get_logger

@dp.table
def sample_users():
    logger = get_logger(__name__)
    logger.info('Running sample_users transformer')
    return (
        spark.read.table("samples.wanderbricks.users")
        .select("user_id", "email", "name", "user_type")
    )&lt;/LI-CODE&gt;&lt;P&gt;After deploying the bundle, I tried running the job but it still fails to import the&amp;nbsp;&lt;EM&gt;logger&lt;/EM&gt; module.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Traceback (most recent call last):
File "/Workspace/Users/.../.bundle/import_test/dev/files/src/project/pipelines/import_test/transformations/sample_users.py", cell 1, line 3
      1 from pyspark import pipelines as dp
----&amp;gt; 3 from project.utils.logger import get_logger
      4 #from utils.logger import get_logger
      6 @dp.table
      7 def sample_users():

File "/databricks/python_shell/lib/dbruntime/autoreload/discoverability/hook.py", line 71, in AutoreloadDiscoverabilityHook._patched_import(self, name, *args, **kwargs)
     65 if not self._should_hint and (
     66     (module := sys.modules.get(absolute_name)) is not None and
     67     (fname := get_allowed_file_name_or_none(module)) is not None and
     68     (mtime := os.stat(fname).st_mtime) &amp;gt; self.last_mtime_by_modname.get(
     69         absolute_name, float("inf")) and not self._should_hint):
     70     self._should_hint = True
---&amp;gt; 71 module = self._original_builtins_import(name, *args, **kwargs)
     72 if (fname := fname or get_allowed_file_name_or_none(module)) is not None:
     73     mtime = mtime or os.stat(fname).st_mtime

ModuleNotFoundError: No module named 'project'
Error: [update_progress]  Update 803be7 is FAILED.&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;I tried importing from both "project.utils.logger" and "utils.logger" and neither worked.&lt;/P&gt;&lt;P&gt;Can you help me figure out what I'm doing wrong?&lt;/P&gt;</description>
      <pubDate>Mon, 05 Jan 2026 17:51:45 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-do-i-import-a-python-module-when-deploying-with-dab/m-p/143050#M52083</guid>
      <dc:creator>kenny_hero</dc:creator>
      <dc:date>2026-01-05T17:51:45Z</dc:date>
    </item>
    <item>
      <title>Re: How do I import a python module when deploying with DAB?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-do-i-import-a-python-module-when-deploying-with-dab/m-p/143110#M52096</link>
      <description>&lt;P&gt;you have to __init__.py has to be under src/__init__.py folder. looks like you created it under utils/__init__.py&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jan 2026 17:53:27 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-do-i-import-a-python-module-when-deploying-with-dab/m-p/143110#M52096</guid>
      <dc:creator>rcdatabricks</dc:creator>
      <dc:date>2026-01-06T17:53:27Z</dc:date>
    </item>
    <item>
      <title>Re: How do I import a python module when deploying with DAB?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-do-i-import-a-python-module-when-deploying-with-dab/m-p/143112#M52097</link>
      <description>&lt;P&gt;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/155368"&gt;@rcdatabricks&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;I tried that.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2026-01-06 at 10.03.04 AM.png" style="width: 580px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/22720i6205D4CF4E8F1704/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2026-01-06 at 10.03.04 AM.png" alt="Screenshot 2026-01-06 at 10.03.04 AM.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;But import still fails.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;ile "/Workspace/Users/.../.bundle/import_test/dev/files/src/project/pipelines/import_test/transformations/sample_users.py", cell 1, line 3
      1 from pyspark import pipelines as dp
----&amp;gt; 3 from project.utils.logger import get_logger
      4 # from utils.logger import get_logger
      6 @dp.table
      7 def sample_users():

File "/databricks/python_shell/lib/dbruntime/autoreload/discoverability/hook.py", line 71, in AutoreloadDiscoverabilityHook._patched_import(self, name, *args, **kwargs)
     65 if not self._should_hint and (
     66     (module := sys.modules.get(absolute_name)) is not None and
     67     (fname := get_allowed_file_name_or_none(module)) is not None and
     68     (mtime := os.stat(fname).st_mtime) &amp;gt; self.last_mtime_by_modname.get(
     69         absolute_name, float("inf")) and not self._should_hint):
     70     self._should_hint = True
---&amp;gt; 71 module = self._original_builtins_import(name, *args, **kwargs)
     72 if (fname := fname or get_allowed_file_name_or_none(module)) is not None:
     73     mtime = mtime or os.stat(fname).st_mtime

ModuleNotFoundError: No module named 'project'&lt;/LI-CODE&gt;&lt;P&gt;I'm new to Databricks, so I may not fully understand how bundle deployment work. I hope someone can share knowledge to help me with a problem what I feel trivial.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jan 2026 18:13:03 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-do-i-import-a-python-module-when-deploying-with-dab/m-p/143112#M52097</guid>
      <dc:creator>kenny_hero</dc:creator>
      <dc:date>2026-01-06T18:13:03Z</dc:date>
    </item>
    <item>
      <title>Re: How do I import a python module when deploying with DAB?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-do-i-import-a-python-module-when-deploying-with-dab/m-p/144905#M52409</link>
      <description>&lt;P&gt;Just to share knowledge with other readers, I think the best option for now(until Databricks supports adding project root to PYTHONPATH) is to refactor the project to have custom modules in a separate folder, create a wheel when building DAB and declare as dependency of pipeline/job config.&lt;/P&gt;&lt;P&gt;I followed the instruction in &lt;A href="https://docs.databricks.com/aws/en/dev-tools/bundles/library-dependencies#python-wheel-file" target="_self"&gt;this page&lt;/A&gt;, but struggled to make it work. It turned out dependency config is different if pipeline runs on serverless. Instead of using "libraries" as in the instruction , I have to use "environment".&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;resources:
  pipelines:
    &amp;lt;pipeline name&amp;gt;
      environment:
        dependencies:
          - &amp;lt;path to wheel file&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;I wish the instruction included this example for serverless, or Databricks supports same configuration regardless of compute type.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jan 2026 15:51:05 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-do-i-import-a-python-module-when-deploying-with-dab/m-p/144905#M52409</guid>
      <dc:creator>kenny_hero</dc:creator>
      <dc:date>2026-01-22T15:51:05Z</dc:date>
    </item>
    <item>
      <title>Re: How do I import a python module when deploying with DAB?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-do-i-import-a-python-module-when-deploying-with-dab/m-p/145104#M52455</link>
      <description>&lt;P&gt;You dont need to use wheel files . Use glob as the key instead of file -&amp;nbsp;&lt;A href="https://docs.databricks.com/aws/en/dev-tools/bundles/resources#pipelinelibraries" target="_blank" rel="noopener"&gt;https://docs.databricks.com/aws/en/dev-tools/bundles/resources#pipelinelibraries&lt;/A&gt;&lt;BR /&gt;Here is the screenshot .&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="pradeep_singh_0-1769261065125.png" style="width: 400px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/23273i8F09001D409D0A9C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="pradeep_singh_0-1769261065125.png" alt="pradeep_singh_0-1769261065125.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 24 Jan 2026 13:35:42 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-do-i-import-a-python-module-when-deploying-with-dab/m-p/145104#M52455</guid>
      <dc:creator>pradeep_singh</dc:creator>
      <dc:date>2026-01-24T13:35:42Z</dc:date>
    </item>
  </channel>
</rss>

