You can call a magic command in Jupyter from a script as follows:
ipython = get_ipython() mgc = ipython.run_line_magic mgc(magic_name = "my_magic_comman