Forum Discussion

PANDAmonium's avatar
PANDAmonium
Resolver IV
1 year ago
Solved

Passing Arguments to Notebooks with Magic

Hi All,   I'm trying to figure out how to use magic commands to run another notebook with an argument that has a variable as the value. Hopefully the example below explains it better. The idea is t...
  • PANDAmonium's avatar
    PANDAmonium
    1 year ago

    That still gave the same error, but I figured it out.

     

    Unexpected character encountered while parsing value: i. Path 'isDev', line 1, position 10.

     

    The variables set in the parent notebook already get passed to this child notebook, so passing the parameter wasn't even needed and what worked was simply:

     

    Notebook1

    isDev = True

    %run Notebook2

    Notebook2

    print(str(isDev))

     

    Also the following worked if I wanted to run it like a script, but the using the magic command was better and 10x faster.

     

    Notebook1

    params = {"isDev":True}
    mssparkutils.notebook.run("Notebook2", 120, params)

    Notebook2

    print(str(isDev))

     

    Thanks!