databrickslabs / brickster

R Toolkit for Databricks
https://databrickslabs.github.io/brickster/
Apache License 2.0
49 stars 8 forks source link

Not able to use magic commands in the Markdown chunks #31

Closed Hbinfinity closed 1 year ago

Hbinfinity commented 1 year ago

I'm able to successfully open a connection with Databricks in RStudio and able to execute code in the Markdown chunks.

However I'm wondering now if I can use magic commands (more specifically, %run) in the markdown chunks. It's an important part of our developments and workflows, I'm trying to do something like:

%run /Users/xxxxx/some_notebook

But it is not working, I get an error:

Error: Error in parse(text = DATABRICKS_CURRENT_TEMP_CMD__) : 
  <text>:2:1: unexpected input
1: {
2: %run /Users/xxxxx/some_notebook
   ^
Error in parse(text = DATABRICKS_CURRENT_TEMP_CMD__): <text>:2:1: unexpected input
Error in parse(text = DATABRICKS_CURRENT_TEMP_CMD__): <text>:2:1: unexpected input
1: {
2: %run /Users/xxxxx/some_notebook
   ^

The other option would be use dbutils.run.notebook command with a python engine, I guess? (What about other magic commands like %sh, %pip commands, %fs, etc though)? This is ofcourse an "immediate-getting-started" effort with some of our customers; the more generic question that I'm trying to ask is, how do we work in a modularised manner? Multiple markdown files and calling them in each other? Something like the following in an orchestrating markdown?

rmarkdown::render("test1.Rmd")

How can we use these markdown files to deploy code to higher environments? Can these be used directly somehow or do we need to do something else?

zacdav-db commented 1 year ago

Sorry I totally missed this issue.

Brickster currently doesn't have a way to support %run magic due to how the context API's that Databricks surfaces work. The only supported contexts are those for r, python, sql, scala.

You'd need to work within those confines, so dbutils is completely valid way to go about it.

the more generic question that I'm trying to ask is, how do we work in a modularised manner? Multiple markdown files and calling them in each other? Something like the following in an orchestrating markdown?

I'd probably need a bit more information, if you want to work in a modularised manner then there is the question of why can't that just work as standard R code executed in r or databricks_r chunks? It's just executing R code after all.

I'm hoping developments with Databricks connect V2 and support for R will open up more usage patterns.

zacdav-db commented 1 year ago

Closing as there are no plans to support %run. I have however just added %sh support.