Skip to content

Commit f9d906c

Browse files
add title and description to ServeGradio (#15639)
* add title and description * update test * apply suggestions Co-authored-by: Adrian Wälchli <[email protected]>
1 parent 10a4b24 commit f9d906c

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/lightning_app/components/serve/gradio.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ class ServeGradio(LightningWork, abc.ABC):
3131
outputs: Any
3232
examples: Optional[List] = None
3333
enable_queue: bool = False
34+
title: Optional[str] = None
35+
description: Optional[str] = None
3436

3537
def __init__(self, *args, **kwargs):
3638
requires("gradio")(super().__init__(*args, **kwargs))
@@ -58,7 +60,14 @@ def run(self, *args, **kwargs):
5860
self._model = self.build_model()
5961
fn = partial(self.predict, *args, **kwargs)
6062
fn.__name__ = self.predict.__name__
61-
gradio.Interface(fn=fn, inputs=self.inputs, outputs=self.outputs, examples=self.examples).launch(
63+
gradio.Interface(
64+
fn=fn,
65+
inputs=self.inputs,
66+
outputs=self.outputs,
67+
examples=self.examples,
68+
title=self.title,
69+
description=self.description,
70+
).launch(
6271
server_name=self.host,
6372
server_port=self.port,
6473
enable_queue=self.enable_queue,

tests/tests_app/components/serve/test_gradio.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,6 @@ def predict(self, *args, **kwargs):
2727
comp.run()
2828
assert comp.model == "model"
2929
assert comp.predict() == "prediction"
30-
gradio_mock.Interface.assert_called_once_with(fn=ANY, inputs=ANY, outputs=ANY, examples=ANY)
30+
gradio_mock.Interface.assert_called_once_with(
31+
fn=ANY, inputs=ANY, outputs=ANY, examples=ANY, title=None, description=None
32+
)

0 commit comments

Comments
 (0)