<?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 Using Init Scipt to execute python notebook at all-purpose cluster level in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/using-init-scipt-to-execute-python-notebook-at-all-purpose/m-p/141473#M51735</link>
    <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;We have&amp;nbsp;setup.py in my databricks workspace.&lt;/P&gt;&lt;P&gt;This script is executed in other transformation scripts using&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;%run /Workspace/Common/setup.py&lt;/LI-CODE&gt;&lt;P&gt;which consume lot of time.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This setup.py internally calls other utilities notebooks using %run&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;%run /Workspace/Common/01_Utilities.py
%run /Workspace/Common/02_Utilities.py&lt;/LI-CODE&gt;&lt;P&gt;We are trying to run setup.py. at cluster level. Currently shell files are allowed in init scripts.&lt;/P&gt;&lt;P&gt;Please help how we can execute this setup.py at cluster level and we can remove execution of this notebook in rest of notebooks.&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/152834"&gt;@Advika&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 09 Dec 2025 07:34:07 GMT</pubDate>
    <dc:creator>prashant151</dc:creator>
    <dc:date>2025-12-09T07:34:07Z</dc:date>
    <item>
      <title>Using Init Scipt to execute python notebook at all-purpose cluster level</title>
      <link>https://community.databricks.com/t5/data-engineering/using-init-scipt-to-execute-python-notebook-at-all-purpose/m-p/141473#M51735</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;We have&amp;nbsp;setup.py in my databricks workspace.&lt;/P&gt;&lt;P&gt;This script is executed in other transformation scripts using&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;%run /Workspace/Common/setup.py&lt;/LI-CODE&gt;&lt;P&gt;which consume lot of time.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This setup.py internally calls other utilities notebooks using %run&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;%run /Workspace/Common/01_Utilities.py
%run /Workspace/Common/02_Utilities.py&lt;/LI-CODE&gt;&lt;P&gt;We are trying to run setup.py. at cluster level. Currently shell files are allowed in init scripts.&lt;/P&gt;&lt;P&gt;Please help how we can execute this setup.py at cluster level and we can remove execution of this notebook in rest of notebooks.&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/152834"&gt;@Advika&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Dec 2025 07:34:07 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/using-init-scipt-to-execute-python-notebook-at-all-purpose/m-p/141473#M51735</guid>
      <dc:creator>prashant151</dc:creator>
      <dc:date>2025-12-09T07:34:07Z</dc:date>
    </item>
    <item>
      <title>Re: Using Init Scipt to execute python notebook at all-purpose cluster level</title>
      <link>https://community.databricks.com/t5/data-engineering/using-init-scipt-to-execute-python-notebook-at-all-purpose/m-p/141488#M51743</link>
      <description>&lt;P&gt;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/129736"&gt;@prashant151&lt;/a&gt;&amp;nbsp;-&amp;nbsp;Unlike legacy (pre-UC) clusters, you cannot directly run a Databricks notebook (like setup.py) from a cluster init script, because init scripts only support shell commands — not %run&amp;nbsp;or notebook execution.&lt;/P&gt;&lt;P&gt;You will need to refactor your setup logic into a Python module and install it via the init script.&lt;/P&gt;&lt;P&gt;I would do below instead&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Refactor steup.py into python package (.whl)&lt;/LI&gt;&lt;LI&gt;Store your .whl to UC Volume&lt;/LI&gt;&lt;LI&gt;Install via Cluster Init Script (Attach this init script to your cluster under Advanced Options → Init Scripts)&lt;/LI&gt;&lt;LI&gt;Now you can import it in your notebook instead of %run&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Dec 2025 11:10:55 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/using-init-scipt-to-execute-python-notebook-at-all-purpose/m-p/141488#M51743</guid>
      <dc:creator>Raman_Unifeye</dc:creator>
      <dc:date>2025-12-09T11:10:55Z</dc:date>
    </item>
    <item>
      <title>Re: Using Init Scipt to execute python notebook at all-purpose cluster level</title>
      <link>https://community.databricks.com/t5/data-engineering/using-init-scipt-to-execute-python-notebook-at-all-purpose/m-p/141718#M51807</link>
      <description>&lt;P&gt;You can’t “%run a notebook” from a cluster init script—init scripts are shell-only and meant for environment setup (install libs, set env vars), not for executing notebooks or sharing Python state across sessions. +1 to what&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/179607"&gt;@Raman_Unifeye&lt;/a&gt;&amp;nbsp;has told.&lt;/P&gt;
&lt;P&gt;Convert your common code into a Python module or wheel and import it in notebooks instead of %run.&lt;/P&gt;
&lt;P&gt;Option 1: Workspace modules (no build step)&lt;/P&gt;
&lt;P&gt;Move Common/01_Utilities.py, 02_Utilities.py into Workspace Files as .py modules (add init.py). Then import them directly (DR 11.3+ auto-adds CWD to PYTHONPATH).&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;from Common.utilities import init_env, foo
init_env()&lt;/LI-CODE&gt;
&lt;P&gt;&lt;SPAN&gt;Option 2: Build a wheel and install per cluster&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Package your code (setup.py or pyproject.toml), build a wheel, then install it as a cluster library or via %pip install /Workspace/.../yourpkg.whl (or from a UC volume). &lt;BR /&gt;Example:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;%pip install /Workspace/Common/dist/yourpkg-0.1.0-py3-none-any.whl
import yourpkg
yourpkg.init_env()&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 12 Dec 2025 05:15:59 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/using-init-scipt-to-execute-python-notebook-at-all-purpose/m-p/141718#M51807</guid>
      <dc:creator>iyashk-DB</dc:creator>
      <dc:date>2025-12-12T05:15:59Z</dc:date>
    </item>
  </channel>
</rss>

