OCEANAI / app.py
ElenaRyumina's picture
v0.8.0 (#8)
1bf4da3 verified
raw
history blame
1.65 kB
"""
File: app.py
Authors: Elena Ryumina and Dmitry Ryumin
Description: OCEANAI App for gradio.
License: MIT License
"""
import gradio as gr
# Importing necessary components for the Gradio app
from app.config import CONFIG_NAME, config_data, load_tab_creators
from app.event_handlers.event_handlers import setup_app_event_handlers
from app import tabs
from app.components import dropdown_create_ui
def create_gradio_app() -> gr.Blocks:
with gr.Blocks(css=config_data.AppSettings_CSS_PATH) as gradio_app:
languages = dropdown_create_ui(
label=None,
info=None,
choices=config_data.Settings_LANGUAGES_EN,
value=config_data.Settings_LANGUAGES_EN[0],
visible=True,
show_label=False,
elem_classes="dropdown-language-container",
interactive=False,
)
tab_results = {}
ts = []
available_functions = {
attr: getattr(tabs, attr)
for attr in dir(tabs)
if callable(getattr(tabs, attr)) and attr.endswith("_tab")
}
tab_creators = load_tab_creators(CONFIG_NAME, available_functions)
for tab_name, create_tab_function in tab_creators.items():
with gr.Tab(tab_name) as tab:
app_instance = create_tab_function()
tab_results[tab_name] = app_instance
ts.append(tab)
setup_app_event_handlers(
*tab_results[list(tab_results.keys())[0]], *ts, languages
)
return gradio_app
if __name__ == "__main__":
create_gradio_app().queue(api_open=False).launch(share=False)