Skip to content

Instantly share code, notes, and snippets.

@erikbern
Last active February 20, 2023 14:24
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save erikbern/6d3ed976917977f9b62c1aeb37628a2a to your computer and use it in GitHub Desktop.
Run Notebook inside Modal
# Note: this assumes you have a notebook locally named my_notebook.ipynb
import modal
stub = modal.Stub(
image=modal.DebianSlim().pip_install(["papermill", "ipykernel"]),
mounts=[modal.Mount(local_file="my_notebook.ipynb", remote_dir="/root")],
)
@stub.function
def run():
import papermill
papermill.execute_notebook(
"/root/my_notebook.ipynb",
"/root/my_notebook_outout.ipynb",
)
if __name__ == "__main__":
with stub.run():
run()
@DStaz
Copy link

DStaz commented Feb 19, 2023

Hi, could you write an updated working examples of a notebook used into modal please ?

@erikbern
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment