modal.Cls

class Cls(modal.object.Object)
def __init__(self, *args, **kwargs):

from_name

@classmethod
def from_name(
    cls: Type["_Cls"],
    app_name: str,
    tag: Optional[str] = None,
    namespace=api_pb2.DEPLOYMENT_NAMESPACE_WORKSPACE,
    environment_name: Optional[str] = None,
    workspace: Optional[str] = None,
) -> "_Cls":

Retrieve a class with a given name and tag.

Class = modal.Cls.from_name("other-app", "Class")

with_options

def with_options(
    self: "_Cls",
    cpu: Optional[float] = None,
    memory: Optional[int] = None,
    gpu: GPU_T = None,
    secrets: Collection[_Secret] = (),
    volumes: Dict[Union[str, os.PathLike], _Volume] = {},
    retries: Optional[Union[int, Retries]] = None,
    timeout: Optional[int] = None,
    concurrency_limit: Optional[int] = None,
    allow_concurrent_inputs: Optional[int] = None,
    container_idle_timeout: Optional[int] = None,
    allow_background_volume_commits: bool = False,
) -> "_Cls":

Beta: Allows for the runtime modification of a modal.Cls’s configuration.

This is a beta feature and may be unstable.

Usage:

import modal
Model = modal.Cls.lookup(
    "flywheel-generic", "Model", workspace="mk-1"
)
Model2 = Model.with_options(
    gpu=modal.gpu.A100(memory=40),
    volumes={"/models": models_vol}
)
Model2().generate.remote(42)

lookup

@staticmethod
def lookup(
    app_name: str,
    tag: Optional[str] = None,
    namespace=api_pb2.DEPLOYMENT_NAMESPACE_WORKSPACE,
    client: Optional[_Client] = None,
    environment_name: Optional[str] = None,
    workspace: Optional[str] = None,
) -> "_Cls":

Lookup a class with a given name and tag.

Class = modal.Cls.lookup("other-app", "Class")