Skip to main content

Python library for easily interacting with trained machine learning models

Project description

gradio_doctestcode

PyPI - Version

Python library for easily interacting with trained machine learning models

Installation

pip install gradio_doctestcode

Usage

import gradio as gr
from gradio_doctestcode import DocTestCode


example = DocTestCode().example_inputs()

demo = gr.Interface(
    lambda x:x,
    DocTestCode(),  # interactive version of your component
    DocTestCode(),  # static version of your component
    # examples=[[example]],  # uncomment this line to view the "example version" of your component
)


if __name__ == "__main__":
    demo.launch()

DocTestCode

Initialization

name type default description
value
str | tuple[str] | None
None Default value to show in the code editor. If callable, the function will be called whenever the app loads to set the initial value of the component.
language
"python"
    | "markdown"
    | "json"
    | "html"
    | "css"
    | "javascript"
    | "typescript"
    | "yaml"
    | "dockerfile"
    | "shell"
    | "r"
    | None
None The language to display the code as. Supported languages listed in `gr.Code.languages`.
every
float | None
None If `value` is a callable, run the function 'every' number of seconds while the client connection is open. Has no effect otherwise. Queue must be enabled. The event can be accessed (e.g. to cancel it) via this component's .load_event attribute.
lines
int
5 None
label
str | None
None The label for this component. Appears above the component and is also used as the header if there are a table of examples for this component. If None and used in a `gr.Interface`, the label will be the name of the parameter this component is assigned to.
interactive
bool | None
None Whether user should be able to enter code or only view it.
show_label
bool | None
None if True, will display label.
container
bool
True If True, will place the component in a container - providing some extra padding around the border.
scale
int | None
None relative width compared to adjacent Components in a Row. For example, if Component A has scale=2, and Component B has scale=1, A will be twice as wide as B. Should be an integer.
min_width
int
160 minimum pixel width, will wrap if not sufficient screen space to satisfy this value. If a certain scale value results in this Component being narrower than min_width, the min_width parameter will be respected first.
visible
bool
True If False, component will be hidden.
elem_id
str | None
None An optional string that is assigned as the id of this component in the HTML DOM. Can be used for targeting CSS styles.
elem_classes
list[str] | str | None
None An optional list of strings that are assigned as the classes of this component in the HTML DOM. Can be used for targeting CSS styles.
render
bool
True If False, component will not render be rendered in the Blocks context. Should be used if the intention is to assign event listeners now but render the component later.

Events

name description
change Triggered when the value of the DocTestCode changes either because of user input (e.g. a user types in a textbox) OR because of a function update (e.g. an image receives a value from the output of an event trigger). See .input() for a listener that is only triggered by user input.
input This listener is triggered when the user changes the value of the DocTestCode.
focus This listener is triggered when the DocTestCode is focused.
blur This listener is triggered when the DocTestCode is unfocused/blurred.

User function

def predict(
    value: Any
) -> tuple | str | None:
    return value

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gradio_doctestcode-0.0.4.tar.gz (322.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gradio_doctestcode-0.0.4-py3-none-any.whl (308.3 kB view details)

Uploaded Python 3

File details

Details for the file gradio_doctestcode-0.0.4.tar.gz.

File metadata

  • Download URL: gradio_doctestcode-0.0.4.tar.gz
  • Upload date:
  • Size: 322.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.9

File hashes

Hashes for gradio_doctestcode-0.0.4.tar.gz
Algorithm Hash digest
SHA256 903cc1c9cc804e61c344e6df724b536eb87b95ccf784f470c740efadb9a1960a
MD5 c30b879958888f33e66a0d05cbf4e17e
BLAKE2b-256 c759f3e137d1a0562af600beb7f193bdad58f888bbc957f5d348d26bda32a3d2

See more details on using hashes here.

File details

Details for the file gradio_doctestcode-0.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for gradio_doctestcode-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 289997ec0369813bc002e8769851afde68055e56e5ed1c29bd237f5ddd77564c
MD5 a6faaa0bb57f97b5eb6e2d3d6a197abc
BLAKE2b-256 d8cb7205df087f4581db516723af5aae63c21862c415fe130a1d04b577fa9644

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page