<?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 Why is the current path different when executing a Notebook from Repos vs Workspace? in missing-QuestionPost</title>
    <link>https://community.databricks.com/t5/missing-questionpost/why-is-the-current-path-different-when-executing-a-notebook-from/m-p/2763#M15</link>
    <description>&lt;P&gt;When executing the same Notebook from Repos and Workspace, the current path (`os.getcwd()`) is different:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Repos=/Workspace/Repos/USERID/REPONAME.ide/pricing&lt;/LI&gt;&lt;LI&gt;Workspace=/home/spark-1636b562-0ce7-473b-bb17-56&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The issue is the Databricks VScode extension recommends switching from Repos to Workspace, but then all the notebook code containing relative path to the notebook doesn't work anymore.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Would it be possible to have Workspace behave the same way as Repos?&lt;/P&gt;</description>
    <pubDate>Wed, 21 Jun 2023 14:39:32 GMT</pubDate>
    <dc:creator>Duy</dc:creator>
    <dc:date>2023-06-21T14:39:32Z</dc:date>
    <item>
      <title>Why is the current path different when executing a Notebook from Repos vs Workspace?</title>
      <link>https://community.databricks.com/t5/missing-questionpost/why-is-the-current-path-different-when-executing-a-notebook-from/m-p/2763#M15</link>
      <description>&lt;P&gt;When executing the same Notebook from Repos and Workspace, the current path (`os.getcwd()`) is different:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Repos=/Workspace/Repos/USERID/REPONAME.ide/pricing&lt;/LI&gt;&lt;LI&gt;Workspace=/home/spark-1636b562-0ce7-473b-bb17-56&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The issue is the Databricks VScode extension recommends switching from Repos to Workspace, but then all the notebook code containing relative path to the notebook doesn't work anymore.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Would it be possible to have Workspace behave the same way as Repos?&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jun 2023 14:39:32 GMT</pubDate>
      <guid>https://community.databricks.com/t5/missing-questionpost/why-is-the-current-path-different-when-executing-a-notebook-from/m-p/2763#M15</guid>
      <dc:creator>Duy</dc:creator>
      <dc:date>2023-06-21T14:39:32Z</dc:date>
    </item>
    <item>
      <title>Re: Why is the current path different when executing a Notebook from Repos vs Workspace?</title>
      <link>https://community.databricks.com/t5/missing-questionpost/why-is-the-current-path-different-when-executing-a-notebook-from/m-p/2764#M16</link>
      <description>&lt;P&gt;Found a work around:&lt;/P&gt;&lt;P&gt;``` Python&lt;/P&gt;&lt;P&gt;import os&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;notebook_dir = os.path.dirname(dbutils.notebook.entry_point.getDbutils().notebook().getContext().notebookPath().get())&lt;/P&gt;&lt;P&gt;notebook_dir = "/Workspace" + notebook_dir&lt;/P&gt;&lt;P&gt;current_dir = os.getcwd()&lt;/P&gt;&lt;P&gt;if current_dir != notebook_dir:&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; print(f"Switching current dir to: {notebook_dir}")&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; os.chdir(notebook_dir)&lt;/P&gt;&lt;P&gt;```&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jun 2023 00:14:00 GMT</pubDate>
      <guid>https://community.databricks.com/t5/missing-questionpost/why-is-the-current-path-different-when-executing-a-notebook-from/m-p/2764#M16</guid>
      <dc:creator>Duy</dc:creator>
      <dc:date>2023-06-22T00:14:00Z</dc:date>
    </item>
  </channel>
</rss>

