<?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 How to run a notebook in a .py file in databricks in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/how-to-run-a-notebook-in-a-py-file-in-databricks/m-p/78051#M35453</link>
    <description>&lt;P&gt;The situation is that my colleague was using pycharm and now needs to adapt to databricks. They are now doing their job by connecting VScode to databricks and run the .py file using databricks clusters.&lt;/P&gt;&lt;P&gt;The problem is they want to call a notebook in databricks in the .py file in VScode, the %run command is not working because this command only works in notebook. I am wondering if there is a way to do it?&lt;/P&gt;&lt;P&gt;Thanks so much!&lt;/P&gt;</description>
    <pubDate>Wed, 10 Jul 2024 08:17:30 GMT</pubDate>
    <dc:creator>Littlesheep_</dc:creator>
    <dc:date>2024-07-10T08:17:30Z</dc:date>
    <item>
      <title>How to run a notebook in a .py file in databricks</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-run-a-notebook-in-a-py-file-in-databricks/m-p/78051#M35453</link>
      <description>&lt;P&gt;The situation is that my colleague was using pycharm and now needs to adapt to databricks. They are now doing their job by connecting VScode to databricks and run the .py file using databricks clusters.&lt;/P&gt;&lt;P&gt;The problem is they want to call a notebook in databricks in the .py file in VScode, the %run command is not working because this command only works in notebook. I am wondering if there is a way to do it?&lt;/P&gt;&lt;P&gt;Thanks so much!&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jul 2024 08:17:30 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-run-a-notebook-in-a-py-file-in-databricks/m-p/78051#M35453</guid>
      <dc:creator>Littlesheep_</dc:creator>
      <dc:date>2024-07-10T08:17:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to run a notebook in a .py file in databricks</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-run-a-notebook-in-a-py-file-in-databricks/m-p/78156#M35480</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;BR /&gt;One way I can think of to achieve this is by calling the rest API of Databricks job (Create a job with only one task)&lt;BR /&gt;Check out this documentation for more details.&lt;BR /&gt;&lt;A href="https://docs.databricks.com/api/workspace/jobs/runnow" target="_blank"&gt;https://docs.databricks.com/api/workspace/jobs/runnow&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jul 2024 17:22:46 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-run-a-notebook-in-a-py-file-in-databricks/m-p/78156#M35480</guid>
      <dc:creator>Hkesharwani</dc:creator>
      <dc:date>2024-07-10T17:22:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to run a notebook in a .py file in databricks</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-run-a-notebook-in-a-py-file-in-databricks/m-p/78245#M35490</link>
      <description>&lt;P&gt;You can do so by adding your own dbutils function in your py file:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def get_dbutils():
    """
    This is to make your local env (and flake  happy."""
    from pyspark.sql import SparkSession

    spark = SparkSession.getActiveSession()
    if spark.conf.get("spark.databricks.service.client.enabled") == "true":
        from pyspark.dbutils import DBUtils

        return DBUtils(spark)
    else:
        import IPython

        return IPython.get_ipython().user_ns["dbutils"]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;And then run the notebook from the py file using the following way:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;get_dbutils().notebook.run('path/to/notebook', &amp;lt;timeout_in_seconds&amp;gt;) &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Good luck!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jul 2024 05:23:36 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-run-a-notebook-in-a-py-file-in-databricks/m-p/78245#M35490</guid>
      <dc:creator>jacovangelder</dc:creator>
      <dc:date>2024-07-11T05:23:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to run a notebook in a .py file in databricks</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-run-a-notebook-in-a-py-file-in-databricks/m-p/79285#M35720</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/111437"&gt;@Littlesheep_&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thank you for reaching out to our community! We're here to help you.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;To ensure we provide you with the best support, could you please take a moment to review the response and choose the one that best answers your question? Your feedback not only helps us assist you better but also benefits other community members who may have similar questions in the future.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If you found the answer helpful, consider giving it a kudo. If the response fully addresses your question, please mark it as the accepted solution. This will help us close the thread and ensure your question is resolved.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;We appreciate your participation and are here to assist you further if you need it!&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Rishabh&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2024 16:38:26 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-run-a-notebook-in-a-py-file-in-databricks/m-p/79285#M35720</guid>
      <dc:creator>RishabhTiwari07</dc:creator>
      <dc:date>2024-07-18T16:38:26Z</dc:date>
    </item>
  </channel>
</rss>

