modal.Cls
class Cls(modal.object.Object)
def __init__(self, *args, **kwargs):
validate_construction_mechanism
@staticmethod
def validate_construction_mechanism(user_cls):
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[Union[int, Tuple[int, 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,
) -> "_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("my_app", "Model")
ModelUsingGPU = Model.with_options(gpu="A100")
ModelUsingGPU().generate.remote(42) # will run with an A100 GPU
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")