Created
December 19, 2018 14:51
-
-
Save joannapurosto/0a825491c042c968d614ef06ae0807a4 to your computer and use it in GitHub Desktop.
Example for notebook blog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from IPython.core.magic import Magics, magics_class, cell_magic | |
import os | |
@magics_class | |
class ValohaiMagics(Magics): | |
@cell_magic | |
def valohai(self, line='', cell=None): | |
path = os.path.expanduser('~/%s/execute.py' % project) | |
with open(path, 'w+') as f: | |
f.write(cell) | |
path = os.path.expanduser('~/%s/valohai.yaml' % project) | |
with open(path, 'w+') as f: | |
f.write('- step:\r\n') | |
f.write(' name: jupyter_execution\r\n') | |
f.write(' image: %s\r\n' % docker) | |
f.write(' command: python execute.py\r\n') | |
print('Starting execution in Valohai...') | |
!vh execution run --adhoc jupyter_execution | |
!vh execution logs --stream latest | |
ip = get_ipython() | |
ip.register_magics(ValohaiMagics) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment