<?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: Python Notebook: How to call another notebook? in Data Engineering</title>
    <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Python-Notebook-How-to-call-another-notebook/m-p/4844032#M12755</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/1269834"&gt;@MangoMagic&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;May I check if this issue has been resolved? If not, Please feel free to contact us if you have any further questions.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Thank you&lt;/P&gt;</description>
    <pubDate>Tue, 07 Oct 2025 05:06:25 GMT</pubDate>
    <dc:creator>v-nmadadi-msft</dc:creator>
    <dc:date>2025-10-07T05:06:25Z</dc:date>
    <item>
      <title>Python Notebook: How to call another notebook?</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Python-Notebook-How-to-call-another-notebook/m-p/4836717#M12554</link>
      <description>&lt;P&gt;I'm using Python Notebook runtime 3.11 specifically. I tried using magic command "%run " to run another workbook from within the master notebook but it doesn't work &lt;span class="lia-unicode-emoji" title=":face_with_rolling_eyes:"&gt;🙄&lt;/span&gt;. Since I want to split out some common functions I use quite often into a common notebook that can load the functions which I can then call in my main notebook without having to copy the same code into each notebook. But this approach would also make the reference notebook easier to maintain and test as it also uses &lt;STRONG&gt;n&lt;/STRONG&gt;&lt;SPAN&gt;&lt;STRONG&gt;otebookutils&lt;/STRONG&gt; library which is only available in Fabric environment. I experimented with creating python whl packages but this is so much work and I would have to copy these files into every python notebook anyway so it is not a great solution, and developing any python libraries in separate IDE like VS Code is bit of headache I would rather avoid. I just want an easy way to reuse code in multiple python notebooks?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I tried using&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;&lt;SPAN&gt;notebookutils&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;notebook&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;/EM&gt;&lt;SPAN&gt;&lt;EM&gt;run&lt;/EM&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;but this doesn't work either:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MangoMagic_0-1758913785199.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1300289i3E50CB738FE93C7A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MangoMagic_0-1758913785199.png" alt="MangoMagic_0-1758913785199.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Sep 2025 19:14:10 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Python-Notebook-How-to-call-another-notebook/m-p/4836717#M12554</guid>
      <dc:creator>MangoMagic</dc:creator>
      <dc:date>2025-09-26T19:14:10Z</dc:date>
    </item>
    <item>
      <title>Re: Python Notebook: How to call another notebook?</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Python-Notebook-How-to-call-another-notebook/m-p/4837000#M12556</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/1269834"&gt;@MangoMagic&lt;/a&gt;,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I use the REST APIs to call other notebooks.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a function that uses the API to start a notebook, and then polls the status of the notebook to check for it to be finished, then I can do other things after the notebook is done.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's some code snippets:&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def _handler_notebook(job: Dict[str, Any]) -&amp;gt; Tuple[int, str]:
    ws_id   = job.get("workspace_id")
    item_id = job.get("item_id")
    pname   = job.get("process_name") or f"job_{job.get('job_id','?')}"
    if not ws_id or not item_id:
        return 1, "Missing workspace_id/item_id for notebook run."
    params = {"RUN_ID": RUN_ID, "ENVIRONMENT": ENVIRONMENT, "LAYER": LAYER, "PROCESS_NAME": pname}
    print(f"[RUN] NOTEBOOK {pname}  ws={ws_id} item={item_id}")
    rc, note = _run_notebook_with_fallback(ws_id, item_id, params)
    print(f"[DONE] NOTEBOOK {pname}  status={'success' if rc==0 else 'failed'}")
    return rc, note&lt;/LI-CODE&gt;&lt;LI-CODE lang="python"&gt;def _run_notebook_with_fallback(ws_id: str, item_id: str, params: Dict[str, Any]) -&amp;gt; Tuple[int, str]:
    ji = _start_job_instance(ws_id, item_id, "RunNotebook", parameters=params)
    final = _poll_job_instance_with_warmup(ws_id, item_id, ji, job_type="RunNotebook")
    st = (final.get("status") or "").lower()
    if st == "completed":
        note = {"jobType":"RunNotebook","jobInstanceId":ji,"status":st}
        return 0, json.dumps(note, default=str)

    if _is_exec_state_not_found(final):
        print("[FALLBACK] Retrying with jobType=Notebook")
        ji2 = _start_job_instance(ws_id, item_id, "Notebook", parameters=params)
        final2 = _poll_job_instance_with_warmup(ws_id, item_id, ji2, job_type="Notebook")
        st2 = (final2.get("status") or "").lower()
        note = {"jobType":"Notebook","jobInstanceId":ji2,"status":st2,
                "previousAttempt":{"jobType":"RunNotebook","jobInstanceId":ji,"status":st,"failureReason":final.get("failureReason")}}
        return (0 if st2=="completed" else 1), json.dumps(note, default=str)

    note = {"jobType":"RunNotebook","jobInstanceId":ji,"status":st,"failureReason":final.get("failureReason")}
    return (1, json.dumps(note, default=str))&lt;/LI-CODE&gt;&lt;LI-CODE lang="python"&gt;def _poll_job_instance_with_warmup(ws_id: str, item_id: str, job_instance_id: str, job_type: str = "RunNotebook") -&amp;gt; dict:
    start = time.time()
    tries = 0
    print(f"[WARMUP] Sleeping {FIRST_POLL_DELAY_SEC}s before first poll (jobType={job_type}, jobInstanceId={job_instance_id})")
    time.sleep(FIRST_POLL_DELAY_SEC)

    while True:
        st = _get_job_instance(ws_id, item_id, job_instance_id)
        status = (st.get("status") or "").lower()
        print(f"[POLL] {job_instance_id} status={status}")

        if status in ("completed", "failed", "cancelled", "canceled", "deduped"):
            if (job_type.lower() in ("runnotebook","notebook")
                and status == "failed"
                and _is_exec_state_not_found(st)
                and (time.time() - start) &amp;lt; EXEC_STATE_WARMUP_SEC):
                backoff = min(POLL_INTERVAL_SEC * max(2, tries + 1), 30)
                print(f"[POLL] transient NotFound during warm-up; retrying in {backoff}s")
                time.sleep(backoff); tries += 1; continue
            return st

        backoff = POLL_INTERVAL_SEC if tries &amp;lt; 3 else min(POLL_INTERVAL_SEC * 2, 30)
        time.sleep(backoff); tries += 1
        if time.time() - start &amp;gt; POLL_TIMEOUT_SEC:
            raise TimeoutError(f"Timeout waiting for job {job_instance_id}; last state={st}")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;If you found this helpful, consider giving some Kudos. If I answered your question or solved your problem, mark this post as the solution.&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 27 Sep 2025 16:18:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Python-Notebook-How-to-call-another-notebook/m-p/4837000#M12556</guid>
      <dc:creator>tayloramy</dc:creator>
      <dc:date>2025-09-27T16:18:50Z</dc:date>
    </item>
    <item>
      <title>Re: Python Notebook: How to call another notebook?</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Python-Notebook-How-to-call-another-notebook/m-p/4837312#M12564</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For your scenario, the simplest way to &lt;STRONG&gt;reuse functions from another notebook&lt;/STRONG&gt; in Fabric is to use the %run magic command.&lt;/P&gt;&lt;P&gt;For example, suppose you have a separate logger notebook (NB_Slv_Logger) with multiple functions, like log(). You can call these functions from another notebook (e.g., your Lander notebook) as follows:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;- At the very top of your other notebook&lt;/STRONG&gt;, add:&lt;/P&gt;&lt;P&gt;%run NB_Slv_Logger&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Yazdan_1-1759104929753.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1300503i95427BBE4DEE826A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Yazdan_1-1759104929753.png" alt="Yazdan_1-1759104929753.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":warning:"&gt;⚠️&lt;/span&gt;Note: It must be the &lt;STRONG&gt;first line&lt;/STRONG&gt; in your notebook code, before any other imports or code execution.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- Then, anywhere inside your notebook, simply call the functions from the logger notebook:&lt;/P&gt;&lt;P&gt;log(stage=stage_name, status="Separator", message="=", level="INFO", pipeline_name=pipeline_name)&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Yazdan_2-1759104974013.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1300504i22A3593A36FCF888/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Yazdan_2-1759104974013.png" alt="Yazdan_2-1759104974013.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This approach allows you to:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Reuse code without copying it into every notebook.&lt;/LI&gt;&lt;LI&gt;Maintain a single source of truth for common functions.&lt;/LI&gt;&lt;LI&gt;Apply an &lt;STRONG&gt;OOP-like approach&lt;/STRONG&gt; in notebook coding in Fabric.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;It’s much simpler than creating Python packages or managing external libraries, especially when your functions depend on Fabric-specific modules like notebookutils.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Sep 2025 00:21:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Python-Notebook-How-to-call-another-notebook/m-p/4837312#M12564</guid>
      <dc:creator>Yazdan</dc:creator>
      <dc:date>2025-09-29T00:21:31Z</dc:date>
    </item>
    <item>
      <title>Re: Python Notebook: How to call another notebook?</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Python-Notebook-How-to-call-another-notebook/m-p/4842205#M12718</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/1269834"&gt;@MangoMagic&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Sat, 04 Oct 2025 13:43:52 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Python-Notebook-How-to-call-another-notebook/m-p/4842205#M12718</guid>
      <dc:creator>v-nmadadi-msft</dc:creator>
      <dc:date>2025-10-04T13:43:52Z</dc:date>
    </item>
    <item>
      <title>Re: Python Notebook: How to call another notebook?</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Python-Notebook-How-to-call-another-notebook/m-p/4844032#M12755</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/1269834"&gt;@MangoMagic&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;May I check if this issue has been resolved? If not, Please feel free to contact us if you have any further questions.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Tue, 07 Oct 2025 05:06:25 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Python-Notebook-How-to-call-another-notebook/m-p/4844032#M12755</guid>
      <dc:creator>v-nmadadi-msft</dc:creator>
      <dc:date>2025-10-07T05:06:25Z</dc:date>
    </item>
    <item>
      <title>Re: Python Notebook: How to call another notebook?</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Python-Notebook-How-to-call-another-notebook/m-p/4844165#M12757</link>
      <description>&lt;P&gt;hi, use %run command to invoke another notebook.&lt;/P&gt;&lt;P&gt;%run &amp;lt;notebook name&amp;gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://learn.microsoft.com/en-us/fabric/data-engineering/author-execute-notebook" target="_blank"&gt;https://learn.microsoft.com/en-us/fabric/data-engineering/author-execute-notebook&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Oct 2025 07:51:41 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Python-Notebook-How-to-call-another-notebook/m-p/4844165#M12757</guid>
      <dc:creator>BalajiL</dc:creator>
      <dc:date>2025-10-07T07:51:41Z</dc:date>
    </item>
    <item>
      <title>Re: Python Notebook: How to call another notebook?</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Python-Notebook-How-to-call-another-notebook/m-p/4847193#M12833</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/1269834"&gt;@MangoMagic&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As we haven’t heard back from you, we wanted to kindly follow up to check if the suggestions &amp;nbsp;provided by the community members for the issue worked. Please feel free to contact us if you have any further questions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks and regards&lt;/P&gt;</description>
      <pubDate>Fri, 10 Oct 2025 04:36:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Python-Notebook-How-to-call-another-notebook/m-p/4847193#M12833</guid>
      <dc:creator>v-nmadadi-msft</dc:creator>
      <dc:date>2025-10-10T04:36:26Z</dc:date>
    </item>
  </channel>
</rss>

