<?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: Notebook shows 'In Progress' in Monitor App even after it has returned with an error? in Data Engineering</title>
    <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Notebook-shows-In-Progress-in-Monitor-App-even-after-it-has/m-p/4326816#M5595</link>
    <description>&lt;P&gt;Seems like I've stumbled upon some interesting... features... of the pyspark notebooks.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;If you exit unexpectedly from an interactive session - it will keep the session open until it times out, or you manually stop it.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;This also effectively means that interactive notebooks can never enter a failed status AFAIK.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 12 Dec 2024 22:32:39 GMT</pubDate>
    <dc:creator>IntegrateGuru</dc:creator>
    <dc:date>2024-12-12T22:32:39Z</dc:date>
    <item>
      <title>Notebook shows 'In Progress' in Monitor App even after it has returned with an error?</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Notebook-shows-In-Progress-in-Monitor-App-even-after-it-has/m-p/4326800#M5594</link>
      <description>&lt;P&gt;I've noticed that if I run a pyspark notebook with just the following code:&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;myVal = 1/0&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;And execute the notebook, the notebook will return very quickly with&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;ZeroDivisionError: division by zero&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;BR /&gt;However, when I go into the monitor app to view the status of the notebook, the status is 'In Progress'.&amp;nbsp;&lt;BR /&gt;It will remain 'In Progress' until the spark session times out, using our compute resources the entire time. Looking at the spark UI, it looks like right after the first executor is deallocated, a 2nd executor is allocated and then never deallocated, unexplicably.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;What would cause this, and how can I avoid it?&lt;BR /&gt;&lt;BR /&gt;The notebook should enter the error state, and immediately stop processing. It will not do so unless I manually cancel the notebook. Additionally, any subsequent runs of the notebook after the first is running, are not recorded by the Monitor App at all, while the original run is still going.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Dec 2024 22:01:57 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Notebook-shows-In-Progress-in-Monitor-App-even-after-it-has/m-p/4326800#M5594</guid>
      <dc:creator>IntegrateGuru</dc:creator>
      <dc:date>2024-12-12T22:01:57Z</dc:date>
    </item>
    <item>
      <title>Re: Notebook shows 'In Progress' in Monitor App even after it has returned with an error?</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Notebook-shows-In-Progress-in-Monitor-App-even-after-it-has/m-p/4326816#M5595</link>
      <description>&lt;P&gt;Seems like I've stumbled upon some interesting... features... of the pyspark notebooks.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;If you exit unexpectedly from an interactive session - it will keep the session open until it times out, or you manually stop it.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;This also effectively means that interactive notebooks can never enter a failed status AFAIK.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Dec 2024 22:32:39 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Notebook-shows-In-Progress-in-Monitor-App-even-after-it-has/m-p/4326816#M5595</guid>
      <dc:creator>IntegrateGuru</dc:creator>
      <dc:date>2024-12-12T22:32:39Z</dc:date>
    </item>
    <item>
      <title>Re: Notebook shows 'In Progress' in Monitor App even after it has returned with an error?</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Notebook-shows-In-Progress-in-Monitor-App-even-after-it-has/m-p/4327452#M5598</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/802656"&gt;@IntegrateGuru&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The default timeout fro spark session is 20 mins, but you can configure this in workspace setting. We have to manually stop the spark session otherwise it will be available till the default timeout.&lt;/P&gt;&lt;P&gt;you can add mssparkutils.session.stop() to stop the session at the end of all your notebook .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Srisakthi&lt;/P&gt;</description>
      <pubDate>Fri, 13 Dec 2024 07:09:29 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Notebook-shows-In-Progress-in-Monitor-App-even-after-it-has/m-p/4327452#M5598</guid>
      <dc:creator>Srisakthi</dc:creator>
      <dc:date>2024-12-13T07:09:29Z</dc:date>
    </item>
    <item>
      <title>Re: Notebook shows 'In Progress' in Monitor App even after it has returned with an error?</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Notebook-shows-In-Progress-in-Monitor-App-even-after-it-has/m-p/4327501#M5600</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/802656"&gt;@IntegrateGuru&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Each notebook activity in the Monitor hub represents the spark application for a session. When you run a notebook, it initializes a spark session and creates a spark application. The "Status" represents the status of the session, rather than the running status of a code snippet in the notebook.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="vjingzhanmsft_0-1734074675507.png" style="width: 999px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1214622i4853DC3894825C5B/image-size/large?v=v2&amp;amp;px=999" role="button" title="vjingzhanmsft_0-1734074675507.png" alt="vjingzhanmsft_0-1734074675507.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can also use&amp;nbsp;&lt;SPAN&gt;&lt;STRONG&gt;notebookutils.session.stop()&lt;/STRONG&gt; to stop&amp;nbsp;&lt;/SPAN&gt;an interactive session&amp;nbsp;&lt;SPAN&gt;and release resources occupied by the session.&amp;nbsp;&lt;/SPAN&gt;&lt;A style="font-family: inherit; background-color: #ffffff;" href="https://learn.microsoft.com/en-us/fabric/data-engineering/notebook-utilities#stop-an-interactive-session" target="_blank" rel="noopener"&gt;NotebookUtils (former MSSparkUtils) for Fabric - Microsoft Fabric | Microsoft Learn&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Jing&lt;/P&gt;</description>
      <pubDate>Fri, 13 Dec 2024 07:39:08 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Notebook-shows-In-Progress-in-Monitor-App-even-after-it-has/m-p/4327501#M5600</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-12-13T07:39:08Z</dc:date>
    </item>
    <item>
      <title>Re: Notebook shows 'In Progress' in Monitor App even after it has returned with an error?</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Notebook-shows-In-Progress-in-Monitor-App-even-after-it-has/m-p/4327693#M5602</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/802656"&gt;@IntegrateGuru&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Why you need to keep the session open when exit unexpectedly or having exception errors like division by zero or why you need to manually stop? You can automate this process after implementing either of these like exception handling or update the environment settings.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# Handling errors properly in the Notebook by catching errors explicitly and stop the Spark Session when exception occurs. It is terminating the session and free the resources immediately.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from pyspark.sql import SparkSession

try:
    myVal = 1 / 0
except ZeroDivisionError as e:
    print(f"Error encountered: {e}")
    spark = SparkSession.getActiveSession()
    if spark:
        spark.stop()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# Check the notebook environment settings for timeout and error-handling configurations to terminate the Spark session on task failure. Inside the settings you can find out spark.dynamicAllocation.enabled and spark.dynamicAllocation.executeIdleTimeout. Also you can consider to reduce the executor idle timeout to free resources immediately when you have done.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Ash&lt;/P&gt;</description>
      <pubDate>Fri, 13 Dec 2024 09:31:47 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Notebook-shows-In-Progress-in-Monitor-App-even-after-it-has/m-p/4327693#M5602</guid>
      <dc:creator>nalinash</dc:creator>
      <dc:date>2024-12-13T09:31:47Z</dc:date>
    </item>
    <item>
      <title>Re: Notebook shows 'In Progress' in Monitor App even after it has returned with an error?</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Notebook-shows-In-Progress-in-Monitor-App-even-after-it-has/m-p/4328090#M5608</link>
      <description>&lt;P&gt;Thanks, this seems correct.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Is there any way to set the status of a notebook to 'failed' then? We want to be able to view when our scripts run into errors, using an activator that listens to the activity status to go to a failed state.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Dec 2024 14:04:14 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Notebook-shows-In-Progress-in-Monitor-App-even-after-it-has/m-p/4328090#M5608</guid>
      <dc:creator>IntegrateGuru</dc:creator>
      <dc:date>2024-12-13T14:04:14Z</dc:date>
    </item>
    <item>
      <title>Re: Notebook shows 'In Progress' in Monitor App even after it has returned with an error?</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Notebook-shows-In-Progress-in-Monitor-App-even-after-it-has/m-p/4340561#M5740</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/802656"&gt;@IntegrateGuru&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to view the&amp;nbsp;contextual monitoring logs after running an interactive notebook, there are logs below every code cell.&amp;nbsp;&lt;A href="https://learn.microsoft.com/en-us/fabric/data-engineering/spark-monitor-debug" target="_blank" rel="noopener"&gt;Notebook contextual monitoring and debugging - Microsoft Fabric | Microsoft Learn&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to set the status of a notebook to "failed", perhaps you can consider creating a data pipeline to invoke the notebook. Monitor the status of the notebook activity or the output of the notebook. One idea is:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;At the ending cell of a notebook, use&amp;nbsp;&lt;SPAN&gt;&lt;STRONG&gt;notebookutils.notebook.exit()&lt;/STRONG&gt; to &lt;A href="https://learn.microsoft.com/en-us/fabric/data-engineering/notebook-utilities#exit-a-notebook" target="_blank" rel="noopener"&gt;exit a notebook&lt;/A&gt; with an exit value like "Failed".&amp;nbsp;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;Create a data pipeline to invoke the notebook (&lt;A href="https://learn.microsoft.com/en-us/fabric/data-factory/notebook-activity" target="_blank" rel="noopener"&gt;Notebook activity&lt;/A&gt;).&amp;nbsp;&lt;SPAN&gt;When you orchestrate a notebook in a pipeline that calls an&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;EM style="font-family: inherit;"&gt;exit()&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;function, the notebook activity returns with an exit value, completes the pipeline run, and stops the Spark session.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN&gt;Check the snapshot of a notebook activity in the data pipeline to know its status and snapshot in a run:&amp;nbsp;&lt;A href="https://community.fabric.microsoft.com/t5/Data-Engineering/Snapshot-of-Notebook-from-Pipeline-in-real-time/m-p/4327493" target="_blank" rel="noopener"&gt;Snapshot of Notebook from Pipeline in ... - Microsoft Fabric Community&lt;/A&gt;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN&gt;(Alternative) You can also add a &lt;A href="https://learn.microsoft.com/en-us/fabric/data-factory/fail-activity" target="_blank" rel="noopener"&gt;Fail activity&lt;/A&gt;&amp;nbsp;after the notebook activity, and customize its error messages and error codes.&amp;nbsp;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Hope this would be helpful.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Best Regards,&lt;BR /&gt;Jing&lt;BR /&gt;&lt;EM&gt;If this post helps, please Accept it as Solution to help other members find it. Appreciate your Kudos! &lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Dec 2024 08:27:37 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Notebook-shows-In-Progress-in-Monitor-App-even-after-it-has/m-p/4340561#M5740</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-12-23T08:27:37Z</dc:date>
    </item>
  </channel>
</rss>

