<?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 Get notebook_id of running notebook in high concurrency in Data Science</title>
    <link>https://community.fabric.microsoft.com/t5/Data-Science/Get-notebook-id-of-running-notebook-in-high-concurrency/m-p/4367023#M598</link>
    <description>&lt;P&gt;Hi Community&lt;/P&gt;&lt;P&gt;I have a small issue I hope someone may guide me to a solution. I simply want to know the notebook_id of the running notebook (without hardcoding the name of the notebook). I have used the function get_artifact_id() from sempy.fabric library. This will give the notebook_id – however if the notebook is joining a high concurrency session you will get the notebook_id of the notebook that started the session and not the one that is running.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If anyone have some input it will be much appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Kim Tutein&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Appendix – example will work when running in separate session but not if joining high concurrency session&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;from sempy import fabric&lt;/P&gt;&lt;P&gt;notebook_id = fabric.get_artifact_id() #notebook id&lt;/P&gt;&lt;P&gt;print(notebook_id)&lt;/P&gt;</description>
    <pubDate>Thu, 16 Jan 2025 10:51:11 GMT</pubDate>
    <dc:creator>KimTutein</dc:creator>
    <dc:date>2025-01-16T10:51:11Z</dc:date>
    <item>
      <title>Get notebook_id of running notebook in high concurrency</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Science/Get-notebook-id-of-running-notebook-in-high-concurrency/m-p/4367023#M598</link>
      <description>&lt;P&gt;Hi Community&lt;/P&gt;&lt;P&gt;I have a small issue I hope someone may guide me to a solution. I simply want to know the notebook_id of the running notebook (without hardcoding the name of the notebook). I have used the function get_artifact_id() from sempy.fabric library. This will give the notebook_id – however if the notebook is joining a high concurrency session you will get the notebook_id of the notebook that started the session and not the one that is running.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If anyone have some input it will be much appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Kim Tutein&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Appendix – example will work when running in separate session but not if joining high concurrency session&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;from sempy import fabric&lt;/P&gt;&lt;P&gt;notebook_id = fabric.get_artifact_id() #notebook id&lt;/P&gt;&lt;P&gt;print(notebook_id)&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jan 2025 10:51:11 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Science/Get-notebook-id-of-running-notebook-in-high-concurrency/m-p/4367023#M598</guid>
      <dc:creator>KimTutein</dc:creator>
      <dc:date>2025-01-16T10:51:11Z</dc:date>
    </item>
    <item>
      <title>Re: Get notebook_id of running notebook in high concurrency</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Science/Get-notebook-id-of-running-notebook-in-high-concurrency/m-p/4367313#M600</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="393240" data-lia-user-login="KimTutein" class="lia-mention lia-mention-user"&gt;KimTutein&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;In a high-concurrency session in Microsoft Fabric, obtaining the&amp;nbsp;notebook_id&amp;nbsp;of the currently running notebook can be challenging because the&amp;nbsp;&lt;STRONG&gt;fabric.get_artifact_id()&amp;nbsp;&lt;/STRONG&gt;function from the SemPy library retrieves the ID of the notebook that initiated the shared Spark session, rather than the specific notebook currently running. This behavior is due to how high-concurrency sessions are designed to share a single Spark context across multiple notebooks, improving efficiency and reducing costs.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If it is possible, avoid joining a high-concurrency session and instead run the notebook in its own Spark session. This ensures that&amp;nbsp;fabric.get_artifact_id()&amp;nbsp;returns the correct&amp;nbsp;notebook_id&amp;nbsp;for the running notebook.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;else implement logging mechanisms where each notebook logs its execution details (such as its name or purpose) into a shared storage or monitoring system. This can help identify which notebook is running without relying solely on notebok_id&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I havent explored it yet but worth exploring&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;Session Metadata or Tagging&lt;/STRONG&gt;:&lt;/SPAN&gt;&lt;SPAN&gt;High-concurrency sessions in Fabric allow tagging of sessions or notebooks for identification. However, there is no direct API to dynamically fetch the specific&amp;nbsp;notebook_id&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;within such sessions. You may consider using custom tags or metadata to track notebooks manually.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;If this post helps, then please give us Kudos and consider Accept it as a solution to help the other members find it more quickly.&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jan 2025 12:51:11 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Science/Get-notebook-id-of-running-notebook-in-high-concurrency/m-p/4367313#M600</guid>
      <dc:creator>nilendraFabric</dc:creator>
      <dc:date>2025-01-16T12:51:11Z</dc:date>
    </item>
    <item>
      <title>Re: Get notebook_id of running notebook in high concurrency</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Science/Get-notebook-id-of-running-notebook-in-high-concurrency/m-p/4367339#M603</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="913195" data-lia-user-login="nilendraFabric" class="lia-mention lia-mention-user"&gt;nilendraFabric&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your answer. For now we are simple not running notebooks in high concurrency. As we are using private endpoint we have to wait 3-6 minutes for every startup. As we use the notebook_id in our logging it is very important for us. For now I guess there is not solution to get the correct notebook_id other than hardcode the name of the notebook and lookup the id looping thorugh the items in the workspace. However this is not a very safe way of doint this as if the notebook change name it will no longer find the correct workspace_id&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jan 2025 13:07:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Science/Get-notebook-id-of-running-notebook-in-high-concurrency/m-p/4367339#M603</guid>
      <dc:creator>KimTutein</dc:creator>
      <dc:date>2025-01-16T13:07:13Z</dc:date>
    </item>
    <item>
      <title>Re: Get notebook_id of running notebook in high concurrency</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Science/Get-notebook-id-of-running-notebook-in-high-concurrency/m-p/4372765#M609</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="393240" data-lia-user-login="KimTutein" class="lia-mention lia-mention-user"&gt;KimTutein&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Thank you for reaching out microsoft fabric community forum.&lt;BR /&gt;&lt;SPAN data-teams="true"&gt;I tried to look for alternate solution in Sempy library and it seems your conclusion is correct but i would suggest to once try&lt;STRONG&gt;&lt;STRONG&gt;&lt;SPAN class=""&gt;print(notebookutils.runtime.context[&lt;SPAN class=""&gt;'currentNotebookId'])&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN data-teams="true"&gt;and check how it behaves for private endpoint.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;If you need any further assistance or have any questions, please feel free to reach us.&lt;BR /&gt;&lt;BR /&gt;If this solution helps, please consider giving us&amp;nbsp;&lt;STRONG&gt;Kudos&amp;nbsp;&lt;/STRONG&gt;and&amp;nbsp;&lt;STRONG&gt;&lt;STRONG&gt;accepting it as the solution&amp;nbsp;&lt;/STRONG&gt;&lt;/STRONG&gt;so that it may assist other members in the community.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Thanks and Regards.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jan 2025 04:28:59 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Science/Get-notebook-id-of-running-notebook-in-high-concurrency/m-p/4372765#M609</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2025-01-21T04:28:59Z</dc:date>
    </item>
    <item>
      <title>Re: Get notebook_id of running notebook in high concurrency</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Science/Get-notebook-id-of-running-notebook-in-high-concurrency/m-p/4372928#M610</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I allso tried looking all around the Sempy library without luck. However I tried your solution with notebookutills and that works fine -- also with privete endpoint &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; :-).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is very important for us if running in high concurrency so thank you very much for your help and guidance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Kim Tutein&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jan 2025 06:17:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Science/Get-notebook-id-of-running-notebook-in-high-concurrency/m-p/4372928#M610</guid>
      <dc:creator>KimTutein</dc:creator>
      <dc:date>2025-01-21T06:17:17Z</dc:date>
    </item>
  </channel>
</rss>

