modal.runner

modal.runner.DeployResult

class DeployResult(object)

Dataclass representing the result of deploying an app.

def __init__(self, app_id: str) -> None

modal.runner.deploy_stub

async def deploy_stub(
    stub: _Stub,
    name: str = None,
    namespace=api_pb2.DEPLOYMENT_NAMESPACE_WORKSPACE,
    client=None,
    stdout=None,
    show_progress=True,
    environment_name: Optional[str] = None,
    public: bool = False,
) -> DeployResult:

Deploy an app and export its objects persistently.

Typically, using the command-line tool modal deploy <module or script> should be used, instead of this method.

Usage:

if __name__ == "__main__":
    deploy_stub(stub)

Deployment has two primary purposes:

  • Persists all of the objects in the app, allowing them to live past the current app run. For schedules this enables headless “cron”-like functionality where scheduled functions continue to be invoked after the client has disconnected.
  • Allows for certain kinds of these objects, deployment objects, to be referred to and used by other apps.

modal.runner.interactive_shell

async def interactive_shell(_stub: _Stub, cmd: List[str], environment_name: str = "", **kwargs):

Run an interactive shell (like bash) within the image for this app.

This is useful for online debugging and interactive exploration of the contents of this image. If cmd is optionally provided, it will be run instead of the default shell inside this image.

Example

import modal

stub = modal.Stub(image=modal.Image.debian_slim().apt_install("vim"))

You can now run this using

modal shell script.py --cmd /bin/bash

**kwargs will be passed into spawn_sandbox().