paiqo / Databricks-VSCode

VSCode extension to work with Databricks
GNU General Public License v3.0
123 stars 27 forks source link

Different behavior when using recursive "%run" magic command #161

Closed lomizandtyd closed 1 year ago

lomizandtyd commented 1 year ago

Hi,

The nested magic command issue I encountered is:

  1. I have a init.ipynb with multiple %run xxx magic commands to import multiple notebooks.
  2. I have a task.ipynb with %run init to import all functions with one magic command.
  3. When I run the task.ipynb with power tools in VS Code, the output differs from what I get in databricks web editor.
  4. After run %run init, cells below in task.ipynb couldn't read the definitions in xxx.ipynb. But it works in web editor.
  5. If I run %run xxx in task.ipynb directly, I could get the definitions here.

The output of run %run init in task.ipynb with Databricks Power Tools in VS Code: image

It outputs the source code of init.ipynb.

The output of run %run init in webui. image

Does nested magic command run work?

gbrueckl commented 1 year ago

unfortunately nested %run calls are not supported - this is also stated in the README.md:

However, there are some known limitations to %run as listed blow:

  • cells of referenced notebooks that use magics are not executed
    • this also applies to %run (see below)
  • nested %run statements are not supported

please also see https://github.com/paiqo/Databricks-VSCode/issues/152 https://github.com/paiqo/Databricks-VSCode/issues/154

krzysztof-nawara-bp commented 1 year ago

@gbrueckl Sorry if this is not the right place to ask the question, but was it always the case that %MAGIC cells in %run notebooks are not executed? I used to have %autoreload in one of the notebooks that I'm %run'ing and I'm 90% it worked in the past

gbrueckl commented 1 year ago

@krzysztof-nawara-bp yes, as of now, it is not supported by our extension to use nested %run / %magic cells

it also never worked in the past as it would require a lot of rework in our extension which was not done yet, however ,it works (and always worked) if you execute the notebook from the Databricks Web UI - thats probably where the confusion comes from