Commit
•
ff04f99
1
Parent(s):
6401503
Automatically start ML worker if env provided
Browse files
app.py
CHANGED
@@ -15,6 +15,11 @@ logging.getLogger().setLevel(logging.INFO)
|
|
15 |
logging.getLogger("giskard").setLevel(logging.INFO)
|
16 |
|
17 |
|
|
|
|
|
|
|
|
|
|
|
18 |
LOG_FILE = "output.log"
|
19 |
|
20 |
def read_logs():
|
@@ -83,15 +88,13 @@ theme = gr.themes.Soft(
|
|
83 |
with gr.Blocks(theme=theme) as iface:
|
84 |
with gr.Row():
|
85 |
with gr.Column():
|
|
|
86 |
url_input = gr.Textbox(
|
87 |
label="Giskard Hub URL",
|
88 |
-
value=
|
89 |
-
if os.environ.get("SPACE_HOST")
|
90 |
-
else f"http://{settings.host}:{settings.ws_port}",
|
91 |
)
|
92 |
api_key_input = gr.Textbox(
|
93 |
label="Giskard Hub API Key",
|
94 |
-
value=os.environ.get("GSK_API_KEY"),
|
95 |
type="password",
|
96 |
placeholder="gsk-xxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
97 |
)
|
@@ -113,5 +116,8 @@ with gr.Blocks(theme=theme) as iface:
|
|
113 |
iface.load(read_logs, None, logs, every=0.5)
|
114 |
iface.load(read_status, None, output, every=5)
|
115 |
|
|
|
|
|
|
|
116 |
iface.queue()
|
117 |
iface.launch()
|
|
|
15 |
logging.getLogger("giskard").setLevel(logging.INFO)
|
16 |
|
17 |
|
18 |
+
GSK_HUB_URL = 'GSK_HUB_URL'
|
19 |
+
GSK_API_KEY = 'GSK_API_KEY'
|
20 |
+
HF_SPACE_HOST = 'SPACE_HOST'
|
21 |
+
HF_SPACE_TOKEN = 'GSK_HUB_HFS'
|
22 |
+
|
23 |
LOG_FILE = "output.log"
|
24 |
|
25 |
def read_logs():
|
|
|
88 |
with gr.Blocks(theme=theme) as iface:
|
89 |
with gr.Row():
|
90 |
with gr.Column():
|
91 |
+
url = os.environ.get(GSK_HUB_URL) if os.environ.get(GSK_HUB_URL) else f"http://{settings.host}:{settings.ws_port}"
|
92 |
url_input = gr.Textbox(
|
93 |
label="Giskard Hub URL",
|
94 |
+
value=url,
|
|
|
|
|
95 |
)
|
96 |
api_key_input = gr.Textbox(
|
97 |
label="Giskard Hub API Key",
|
|
|
98 |
type="password",
|
99 |
placeholder="gsk-xxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
100 |
)
|
|
|
116 |
iface.load(read_logs, None, logs, every=0.5)
|
117 |
iface.load(read_status, None, output, every=5)
|
118 |
|
119 |
+
if os.environ.get(GSK_HUB_URL) and os.environ.get(GSK_API_KEY):
|
120 |
+
start_ml_worker(os.environ.get(GSK_HUB_URL), os.environ.get(GSK_API_KEY), os.environ.get(HF_SPACE_TOKEN))
|
121 |
+
|
122 |
iface.queue()
|
123 |
iface.launch()
|