databricks / databricks-vscode

VS Code extension for Databricks
Other
122 stars 21 forks source link

[BUG] Incorrect magics handling #1424

Closed ilia-db closed 2 weeks ago

ilia-db commented 2 weeks ago

Describe the bug Magics that start with the # MAGIC comment aren't handled unless they appear at the start of the cell. There's also an unexpected behaviour when executing the magic at the top of the cell - the cell itself is ignored.

To Reproduce Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Screenshots If applicable, add screenshots to help explain your problem.

System information:

  1. Paste the output ot the Help: About command (CMD-Shift-P).
  2. Databricks Extension Version

Databricks Extension Logs Please attach the databricks extension logs

Additional context Add any other context about the problem here.

ilia-db commented 2 weeks ago

Almost all of the magics we handle are actual cell magics, so it makes sense to only process them if they are at the start of the cell. But we also handle $run in the same way, which looks incorrect

mroy-seedbox commented 2 weeks ago

Isn't that how %run works?

From the docs:

%run must be in a cell by itself, because it runs the entire notebook inline.

ilia-db commented 2 weeks ago

Good point. In ipython it's possible to have multiple %run commands, but I forgot about databricks differences. In the extension we run things with the local ipython, but it makes more sense to be in line with databricks logic, otherwise it won't be possible to run the same file remotely.

Going to close the issue and the PR, thanks a lot for the comment