<?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: Gracefully stop a job based on condition in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/gracefully-stop-a-job-based-on-condition/m-p/37636#M26408</link>
    <description>&lt;P&gt;Yes, you're correct. The downstream tasks would still be triggered.&amp;nbsp;&lt;BR /&gt;You can try cancelling the run using the &lt;A href="https://docs.databricks.com/api/workspace/jobs/cancelrun" target="_blank" rel="noopener"&gt;Jobs API&lt;/A&gt;? But I don't think that is what you are looking for as you want the job run to have success state.&lt;/P&gt;&lt;P&gt;Maybe propagating the check using&amp;nbsp;&lt;A href="https://docs.databricks.com/dev-tools/databricks-utils.html#taskvalues-subutility-dbutilsjobstaskvalues" target="_blank" rel="noopener"&gt;Task values&lt;/A&gt;&amp;nbsp;can be an option or simply add the check to every task.&lt;/P&gt;</description>
    <pubDate>Fri, 14 Jul 2023 14:35:02 GMT</pubDate>
    <dc:creator>menotron</dc:creator>
    <dc:date>2023-07-14T14:35:02Z</dc:date>
    <item>
      <title>Gracefully stop a job based on condition</title>
      <link>https://community.databricks.com/t5/data-engineering/gracefully-stop-a-job-based-on-condition/m-p/37610#M26397</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a job with many tasks running on a schedule, and the first tasks checks a condition. Based on the condition, I would either want to continue the job as normal, or to stop right away and don't run all the other tasks. Is there a way to do this without having the job in a failed state ?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jul 2023 06:26:02 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/gracefully-stop-a-job-based-on-condition/m-p/37610#M26397</guid>
      <dc:creator>erigaud</dc:creator>
      <dc:date>2023-07-14T06:26:02Z</dc:date>
    </item>
    <item>
      <title>Re: Gracefully stop a job based on condition</title>
      <link>https://community.databricks.com/t5/data-engineering/gracefully-stop-a-job-based-on-condition/m-p/37628#M26404</link>
      <description>&lt;P&gt;You can use the&amp;nbsp;&lt;SPAN&gt;dbutils.notebook.exit(&lt;/SPAN&gt;&lt;SPAN class=""&gt;"returnValue"&lt;/SPAN&gt;&lt;SPAN&gt;) as explained &lt;A href="https://learn.microsoft.com/en-us/azure/databricks/notebooks/notebook-workflows#:~:text=exit(value%3A%20String,throw%20an%20exception." target="_self"&gt;here&lt;/A&gt; stop execution of a notebook gracefully.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;if condition:
  pass
else:
  dbutils.notebook.exit("Aborting as ondition not met. Further tasks will be skipped")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jul 2023 12:51:13 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/gracefully-stop-a-job-based-on-condition/m-p/37628#M26404</guid>
      <dc:creator>menotron</dc:creator>
      <dc:date>2023-07-14T12:51:13Z</dc:date>
    </item>
    <item>
      <title>Re: Gracefully stop a job based on condition</title>
      <link>https://community.databricks.com/t5/data-engineering/gracefully-stop-a-job-based-on-condition/m-p/37629#M26405</link>
      <description>&lt;P&gt;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/84270"&gt;@erigaud&lt;/a&gt;&amp;nbsp;Hi. The below two approaches could help.&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. dbutils.notebook.exit() --&amp;gt; This will stop the job. You can even pass any values in the parenthesis to print based on your requirement.&lt;/P&gt;&lt;P&gt;2. Using sys.exit(0) -&amp;gt; This comes with sys module and you can use this as well to exit your job. Both will work. You can try and let me know.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jul 2023 13:14:18 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/gracefully-stop-a-job-based-on-condition/m-p/37629#M26405</guid>
      <dc:creator>pvignesh92</dc:creator>
      <dc:date>2023-07-14T13:14:18Z</dc:date>
    </item>
    <item>
      <title>Re: Gracefully stop a job based on condition</title>
      <link>https://community.databricks.com/t5/data-engineering/gracefully-stop-a-job-based-on-condition/m-p/37630#M26406</link>
      <description>&lt;P&gt;I would want the full job to stop (including subsequent tasks) but running&amp;nbsp;&lt;SPAN&gt;dbutils.notebook.exit()&amp;nbsp; will success the current task and move on to the next task right ? I would want the job to finish right away in a success state&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jul 2023 13:33:15 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/gracefully-stop-a-job-based-on-condition/m-p/37630#M26406</guid>
      <dc:creator>erigaud</dc:creator>
      <dc:date>2023-07-14T13:33:15Z</dc:date>
    </item>
    <item>
      <title>Re: Gracefully stop a job based on condition</title>
      <link>https://community.databricks.com/t5/data-engineering/gracefully-stop-a-job-based-on-condition/m-p/37636#M26408</link>
      <description>&lt;P&gt;Yes, you're correct. The downstream tasks would still be triggered.&amp;nbsp;&lt;BR /&gt;You can try cancelling the run using the &lt;A href="https://docs.databricks.com/api/workspace/jobs/cancelrun" target="_blank" rel="noopener"&gt;Jobs API&lt;/A&gt;? But I don't think that is what you are looking for as you want the job run to have success state.&lt;/P&gt;&lt;P&gt;Maybe propagating the check using&amp;nbsp;&lt;A href="https://docs.databricks.com/dev-tools/databricks-utils.html#taskvalues-subutility-dbutilsjobstaskvalues" target="_blank" rel="noopener"&gt;Task values&lt;/A&gt;&amp;nbsp;can be an option or simply add the check to every task.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jul 2023 14:35:02 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/gracefully-stop-a-job-based-on-condition/m-p/37636#M26408</guid>
      <dc:creator>menotron</dc:creator>
      <dc:date>2023-07-14T14:35:02Z</dc:date>
    </item>
    <item>
      <title>Re: Gracefully stop a job based on condition</title>
      <link>https://community.databricks.com/t5/data-engineering/gracefully-stop-a-job-based-on-condition/m-p/37638#M26409</link>
      <description>&lt;P&gt;I think the best way to accomplish this would be to either propagate the check, as mentionned by&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/64686"&gt;@menotron&lt;/a&gt;,&amp;nbsp;or have the initial task in another job, and only run the second job if the condition is met. Obviously it depends on the use case. Thank you for taking the time to answer !&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jul 2023 14:45:47 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/gracefully-stop-a-job-based-on-condition/m-p/37638#M26409</guid>
      <dc:creator>erigaud</dc:creator>
      <dc:date>2023-07-14T14:45:47Z</dc:date>
    </item>
  </channel>
</rss>

