'Is there a way to run multiple %run statements in one line?
I have multiple %run statements currently in multiple lines in my databricks python notebook that work when running them one at a time. I was wondering if there was a way to combine them into one cell so that I don't have to run each individually. I have tried putting them together but keep getting errors
%run {location of file}
%run {location of file}
...
%run {location of file}
Error:
Failed to parse %run command: string matching regex `\$[\w_]+' expected but `%' found)
Below is what I tried based off OneCricketeer's suggestion. Turns out this solution doesn't resolve the issue.
notebooks = [
('{location of file}'),
('{location of file}'),
('{location of file}')]
for n in notebooks:
dbutils.notebook.run(n,60)
print('Finished loading notebook ' + n)
Solution 1:[1]
Generally, only first % "command" is executable in any cell.
To programmatically run a notebook, take a look at dbutils.notebook.run
Example
notebooks = [
('name', {'arg1': 'foo'}, ),
('other', {'arg1': 'bar'}, )
]
# for storing the values to call dbutils.notebook.exit function
notebook_ids = dict()
for n in notebooks:
name = n[0]
notebook_ids[name] = dbutils.notebook.run(name, 3600, n[1])
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
