Remove unused codes

dev
babysor00 3 years ago
parent 11a5e2a141
commit 2e57bf3f11

@ -68,7 +68,7 @@
"request": "launch",
"program": "mkgui\\base\\_cli.py",
"console": "integratedTerminal",
"args": ["launch-ui", "mkgui.app:mocking_bird"
"args": [ "mkgui.app:mocking_bird"
]
},
]

@ -1,10 +1,6 @@
"""Command line interface."""
import os
import sys
import typer
from pydantic.error_wrappers import ValidationError
cli = typer.Typer()
@ -21,44 +17,5 @@ def launch_ui(opyrator: str, port: int = typer.Option(8051, "--port", "-p")) ->
from mkgui.base.ui.streamlit_ui import launch_ui
launch_ui(opyrator, port)
@cli.command()
def launch_api(
opyrator: str,
port: int = typer.Option(8080, "--port", "-p"),
host: str = typer.Option("0.0.0.0", "--host", "-h"),
) -> None:
"""Start a HTTP API server for the opyrator.
This will launch a FastAPI server based on the OpenAPI standard and with an automatic interactive documentation.
"""
# Add the current working directory to the sys path
# This is required to resolve the opyrator path
sys.path.append(os.getcwd())
from mkgui.base.api.fastapi_app import launch_api # type: ignore
launch_api(opyrator, port, host)
@cli.command()
def call(opyrator: str, input_data: str) -> None:
"""Execute the opyrator from command line."""
# Add the current working directory to the sys path
# This is required to resolve the opyrator path
sys.path.append(os.getcwd())
try:
from mkgui.base import Opyrator
output = Opyrator(opyrator)(input_data)
if output:
typer.echo(output.json(indent=4))
else:
typer.echo("Nothing returned!")
except ValidationError as ex:
typer.secho(str(ex), fg=typer.colors.RED, err=True)
if __name__ == "__main__":
cli()

@ -35,7 +35,7 @@ st.set_page_config(
with st.spinner("Loading MockingBird GUI. Please wait..."):
opyrator = Opyrator("{opyrator_path}")
render_streamlit_ui(opyrator)
render_streamlit_ui(opyrator, action="{action}")
"""
@ -43,7 +43,7 @@ def launch_ui(opyrator_path: str, port: int = 8501) -> None:
with NamedTemporaryFile(
suffix=".py", mode="w", encoding="utf-8", delete=False
) as f:
f.write(STREAMLIT_RUNNER_SNIPPET.format(opyrator_path=opyrator_path))
f.write(STREAMLIT_RUNNER_SNIPPET.format_map({'opyrator_path': opyrator_path, 'action': "Synthesize"}))
f.seek(0)
# TODO: PYTHONPATH="$PYTHONPATH:/workspace/opyrator/src"
@ -105,8 +105,6 @@ class InputUI:
"definitions", {}
)
# TODO: check if state has input data
def render_ui(self, streamlit_app_root) -> None:
if has_input_ui_renderer(self._input_class):
# The input model has a rendering function
@ -116,10 +114,7 @@ class InputUI:
).dict()
return
required_properties = self._input_class.schema(by_alias=True).get(
"required", []
)
print(self._schema_properties)
# print(self._schema_properties)
for property_key in self._schema_properties.keys():
property = self._schema_properties[property_key]
@ -806,7 +801,7 @@ class OutputUI:
streamlit.json(jsonable_encoder(output_data))
def render_streamlit_ui(opyrator: Opyrator) -> None:
def render_streamlit_ui(opyrator: Opyrator, action: str = "Execute") -> None:
title = opyrator.name
# init
@ -829,7 +824,7 @@ def render_streamlit_ui(opyrator: Opyrator) -> None:
with left:
execute_selected = st.button("Execute")
execute_selected = st.button(action)
if execute_selected:
with st.spinner("Executing operation. Please wait..."):
try:

Loading…
Cancel
Save