Apps are the user representation of an actively running Modal process.
You can obtain an
App from the
Stub.run() context manager. While the app
is running, you can get its
client, and other useful properties
from this object.
import modal stub = modal.Stub() stub.my_secret_object = modal.Secret.from_name("my-secret") if __name__ == "__main__": with stub.run() as app: print(app.client) print(app.app_id) print(app.my_secret_object)
def client(self) -> _Client:
A reference to the running App’s server client.
def app_id(self) -> str:
A unique identifier for this running App.
Tell the server the client has disconnected for this app. Terminates all running tasks for ephemeral apps.
Tell the server to stop this app, terminating all running tasks.
URL link to a running app’s logs page in the Modal dashboard.
def init_container(client: _Client, app_id: str, stub_name: str = "") -> "_App":
Used by the container to bootstrap the app and all its objects. Not intended to be called by Modal users.
def deploy(self, name: str, namespace, object_entity: str) -> str:
App.deploy is deprecated in favor of
def spawn_sandbox( self, *args, **kwargs, ) -> "modal.sandbox._Sandbox":
def is_local() -> bool:
Returns if we are currently on the machine launching/deploying a Modal app
True when executed locally on the user’s machine.
False when executed from a Modal container in the cloud.