Spaces:
Running
Running
Upload folder using huggingface_hub
Browse files- Dockerfile +4 -0
- README.md +10 -3
- __pycache__/__init__.cpython-39.pyc +0 -0
- __pycache__/app.cpython-39.pyc +0 -0
- app.py +11 -12
- requirements.txt +1 -1
- src/backend/gradio_molecule3d/molecule3d.py +3 -0
- src/backend/gradio_molecule3d/molecule3d.pyi +31 -8
- src/backend/gradio_molecule3d/templates/component/index.js +0 -0
- src/demo/app.py +2 -1
- src/frontend/Index.svelte +3 -0
- src/frontend/shared/File.svelte +2 -1
- src/frontend/shared/FileUpload.svelte +2 -1
- src/pyproject.toml +2 -2
Dockerfile
CHANGED
|
@@ -5,6 +5,10 @@ WORKDIR /code
|
|
| 5 |
|
| 6 |
COPY --link --chown=1000 . .
|
| 7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 9 |
|
| 10 |
ENV PYTHONUNBUFFERED=1 GRADIO_ALLOW_FLAGGING=never GRADIO_NUM_PORTS=1 GRADIO_SERVER_NAME=0.0.0.0 GRADIO_SERVER_PORT=7860 SYSTEM=spaces
|
|
|
|
| 5 |
|
| 6 |
COPY --link --chown=1000 . .
|
| 7 |
|
| 8 |
+
RUN mkdir -p /tmp/cache/
|
| 9 |
+
RUN chmod a+rwx -R /tmp/cache/
|
| 10 |
+
ENV TRANSFORMERS_CACHE=/tmp/cache/
|
| 11 |
+
|
| 12 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 13 |
|
| 14 |
ENV PYTHONUNBUFFERED=1 GRADIO_ALLOW_FLAGGING=never GRADIO_NUM_PORTS=1 GRADIO_SERVER_NAME=0.0.0.0 GRADIO_SERVER_PORT=7860 SYSTEM=spaces
|
README.md
CHANGED
|
@@ -1,10 +1,17 @@
|
|
| 1 |
|
| 2 |
---
|
| 3 |
-
tags: [gradio-custom-component, gradio-template-File]
|
| 4 |
-
title: gradio_molecule3d V0.0.
|
| 5 |
-
colorFrom:
|
| 6 |
colorTo: indigo
|
| 7 |
sdk: docker
|
| 8 |
pinned: false
|
| 9 |
license: apache-2.0
|
| 10 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
|
| 2 |
---
|
| 3 |
+
tags: [gradio-custom-component,machine learning,reproducibility,visualization,gradio,gradio-template-File,protein]
|
| 4 |
+
title: gradio_molecule3d V0.0.2
|
| 5 |
+
colorFrom: purple
|
| 6 |
colorTo: indigo
|
| 7 |
sdk: docker
|
| 8 |
pinned: false
|
| 9 |
license: apache-2.0
|
| 10 |
---
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
# Name: gradio_molecule3d
|
| 14 |
+
|
| 15 |
+
Description: Molecule3D custom component to visualize pdb or sdf files
|
| 16 |
+
|
| 17 |
+
Install with: pip install gradio_molecule3d
|
__pycache__/__init__.cpython-39.pyc
ADDED
|
Binary file (144 Bytes). View file
|
|
|
__pycache__/app.cpython-39.pyc
CHANGED
|
Binary files a/__pycache__/app.cpython-39.pyc and b/__pycache__/app.cpython-39.pyc differ
|
|
|
app.py
CHANGED
|
@@ -26,21 +26,20 @@ def predict(x):
|
|
| 26 |
return x
|
| 27 |
|
| 28 |
#doesn't work
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
)
|
| 35 |
|
| 36 |
#works
|
| 37 |
with gr.Blocks() as demo:
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
btn = gr.Button("Predict")
|
| 42 |
btn.click(predict, inputs=inp, outputs=out)
|
| 43 |
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
demoInterface.launch()
|
|
|
|
| 26 |
return x
|
| 27 |
|
| 28 |
#doesn't work
|
| 29 |
+
#demo = gr.Interface(
|
| 30 |
+
# predict,
|
| 31 |
+
# Molecule3D(label="Molecule3D", reps=reps), # interactive version of your component
|
| 32 |
+
# Molecule3D(), # static version of your component
|
| 33 |
+
# examples=[[example]], # uncomment this line to view the "example version" of your component
|
| 34 |
+
# )
|
| 35 |
|
| 36 |
#works
|
| 37 |
with gr.Blocks() as demo:
|
| 38 |
+
inp = Molecule3D("demo/1pga.pdb",label="Molecule3D", reps=reps)
|
| 39 |
+
inp = Molecule3D("demo/1pga.pdb",label="Molecule3D", reps=reps, showviewer=False)
|
| 40 |
+
out = Molecule3D(label="Molecule3D", reps=reps)
|
| 41 |
btn = gr.Button("Predict")
|
| 42 |
btn.click(predict, inputs=inp, outputs=out)
|
| 43 |
|
| 44 |
+
demo.launch()
|
| 45 |
+
# blocks.launch()
|
|
|
requirements.txt
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
gradio_molecule3d-0.0.
|
|
|
|
| 1 |
+
gradio_molecule3d-0.0.2-py3-none-any.whl
|
src/backend/gradio_molecule3d/molecule3d.py
CHANGED
|
@@ -65,6 +65,7 @@ class Molecule3D(Component):
|
|
| 65 |
elem_id: str | None = None,
|
| 66 |
elem_classes: list[str] | str | None = None,
|
| 67 |
render: bool = True,
|
|
|
|
| 68 |
):
|
| 69 |
"""
|
| 70 |
Parameters:
|
|
@@ -87,6 +88,7 @@ class Molecule3D(Component):
|
|
| 87 |
elem_id: An optional string that is assigned as the id of this component in the HTML DOM. Can be used for targeting CSS styles.
|
| 88 |
elem_classes: 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.
|
| 89 |
render: 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.
|
|
|
|
| 90 |
"""
|
| 91 |
self.file_count = file_count
|
| 92 |
if self.file_count == "multiple":
|
|
@@ -129,6 +131,7 @@ class Molecule3D(Component):
|
|
| 129 |
self.reps = reps
|
| 130 |
self.config = config
|
| 131 |
self.confidenceLabel = confidenceLabel
|
|
|
|
| 132 |
|
| 133 |
|
| 134 |
def _process_single_file(self, f: FileData) -> NamedString | bytes:
|
|
|
|
| 65 |
elem_id: str | None = None,
|
| 66 |
elem_classes: list[str] | str | None = None,
|
| 67 |
render: bool = True,
|
| 68 |
+
showviewer: bool = True
|
| 69 |
):
|
| 70 |
"""
|
| 71 |
Parameters:
|
|
|
|
| 88 |
elem_id: An optional string that is assigned as the id of this component in the HTML DOM. Can be used for targeting CSS styles.
|
| 89 |
elem_classes: 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.
|
| 90 |
render: 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.
|
| 91 |
+
showviewer: If True, will display the 3Dmol.js viewer. If False, will not display the 3Dmol.js viewer.
|
| 92 |
"""
|
| 93 |
self.file_count = file_count
|
| 94 |
if self.file_count == "multiple":
|
|
|
|
| 131 |
self.reps = reps
|
| 132 |
self.config = config
|
| 133 |
self.confidenceLabel = confidenceLabel
|
| 134 |
+
self.showviewer = showviewer
|
| 135 |
|
| 136 |
|
| 137 |
def _process_single_file(self, f: FileData) -> NamedString | bytes:
|
src/backend/gradio_molecule3d/molecule3d.pyi
CHANGED
|
@@ -66,6 +66,7 @@ class Molecule3D(Component):
|
|
| 66 |
elem_id: str | None = None,
|
| 67 |
elem_classes: list[str] | str | None = None,
|
| 68 |
render: bool = True,
|
|
|
|
| 69 |
):
|
| 70 |
"""
|
| 71 |
Parameters:
|
|
@@ -88,6 +89,7 @@ class Molecule3D(Component):
|
|
| 88 |
elem_id: An optional string that is assigned as the id of this component in the HTML DOM. Can be used for targeting CSS styles.
|
| 89 |
elem_classes: 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.
|
| 90 |
render: 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.
|
|
|
|
| 91 |
"""
|
| 92 |
self.file_count = file_count
|
| 93 |
if self.file_count == "multiple":
|
|
@@ -130,6 +132,7 @@ class Molecule3D(Component):
|
|
| 130 |
self.reps = reps
|
| 131 |
self.config = config
|
| 132 |
self.confidenceLabel = confidenceLabel
|
|
|
|
| 133 |
|
| 134 |
|
| 135 |
def _process_single_file(self, f: FileData) -> NamedString | bytes:
|
|
@@ -211,7 +214,6 @@ class Molecule3D(Component):
|
|
| 211 |
inputs: Component | Sequence[Component] | set[Component] | None = None,
|
| 212 |
outputs: Component | Sequence[Component] | None = None,
|
| 213 |
api_name: str | None | Literal[False] = None,
|
| 214 |
-
status_tracker: None = None,
|
| 215 |
scroll_to_output: bool = False,
|
| 216 |
show_progress: Literal["full", "minimal", "hidden"] = "full",
|
| 217 |
queue: bool | None = None,
|
|
@@ -222,7 +224,10 @@ class Molecule3D(Component):
|
|
| 222 |
cancels: dict[str, Any] | list[dict[str, Any]] | None = None,
|
| 223 |
every: float | None = None,
|
| 224 |
trigger_mode: Literal["once", "multiple", "always_last"] | None = None,
|
| 225 |
-
js: str | None = None,
|
|
|
|
|
|
|
|
|
|
| 226 |
"""
|
| 227 |
Parameters:
|
| 228 |
fn: the function to call when this event is triggered. Often a machine learning model's prediction function. Each parameter of the function corresponds to one input component, and the function should return a single value or a tuple of values, with each element in the tuple corresponding to one output component.
|
|
@@ -240,6 +245,9 @@ class Molecule3D(Component):
|
|
| 240 |
every: Run this event 'every' number of seconds while the client connection is open. Interpreted in seconds. Queue must be enabled.
|
| 241 |
trigger_mode: If "once" (default for all events except `.change()`) would not allow any submissions while an event is pending. If set to "multiple", unlimited submissions are allowed while pending, and "always_last" (default for `.change()` event) would allow a second submission after the pending event is complete.
|
| 242 |
js: Optional frontend js method to run before running 'fn'. Input arguments for js method are values of 'inputs' and 'outputs', return should be a list of values for output components.
|
|
|
|
|
|
|
|
|
|
| 243 |
"""
|
| 244 |
...
|
| 245 |
|
|
@@ -248,7 +256,6 @@ class Molecule3D(Component):
|
|
| 248 |
inputs: Component | Sequence[Component] | set[Component] | None = None,
|
| 249 |
outputs: Component | Sequence[Component] | None = None,
|
| 250 |
api_name: str | None | Literal[False] = None,
|
| 251 |
-
status_tracker: None = None,
|
| 252 |
scroll_to_output: bool = False,
|
| 253 |
show_progress: Literal["full", "minimal", "hidden"] = "full",
|
| 254 |
queue: bool | None = None,
|
|
@@ -259,7 +266,10 @@ class Molecule3D(Component):
|
|
| 259 |
cancels: dict[str, Any] | list[dict[str, Any]] | None = None,
|
| 260 |
every: float | None = None,
|
| 261 |
trigger_mode: Literal["once", "multiple", "always_last"] | None = None,
|
| 262 |
-
js: str | None = None,
|
|
|
|
|
|
|
|
|
|
| 263 |
"""
|
| 264 |
Parameters:
|
| 265 |
fn: the function to call when this event is triggered. Often a machine learning model's prediction function. Each parameter of the function corresponds to one input component, and the function should return a single value or a tuple of values, with each element in the tuple corresponding to one output component.
|
|
@@ -277,6 +287,9 @@ class Molecule3D(Component):
|
|
| 277 |
every: Run this event 'every' number of seconds while the client connection is open. Interpreted in seconds. Queue must be enabled.
|
| 278 |
trigger_mode: If "once" (default for all events except `.change()`) would not allow any submissions while an event is pending. If set to "multiple", unlimited submissions are allowed while pending, and "always_last" (default for `.change()` event) would allow a second submission after the pending event is complete.
|
| 279 |
js: Optional frontend js method to run before running 'fn'. Input arguments for js method are values of 'inputs' and 'outputs', return should be a list of values for output components.
|
|
|
|
|
|
|
|
|
|
| 280 |
"""
|
| 281 |
...
|
| 282 |
|
|
@@ -285,7 +298,6 @@ class Molecule3D(Component):
|
|
| 285 |
inputs: Component | Sequence[Component] | set[Component] | None = None,
|
| 286 |
outputs: Component | Sequence[Component] | None = None,
|
| 287 |
api_name: str | None | Literal[False] = None,
|
| 288 |
-
status_tracker: None = None,
|
| 289 |
scroll_to_output: bool = False,
|
| 290 |
show_progress: Literal["full", "minimal", "hidden"] = "full",
|
| 291 |
queue: bool | None = None,
|
|
@@ -296,7 +308,10 @@ class Molecule3D(Component):
|
|
| 296 |
cancels: dict[str, Any] | list[dict[str, Any]] | None = None,
|
| 297 |
every: float | None = None,
|
| 298 |
trigger_mode: Literal["once", "multiple", "always_last"] | None = None,
|
| 299 |
-
js: str | None = None,
|
|
|
|
|
|
|
|
|
|
| 300 |
"""
|
| 301 |
Parameters:
|
| 302 |
fn: the function to call when this event is triggered. Often a machine learning model's prediction function. Each parameter of the function corresponds to one input component, and the function should return a single value or a tuple of values, with each element in the tuple corresponding to one output component.
|
|
@@ -314,6 +329,9 @@ class Molecule3D(Component):
|
|
| 314 |
every: Run this event 'every' number of seconds while the client connection is open. Interpreted in seconds. Queue must be enabled.
|
| 315 |
trigger_mode: If "once" (default for all events except `.change()`) would not allow any submissions while an event is pending. If set to "multiple", unlimited submissions are allowed while pending, and "always_last" (default for `.change()` event) would allow a second submission after the pending event is complete.
|
| 316 |
js: Optional frontend js method to run before running 'fn'. Input arguments for js method are values of 'inputs' and 'outputs', return should be a list of values for output components.
|
|
|
|
|
|
|
|
|
|
| 317 |
"""
|
| 318 |
...
|
| 319 |
|
|
@@ -322,7 +340,6 @@ class Molecule3D(Component):
|
|
| 322 |
inputs: Component | Sequence[Component] | set[Component] | None = None,
|
| 323 |
outputs: Component | Sequence[Component] | None = None,
|
| 324 |
api_name: str | None | Literal[False] = None,
|
| 325 |
-
status_tracker: None = None,
|
| 326 |
scroll_to_output: bool = False,
|
| 327 |
show_progress: Literal["full", "minimal", "hidden"] = "full",
|
| 328 |
queue: bool | None = None,
|
|
@@ -333,7 +350,10 @@ class Molecule3D(Component):
|
|
| 333 |
cancels: dict[str, Any] | list[dict[str, Any]] | None = None,
|
| 334 |
every: float | None = None,
|
| 335 |
trigger_mode: Literal["once", "multiple", "always_last"] | None = None,
|
| 336 |
-
js: str | None = None,
|
|
|
|
|
|
|
|
|
|
| 337 |
"""
|
| 338 |
Parameters:
|
| 339 |
fn: the function to call when this event is triggered. Often a machine learning model's prediction function. Each parameter of the function corresponds to one input component, and the function should return a single value or a tuple of values, with each element in the tuple corresponding to one output component.
|
|
@@ -351,5 +371,8 @@ class Molecule3D(Component):
|
|
| 351 |
every: Run this event 'every' number of seconds while the client connection is open. Interpreted in seconds. Queue must be enabled.
|
| 352 |
trigger_mode: If "once" (default for all events except `.change()`) would not allow any submissions while an event is pending. If set to "multiple", unlimited submissions are allowed while pending, and "always_last" (default for `.change()` event) would allow a second submission after the pending event is complete.
|
| 353 |
js: Optional frontend js method to run before running 'fn'. Input arguments for js method are values of 'inputs' and 'outputs', return should be a list of values for output components.
|
|
|
|
|
|
|
|
|
|
| 354 |
"""
|
| 355 |
...
|
|
|
|
| 66 |
elem_id: str | None = None,
|
| 67 |
elem_classes: list[str] | str | None = None,
|
| 68 |
render: bool = True,
|
| 69 |
+
showviewer: bool = True
|
| 70 |
):
|
| 71 |
"""
|
| 72 |
Parameters:
|
|
|
|
| 89 |
elem_id: An optional string that is assigned as the id of this component in the HTML DOM. Can be used for targeting CSS styles.
|
| 90 |
elem_classes: 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.
|
| 91 |
render: 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.
|
| 92 |
+
showviewer: If True, will display the 3Dmol.js viewer. If False, will not display the 3Dmol.js viewer.
|
| 93 |
"""
|
| 94 |
self.file_count = file_count
|
| 95 |
if self.file_count == "multiple":
|
|
|
|
| 132 |
self.reps = reps
|
| 133 |
self.config = config
|
| 134 |
self.confidenceLabel = confidenceLabel
|
| 135 |
+
self.showviewer = showviewer
|
| 136 |
|
| 137 |
|
| 138 |
def _process_single_file(self, f: FileData) -> NamedString | bytes:
|
|
|
|
| 214 |
inputs: Component | Sequence[Component] | set[Component] | None = None,
|
| 215 |
outputs: Component | Sequence[Component] | None = None,
|
| 216 |
api_name: str | None | Literal[False] = None,
|
|
|
|
| 217 |
scroll_to_output: bool = False,
|
| 218 |
show_progress: Literal["full", "minimal", "hidden"] = "full",
|
| 219 |
queue: bool | None = None,
|
|
|
|
| 224 |
cancels: dict[str, Any] | list[dict[str, Any]] | None = None,
|
| 225 |
every: float | None = None,
|
| 226 |
trigger_mode: Literal["once", "multiple", "always_last"] | None = None,
|
| 227 |
+
js: str | None = None,
|
| 228 |
+
concurrency_limit: int | None | Literal["default"] = "default",
|
| 229 |
+
concurrency_id: str | None = None,
|
| 230 |
+
show_api: bool = True) -> Dependency:
|
| 231 |
"""
|
| 232 |
Parameters:
|
| 233 |
fn: the function to call when this event is triggered. Often a machine learning model's prediction function. Each parameter of the function corresponds to one input component, and the function should return a single value or a tuple of values, with each element in the tuple corresponding to one output component.
|
|
|
|
| 245 |
every: Run this event 'every' number of seconds while the client connection is open. Interpreted in seconds. Queue must be enabled.
|
| 246 |
trigger_mode: If "once" (default for all events except `.change()`) would not allow any submissions while an event is pending. If set to "multiple", unlimited submissions are allowed while pending, and "always_last" (default for `.change()` event) would allow a second submission after the pending event is complete.
|
| 247 |
js: Optional frontend js method to run before running 'fn'. Input arguments for js method are values of 'inputs' and 'outputs', return should be a list of values for output components.
|
| 248 |
+
concurrency_limit: If set, this is the maximum number of this event that can be running simultaneously. Can be set to None to mean no concurrency_limit (any number of this event can be running simultaneously). Set to "default" to use the default concurrency limit (defined by the `default_concurrency_limit` parameter in `Blocks.queue()`, which itself is 1 by default).
|
| 249 |
+
concurrency_id: If set, this is the id of the concurrency group. Events with the same concurrency_id will be limited by the lowest set concurrency_limit.
|
| 250 |
+
show_api: whether to show this event in the "view API" page of the Gradio app, or in the ".view_api()" method of the Gradio clients. Unlike setting api_name to False, setting show_api to False will still allow downstream apps to use this event. If fn is None, show_api will automatically be set to False.
|
| 251 |
"""
|
| 252 |
...
|
| 253 |
|
|
|
|
| 256 |
inputs: Component | Sequence[Component] | set[Component] | None = None,
|
| 257 |
outputs: Component | Sequence[Component] | None = None,
|
| 258 |
api_name: str | None | Literal[False] = None,
|
|
|
|
| 259 |
scroll_to_output: bool = False,
|
| 260 |
show_progress: Literal["full", "minimal", "hidden"] = "full",
|
| 261 |
queue: bool | None = None,
|
|
|
|
| 266 |
cancels: dict[str, Any] | list[dict[str, Any]] | None = None,
|
| 267 |
every: float | None = None,
|
| 268 |
trigger_mode: Literal["once", "multiple", "always_last"] | None = None,
|
| 269 |
+
js: str | None = None,
|
| 270 |
+
concurrency_limit: int | None | Literal["default"] = "default",
|
| 271 |
+
concurrency_id: str | None = None,
|
| 272 |
+
show_api: bool = True) -> Dependency:
|
| 273 |
"""
|
| 274 |
Parameters:
|
| 275 |
fn: the function to call when this event is triggered. Often a machine learning model's prediction function. Each parameter of the function corresponds to one input component, and the function should return a single value or a tuple of values, with each element in the tuple corresponding to one output component.
|
|
|
|
| 287 |
every: Run this event 'every' number of seconds while the client connection is open. Interpreted in seconds. Queue must be enabled.
|
| 288 |
trigger_mode: If "once" (default for all events except `.change()`) would not allow any submissions while an event is pending. If set to "multiple", unlimited submissions are allowed while pending, and "always_last" (default for `.change()` event) would allow a second submission after the pending event is complete.
|
| 289 |
js: Optional frontend js method to run before running 'fn'. Input arguments for js method are values of 'inputs' and 'outputs', return should be a list of values for output components.
|
| 290 |
+
concurrency_limit: If set, this is the maximum number of this event that can be running simultaneously. Can be set to None to mean no concurrency_limit (any number of this event can be running simultaneously). Set to "default" to use the default concurrency limit (defined by the `default_concurrency_limit` parameter in `Blocks.queue()`, which itself is 1 by default).
|
| 291 |
+
concurrency_id: If set, this is the id of the concurrency group. Events with the same concurrency_id will be limited by the lowest set concurrency_limit.
|
| 292 |
+
show_api: whether to show this event in the "view API" page of the Gradio app, or in the ".view_api()" method of the Gradio clients. Unlike setting api_name to False, setting show_api to False will still allow downstream apps to use this event. If fn is None, show_api will automatically be set to False.
|
| 293 |
"""
|
| 294 |
...
|
| 295 |
|
|
|
|
| 298 |
inputs: Component | Sequence[Component] | set[Component] | None = None,
|
| 299 |
outputs: Component | Sequence[Component] | None = None,
|
| 300 |
api_name: str | None | Literal[False] = None,
|
|
|
|
| 301 |
scroll_to_output: bool = False,
|
| 302 |
show_progress: Literal["full", "minimal", "hidden"] = "full",
|
| 303 |
queue: bool | None = None,
|
|
|
|
| 308 |
cancels: dict[str, Any] | list[dict[str, Any]] | None = None,
|
| 309 |
every: float | None = None,
|
| 310 |
trigger_mode: Literal["once", "multiple", "always_last"] | None = None,
|
| 311 |
+
js: str | None = None,
|
| 312 |
+
concurrency_limit: int | None | Literal["default"] = "default",
|
| 313 |
+
concurrency_id: str | None = None,
|
| 314 |
+
show_api: bool = True) -> Dependency:
|
| 315 |
"""
|
| 316 |
Parameters:
|
| 317 |
fn: the function to call when this event is triggered. Often a machine learning model's prediction function. Each parameter of the function corresponds to one input component, and the function should return a single value or a tuple of values, with each element in the tuple corresponding to one output component.
|
|
|
|
| 329 |
every: Run this event 'every' number of seconds while the client connection is open. Interpreted in seconds. Queue must be enabled.
|
| 330 |
trigger_mode: If "once" (default for all events except `.change()`) would not allow any submissions while an event is pending. If set to "multiple", unlimited submissions are allowed while pending, and "always_last" (default for `.change()` event) would allow a second submission after the pending event is complete.
|
| 331 |
js: Optional frontend js method to run before running 'fn'. Input arguments for js method are values of 'inputs' and 'outputs', return should be a list of values for output components.
|
| 332 |
+
concurrency_limit: If set, this is the maximum number of this event that can be running simultaneously. Can be set to None to mean no concurrency_limit (any number of this event can be running simultaneously). Set to "default" to use the default concurrency limit (defined by the `default_concurrency_limit` parameter in `Blocks.queue()`, which itself is 1 by default).
|
| 333 |
+
concurrency_id: If set, this is the id of the concurrency group. Events with the same concurrency_id will be limited by the lowest set concurrency_limit.
|
| 334 |
+
show_api: whether to show this event in the "view API" page of the Gradio app, or in the ".view_api()" method of the Gradio clients. Unlike setting api_name to False, setting show_api to False will still allow downstream apps to use this event. If fn is None, show_api will automatically be set to False.
|
| 335 |
"""
|
| 336 |
...
|
| 337 |
|
|
|
|
| 340 |
inputs: Component | Sequence[Component] | set[Component] | None = None,
|
| 341 |
outputs: Component | Sequence[Component] | None = None,
|
| 342 |
api_name: str | None | Literal[False] = None,
|
|
|
|
| 343 |
scroll_to_output: bool = False,
|
| 344 |
show_progress: Literal["full", "minimal", "hidden"] = "full",
|
| 345 |
queue: bool | None = None,
|
|
|
|
| 350 |
cancels: dict[str, Any] | list[dict[str, Any]] | None = None,
|
| 351 |
every: float | None = None,
|
| 352 |
trigger_mode: Literal["once", "multiple", "always_last"] | None = None,
|
| 353 |
+
js: str | None = None,
|
| 354 |
+
concurrency_limit: int | None | Literal["default"] = "default",
|
| 355 |
+
concurrency_id: str | None = None,
|
| 356 |
+
show_api: bool = True) -> Dependency:
|
| 357 |
"""
|
| 358 |
Parameters:
|
| 359 |
fn: the function to call when this event is triggered. Often a machine learning model's prediction function. Each parameter of the function corresponds to one input component, and the function should return a single value or a tuple of values, with each element in the tuple corresponding to one output component.
|
|
|
|
| 371 |
every: Run this event 'every' number of seconds while the client connection is open. Interpreted in seconds. Queue must be enabled.
|
| 372 |
trigger_mode: If "once" (default for all events except `.change()`) would not allow any submissions while an event is pending. If set to "multiple", unlimited submissions are allowed while pending, and "always_last" (default for `.change()` event) would allow a second submission after the pending event is complete.
|
| 373 |
js: Optional frontend js method to run before running 'fn'. Input arguments for js method are values of 'inputs' and 'outputs', return should be a list of values for output components.
|
| 374 |
+
concurrency_limit: If set, this is the maximum number of this event that can be running simultaneously. Can be set to None to mean no concurrency_limit (any number of this event can be running simultaneously). Set to "default" to use the default concurrency limit (defined by the `default_concurrency_limit` parameter in `Blocks.queue()`, which itself is 1 by default).
|
| 375 |
+
concurrency_id: If set, this is the id of the concurrency group. Events with the same concurrency_id will be limited by the lowest set concurrency_limit.
|
| 376 |
+
show_api: whether to show this event in the "view API" page of the Gradio app, or in the ".view_api()" method of the Gradio clients. Unlike setting api_name to False, setting show_api to False will still allow downstream apps to use this event. If fn is None, show_api will automatically be set to False.
|
| 377 |
"""
|
| 378 |
...
|
src/backend/gradio_molecule3d/templates/component/index.js
CHANGED
|
The diff for this file is too large to render.
See raw diff
|
|
|
src/demo/app.py
CHANGED
|
@@ -26,7 +26,7 @@ def predict(x):
|
|
| 26 |
return x
|
| 27 |
|
| 28 |
#doesn't work
|
| 29 |
-
#
|
| 30 |
# predict,
|
| 31 |
# Molecule3D(label="Molecule3D", reps=reps), # interactive version of your component
|
| 32 |
# Molecule3D(), # static version of your component
|
|
@@ -36,6 +36,7 @@ def predict(x):
|
|
| 36 |
#works
|
| 37 |
with gr.Blocks() as demo:
|
| 38 |
inp = Molecule3D("demo/1pga.pdb",label="Molecule3D", reps=reps)
|
|
|
|
| 39 |
out = Molecule3D(label="Molecule3D", reps=reps)
|
| 40 |
btn = gr.Button("Predict")
|
| 41 |
btn.click(predict, inputs=inp, outputs=out)
|
|
|
|
| 26 |
return x
|
| 27 |
|
| 28 |
#doesn't work
|
| 29 |
+
#demo = gr.Interface(
|
| 30 |
# predict,
|
| 31 |
# Molecule3D(label="Molecule3D", reps=reps), # interactive version of your component
|
| 32 |
# Molecule3D(), # static version of your component
|
|
|
|
| 36 |
#works
|
| 37 |
with gr.Blocks() as demo:
|
| 38 |
inp = Molecule3D("demo/1pga.pdb",label="Molecule3D", reps=reps)
|
| 39 |
+
inp = Molecule3D("demo/1pga.pdb",label="Molecule3D", reps=reps, showviewer=False)
|
| 40 |
out = Molecule3D(label="Molecule3D", reps=reps)
|
| 41 |
btn = gr.Button("Predict")
|
| 42 |
btn.click(predict, inputs=inp, outputs=out)
|
src/frontend/Index.svelte
CHANGED
|
@@ -33,6 +33,7 @@
|
|
| 33 |
export let reps: any = [];
|
| 34 |
export let config: any = {};
|
| 35 |
export let confidenceLabel: string = "";
|
|
|
|
| 36 |
|
| 37 |
export let proxy_url: null | string;
|
| 38 |
export let _selectable = false;
|
|
@@ -242,6 +243,7 @@
|
|
| 242 |
{moldata}
|
| 243 |
{errors}
|
| 244 |
i18n={gradio.i18n}
|
|
|
|
| 245 |
/>
|
| 246 |
{:else}
|
| 247 |
<FileUpload
|
|
@@ -257,6 +259,7 @@
|
|
| 257 |
{config}
|
| 258 |
{confidenceLabel}
|
| 259 |
{moldata}
|
|
|
|
| 260 |
on:change={({ detail }) => {
|
| 261 |
errors = [];
|
| 262 |
value = detail;
|
|
|
|
| 33 |
export let reps: any = [];
|
| 34 |
export let config: any = {};
|
| 35 |
export let confidenceLabel: string = "";
|
| 36 |
+
export let showviewer: boolean = true;
|
| 37 |
|
| 38 |
export let proxy_url: null | string;
|
| 39 |
export let _selectable = false;
|
|
|
|
| 243 |
{moldata}
|
| 244 |
{errors}
|
| 245 |
i18n={gradio.i18n}
|
| 246 |
+
molviewer={showviewer}
|
| 247 |
/>
|
| 248 |
{:else}
|
| 249 |
<FileUpload
|
|
|
|
| 259 |
{config}
|
| 260 |
{confidenceLabel}
|
| 261 |
{moldata}
|
| 262 |
+
molviewer={showviewer}
|
| 263 |
on:change={({ detail }) => {
|
| 264 |
errors = [];
|
| 265 |
value = detail;
|
src/frontend/shared/File.svelte
CHANGED
|
@@ -18,6 +18,7 @@
|
|
| 18 |
export let confidenceLabel = "";
|
| 19 |
export let representations = [];
|
| 20 |
export let moldata = null;
|
|
|
|
| 21 |
export let errors = [];
|
| 22 |
</script>
|
| 23 |
|
|
@@ -32,7 +33,7 @@
|
|
| 32 |
<FilePreview {i18n} {selectable} on:select {value} {height} />
|
| 33 |
|
| 34 |
<!-- {JSON.stringify(moldata)} -->
|
| 35 |
-
{#if moldata != null}
|
| 36 |
<MolecularViewer {moldata} {config} {confidenceLabel} {representations} />
|
| 37 |
{/if}
|
| 38 |
{:else}
|
|
|
|
| 18 |
export let confidenceLabel = "";
|
| 19 |
export let representations = [];
|
| 20 |
export let moldata = null;
|
| 21 |
+
export let molviewer = false;
|
| 22 |
export let errors = [];
|
| 23 |
</script>
|
| 24 |
|
|
|
|
| 33 |
<FilePreview {i18n} {selectable} on:select {value} {height} />
|
| 34 |
|
| 35 |
<!-- {JSON.stringify(moldata)} -->
|
| 36 |
+
{#if moldata != null && molviewer}
|
| 37 |
<MolecularViewer {moldata} {config} {confidenceLabel} {representations} />
|
| 38 |
{/if}
|
| 39 |
{:else}
|
src/frontend/shared/FileUpload.svelte
CHANGED
|
@@ -25,6 +25,7 @@
|
|
| 25 |
export let confidenceLabel = "";
|
| 26 |
export let representations = [];
|
| 27 |
export let moldata = null;
|
|
|
|
| 28 |
|
| 29 |
async function handle_upload({
|
| 30 |
detail,
|
|
@@ -78,7 +79,7 @@
|
|
| 78 |
<ModifyUpload {i18n} on:clear={handle_clear} absolute />
|
| 79 |
<FilePreview {i18n} on:select {selectable} {value} {height} />
|
| 80 |
|
| 81 |
-
{#if moldata != null}
|
| 82 |
<MolecularViewer {moldata} {config} {confidenceLabel} {representations} />
|
| 83 |
{/if}
|
| 84 |
{:else}
|
|
|
|
| 25 |
export let confidenceLabel = "";
|
| 26 |
export let representations = [];
|
| 27 |
export let moldata = null;
|
| 28 |
+
export let molviewer = false;
|
| 29 |
|
| 30 |
async function handle_upload({
|
| 31 |
detail,
|
|
|
|
| 79 |
<ModifyUpload {i18n} on:clear={handle_clear} absolute />
|
| 80 |
<FilePreview {i18n} on:select {selectable} {value} {height} />
|
| 81 |
|
| 82 |
+
{#if moldata != null && molviewer}
|
| 83 |
<MolecularViewer {moldata} {config} {confidenceLabel} {representations} />
|
| 84 |
{/if}
|
| 85 |
{:else}
|
src/pyproject.toml
CHANGED
|
@@ -8,7 +8,7 @@ build-backend = "hatchling.build"
|
|
| 8 |
|
| 9 |
[project]
|
| 10 |
name = "gradio_molecule3d"
|
| 11 |
-
version = "0.0.
|
| 12 |
description = "Molecule3D custom component to visualize pdb or sdf files"
|
| 13 |
readme = "README.md"
|
| 14 |
license = "MIT"
|
|
@@ -44,7 +44,7 @@ classifiers = [
|
|
| 44 |
dev = ["build", "twine"]
|
| 45 |
|
| 46 |
[tool.hatch.build]
|
| 47 |
-
artifacts = ["/backend/gradio_molecule3d/templates", "*.pyi", "backend/gradio_molecule3d/templates"]
|
| 48 |
|
| 49 |
[tool.hatch.build.targets.wheel]
|
| 50 |
packages = ["/backend/gradio_molecule3d"]
|
|
|
|
| 8 |
|
| 9 |
[project]
|
| 10 |
name = "gradio_molecule3d"
|
| 11 |
+
version = "0.0.2"
|
| 12 |
description = "Molecule3D custom component to visualize pdb or sdf files"
|
| 13 |
readme = "README.md"
|
| 14 |
license = "MIT"
|
|
|
|
| 44 |
dev = ["build", "twine"]
|
| 45 |
|
| 46 |
[tool.hatch.build]
|
| 47 |
+
artifacts = ["/backend/gradio_molecule3d/templates", "*.pyi", "backend/gradio_molecule3d/templates", "backend/gradio_molecule3d/templates", "backend/gradio_molecule3d/templates"]
|
| 48 |
|
| 49 |
[tool.hatch.build.targets.wheel]
|
| 50 |
packages = ["/backend/gradio_molecule3d"]
|