lightning/examples/app_commands_and_api/command.py

20 lines
460 B
Python

from argparse import ArgumentParser
from pydantic import BaseModel
from lightning.app.utilities.commands import ClientCommand
class CustomConfig(BaseModel):
name: str
class CustomCommand(ClientCommand):
description = "A command with a client."
def run(self):
parser = ArgumentParser()
parser.add_argument("--name", type=str)
args = parser.parse_args()
self.invoke_handler(config=CustomConfig(name=args.name))