Update visualizer_app.py
Browse files- visualizer_app.py +47 -37
visualizer_app.py
CHANGED
@@ -117,16 +117,9 @@ def _():
|
|
117 |
def client_instantiation(
|
118 |
APIClient,
|
119 |
Credentials,
|
120 |
-
client,
|
121 |
-
client_key,
|
122 |
-
client_options,
|
123 |
-
client_selector,
|
124 |
client_setup,
|
125 |
-
get_key_by_value,
|
126 |
-
mo,
|
127 |
project_id,
|
128 |
space_id,
|
129 |
-
wrap_with_spaces,
|
130 |
wx_api_key,
|
131 |
wx_url,
|
132 |
):
|
@@ -134,48 +127,31 @@ def client_instantiation(
|
|
134 |
if client_setup:
|
135 |
try:
|
136 |
wx_credentials = Credentials(url=wx_url, api_key=wx_api_key)
|
137 |
-
|
138 |
project_client = (
|
139 |
APIClient(credentials=wx_credentials, project_id=project_id)
|
140 |
if project_id
|
141 |
else None
|
142 |
)
|
143 |
-
|
144 |
deployment_client = (
|
145 |
APIClient(credentials=wx_credentials, space_id=space_id)
|
146 |
if space_id
|
147 |
else None
|
148 |
)
|
149 |
-
|
150 |
-
|
151 |
-
client_status = mo.md(
|
152 |
-
f"### ✅ Client Instantiation Successful ✅\n\n"
|
153 |
-
f"{client_selector}\n\n"
|
154 |
-
f"**Active Client:**{wrap_with_spaces(active_client_name, prefix_spaces=5)}"
|
155 |
-
)
|
156 |
-
client_callout_kind = "success"
|
157 |
-
|
158 |
except Exception as e:
|
159 |
-
|
160 |
-
|
161 |
-
f"### ❌ Client Instantiation Failed\n**Error:** {error_message}\n\nCheck your region selection and credentials"
|
162 |
-
)
|
163 |
-
client_callout_kind = "danger"
|
164 |
wx_credentials = project_client = deployment_client = None
|
165 |
else:
|
166 |
wx_credentials = project_client = deployment_client = None
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
f"{client_selector}\n\n"
|
171 |
-
f"**Active Client:**{wrap_with_spaces(active_client_name, prefix_spaces=5)}"
|
172 |
-
)
|
173 |
-
client_callout_kind = "neutral"
|
174 |
-
|
175 |
return (
|
176 |
-
client_callout_kind,
|
177 |
-
client_status,
|
178 |
deployment_client,
|
|
|
|
|
179 |
project_client,
|
180 |
)
|
181 |
|
@@ -426,6 +402,42 @@ def instantiation_status(
|
|
426 |
client_stack = mo.hstack([client_instantiation_form, client_callout], align="center", justify="space-around", gap=10)
|
427 |
return (client_stack,)
|
428 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
429 |
|
430 |
@app.cell
|
431 |
def client_selector(deployment_client, project_client):
|
@@ -443,8 +455,7 @@ def client_selector(deployment_client, project_client):
|
|
443 |
|
444 |
default_client = next(iter(client_options))
|
445 |
client_selector = mo.ui.dropdown(client_options, value=default_client, label="**Select your active client:**")
|
446 |
-
|
447 |
-
return (client_selector,)
|
448 |
|
449 |
|
450 |
@app.cell
|
@@ -454,8 +465,7 @@ def active_client(client_selector):
|
|
454 |
client = None
|
455 |
else:
|
456 |
client = client_key
|
457 |
-
return
|
458 |
-
|
459 |
|
460 |
@app.cell
|
461 |
def emb_model_selection(client, set_embedding_model_list):
|
|
|
117 |
def client_instantiation(
|
118 |
APIClient,
|
119 |
Credentials,
|
|
|
|
|
|
|
|
|
120 |
client_setup,
|
|
|
|
|
121 |
project_id,
|
122 |
space_id,
|
|
|
123 |
wx_api_key,
|
124 |
wx_url,
|
125 |
):
|
|
|
127 |
if client_setup:
|
128 |
try:
|
129 |
wx_credentials = Credentials(url=wx_url, api_key=wx_api_key)
|
|
|
130 |
project_client = (
|
131 |
APIClient(credentials=wx_credentials, project_id=project_id)
|
132 |
if project_id
|
133 |
else None
|
134 |
)
|
|
|
135 |
deployment_client = (
|
136 |
APIClient(credentials=wx_credentials, space_id=space_id)
|
137 |
if space_id
|
138 |
else None
|
139 |
)
|
140 |
+
instantiation_success = True
|
141 |
+
instantiation_error = None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
142 |
except Exception as e:
|
143 |
+
instantiation_success = False
|
144 |
+
instantiation_error = str(e)
|
|
|
|
|
|
|
145 |
wx_credentials = project_client = deployment_client = None
|
146 |
else:
|
147 |
wx_credentials = project_client = deployment_client = None
|
148 |
+
instantiation_success = None
|
149 |
+
instantiation_error = None
|
150 |
+
|
|
|
|
|
|
|
|
|
|
|
151 |
return (
|
|
|
|
|
152 |
deployment_client,
|
153 |
+
instantiation_error,
|
154 |
+
instantiation_success,
|
155 |
project_client,
|
156 |
)
|
157 |
|
|
|
402 |
client_stack = mo.hstack([client_instantiation_form, client_callout], align="center", justify="space-around", gap=10)
|
403 |
return (client_stack,)
|
404 |
|
405 |
+
def _(
|
406 |
+
client,
|
407 |
+
client_key,
|
408 |
+
client_options,
|
409 |
+
client_selector,
|
410 |
+
client_setup,
|
411 |
+
get_key_by_value,
|
412 |
+
instantiation_error,
|
413 |
+
instantiation_success,
|
414 |
+
mo,
|
415 |
+
wrap_with_spaces,
|
416 |
+
):
|
417 |
+
active_client_name = get_key_by_value(client_options, client_key)
|
418 |
+
|
419 |
+
if client_setup:
|
420 |
+
if instantiation_success:
|
421 |
+
client_status = mo.md(
|
422 |
+
f"### ✅ Client Instantiation Successful ✅\n\n"
|
423 |
+
f"{client_selector}\n\n"
|
424 |
+
f"**Active Client:**{wrap_with_spaces(active_client_name, prefix_spaces=5)}"
|
425 |
+
)
|
426 |
+
client_callout_kind = "success"
|
427 |
+
else:
|
428 |
+
client_status = mo.md(
|
429 |
+
f"### ❌ Client Instantiation Failed\n**Error:** {instantiation_error}\n\nCheck your region selection and credentials"
|
430 |
+
)
|
431 |
+
client_callout_kind = "danger"
|
432 |
+
else:
|
433 |
+
client_status = mo.md(
|
434 |
+
f"### Client Instantiation Status will turn Green When Ready\n\n"
|
435 |
+
f"{client_selector}\n\n"
|
436 |
+
f"**Active Client:**{wrap_with_spaces(active_client_name, prefix_spaces=5)}"
|
437 |
+
)
|
438 |
+
client_callout_kind = "neutral"
|
439 |
+
|
440 |
+
return active_client_name, client_callout_kind, client_status
|
441 |
|
442 |
@app.cell
|
443 |
def client_selector(deployment_client, project_client):
|
|
|
455 |
|
456 |
default_client = next(iter(client_options))
|
457 |
client_selector = mo.ui.dropdown(client_options, value=default_client, label="**Select your active client:**")
|
458 |
+
return client_options, client_selector
|
|
|
459 |
|
460 |
|
461 |
@app.cell
|
|
|
465 |
client = None
|
466 |
else:
|
467 |
client = client_key
|
468 |
+
return client, client_key
|
|
|
469 |
|
470 |
@app.cell
|
471 |
def emb_model_selection(client, set_embedding_model_list):
|