modal.app
modal.app.App
class App(object)
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 app_id
, 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)
client
@property
def client(self) -> _Client:
A reference to the running App’s server client.
app_id
@property
def app_id(self) -> str:
A unique identifier for this running App.
disconnect
def disconnect(self):
Tell the server the client has disconnected for this app. Terminates all running tasks for ephemeral apps.
stop
def stop(self):
Tell the server to stop this app, terminating all running tasks.
log_url
def log_url(self):
URL link to a running app’s logs page in the Modal dashboard.
init_container
@staticmethod
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.
deploy
def deploy(self, name: str, namespace, object_entity: str) -> str:
App.deploy
is deprecated in favor of modal.runner.deploy_stub
.
spawn_sandbox
def spawn_sandbox(
self,
*args,
**kwargs,
) -> "modal.sandbox._Sandbox":
Deprecated. Use Stub.spawn_sandbox
instead.
modal.app.is_local
def is_local() -> bool:
Returns if we are currently on the machine launching/deploying a Modal app
Returns True
when executed locally on the user’s machine.
Returns False
when executed from a Modal container in the cloud.