Block-Components

- fix errors
- remove type and optional from blocks context
This commit is contained in:
Ömer Faruk Özdemir 2022-03-09 12:35:47 +03:00
parent 00b846e7e6
commit 05037f436c
6 changed files with 5 additions and 7 deletions

View File

@ -25,7 +25,7 @@ with xray_blocks:
xray_scan = gr.inputs.Image()
xray_results = gr.outputs.JSON()
output_textbox = gr.outputs.Textbox()
input_textbox = gr.inputs.Textbox(default="Hello This Is a Input Textbox", component_type="input")
input_textbox = gr.inputs.Textbox(default="Hello This Is a Input Textbox")
xray_run = gr.Button("Run")
xray_run.click(xray_model, inputs=[disease, xray_scan], outputs=xray_results)
xray_run.click(xray_model, inputs=[disease, xray_scan], outputs=output_textbox)

View File

@ -178,7 +178,6 @@ class Blocks(Launchable, BlockContext):
config["components"].append(
{
"id": _id,
"type": block.component_type,
"props": block.get_template_context(),
}
)

View File

@ -44,7 +44,6 @@ class Component(Block):
return {
"name": self.__class__.__name__.lower(),
"label": self.label,
"optional": self.optional,
}
@classmethod
@ -227,7 +226,7 @@ class Textbox(Component):
"The 'type' parameter has been deprecated. Use the Number component instead if you need it.",
DeprecationWarning,
)
default = float(default)
default = str(default)
self.lines = lines
self.placeholder = placeholder
self.default = default

View File

@ -92,7 +92,7 @@ class InputComponent(Component):
self.component_type = "input"
self.set_interpret_parameters()
self.optional = optional
super().__init__(label, requires_permissions)
super().__init__(label=label, requires_permissions=requires_permissions)
def preprocess(self, x: Any) -> Any:
"""

View File

@ -48,7 +48,7 @@ class OutputComponent(Component):
def __init__(self, label: str):
self.component_type = "output"
super().__init__(label)
super().__init__(label=label)
def postprocess(self, y):
"""

View File

@ -6,7 +6,7 @@ from gradio.components import Component
class StaticComponent(Component):
def __init__(self, label: str):
self.component_type = "static"
super().__init__(label)
super().__init__(label=label)
def process(self, y):
"""