Update app.py
Browse files
app.py
CHANGED
@@ -202,16 +202,9 @@ def _(client_instantiation_form, os):
|
|
202 |
def client_instantiation(
|
203 |
APIClient,
|
204 |
Credentials,
|
205 |
-
client,
|
206 |
-
client_key,
|
207 |
-
client_options,
|
208 |
-
client_selector,
|
209 |
client_setup,
|
210 |
-
get_key_by_value,
|
211 |
-
mo,
|
212 |
project_id,
|
213 |
space_id,
|
214 |
-
wrap_with_spaces,
|
215 |
wx_api_key,
|
216 |
wx_url,
|
217 |
):
|
@@ -219,57 +212,77 @@ def client_instantiation(
|
|
219 |
if client_setup:
|
220 |
try:
|
221 |
wx_credentials = Credentials(url=wx_url, api_key=wx_api_key)
|
222 |
-
|
223 |
project_client = (
|
224 |
APIClient(credentials=wx_credentials, project_id=project_id)
|
225 |
if project_id
|
226 |
else None
|
227 |
)
|
228 |
-
|
229 |
deployment_client = (
|
230 |
APIClient(credentials=wx_credentials, space_id=space_id)
|
231 |
if space_id
|
232 |
else None
|
233 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
234 |
|
235 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
236 |
client_status = mo.md(
|
237 |
f"### β
Client Instantiation Successful β
\n\n"
|
238 |
f"{client_selector}\n\n"
|
239 |
f"**Active Client:**{wrap_with_spaces(active_client_name, prefix_spaces=5)}"
|
240 |
)
|
241 |
client_callout_kind = "success"
|
242 |
-
|
243 |
-
except Exception as e:
|
244 |
-
error_message = str(e)
|
245 |
client_status = mo.md(
|
246 |
-
f"### β Client Instantiation Failed\n**Error:** {
|
247 |
)
|
248 |
client_callout_kind = "danger"
|
249 |
-
wx_credentials = project_client = deployment_client = None
|
250 |
else:
|
251 |
-
wx_credentials = project_client = deployment_client = None
|
252 |
-
active_client_name = get_key_by_value(client_options, client_key)
|
253 |
client_status = mo.md(
|
254 |
f"### Client Instantiation Status will turn Green When Ready\n\n"
|
255 |
f"{client_selector}\n\n"
|
256 |
f"**Active Client:**{wrap_with_spaces(active_client_name, prefix_spaces=5)}"
|
257 |
)
|
258 |
client_callout_kind = "neutral"
|
259 |
-
|
260 |
-
return
|
261 |
-
client_callout_kind,
|
262 |
-
client_status,
|
263 |
-
deployment_client,
|
264 |
-
project_client,
|
265 |
-
)
|
266 |
-
|
267 |
-
@app.cell
|
268 |
-
def _(client_callout_kind, client_instantiation_form, client_status, mo):
|
269 |
-
client_callout = mo.callout(client_status, kind=client_callout_kind)
|
270 |
-
|
271 |
-
client_section = mo.hstack([client_instantiation_form, client_callout], align="center", justify="space-around")
|
272 |
-
return (client_section,)
|
273 |
|
274 |
|
275 |
@app.cell
|
|
|
202 |
def client_instantiation(
|
203 |
APIClient,
|
204 |
Credentials,
|
|
|
|
|
|
|
|
|
205 |
client_setup,
|
|
|
|
|
206 |
project_id,
|
207 |
space_id,
|
|
|
208 |
wx_api_key,
|
209 |
wx_url,
|
210 |
):
|
|
|
212 |
if client_setup:
|
213 |
try:
|
214 |
wx_credentials = Credentials(url=wx_url, api_key=wx_api_key)
|
|
|
215 |
project_client = (
|
216 |
APIClient(credentials=wx_credentials, project_id=project_id)
|
217 |
if project_id
|
218 |
else None
|
219 |
)
|
|
|
220 |
deployment_client = (
|
221 |
APIClient(credentials=wx_credentials, space_id=space_id)
|
222 |
if space_id
|
223 |
else None
|
224 |
)
|
225 |
+
instantiation_success = True
|
226 |
+
instantiation_error = None
|
227 |
+
except Exception as e:
|
228 |
+
instantiation_success = False
|
229 |
+
instantiation_error = str(e)
|
230 |
+
wx_credentials = project_client = deployment_client = None
|
231 |
+
else:
|
232 |
+
wx_credentials = project_client = deployment_client = None
|
233 |
+
instantiation_success = None
|
234 |
+
instantiation_error = None
|
235 |
+
|
236 |
+
return (
|
237 |
+
deployment_client,
|
238 |
+
instantiation_error,
|
239 |
+
instantiation_success,
|
240 |
+
project_client,
|
241 |
+
)
|
242 |
+
|
243 |
+
@app.cell
|
244 |
+
def _(client_callout_kind, client_instantiation_form, client_status, mo):
|
245 |
+
client_callout = mo.callout(client_status, kind=client_callout_kind)
|
246 |
+
|
247 |
+
client_section = mo.hstack([client_instantiation_form, client_callout], align="center", justify="space-around")
|
248 |
+
return (client_section,)
|
249 |
|
250 |
+
def _(
|
251 |
+
client,
|
252 |
+
client_key,
|
253 |
+
client_options,
|
254 |
+
client_selector,
|
255 |
+
client_setup,
|
256 |
+
get_key_by_value,
|
257 |
+
instantiation_error,
|
258 |
+
instantiation_success,
|
259 |
+
mo,
|
260 |
+
wrap_with_spaces,
|
261 |
+
):
|
262 |
+
active_client_name = get_key_by_value(client_options, client_key)
|
263 |
+
|
264 |
+
if client_setup:
|
265 |
+
if instantiation_success:
|
266 |
client_status = mo.md(
|
267 |
f"### β
Client Instantiation Successful β
\n\n"
|
268 |
f"{client_selector}\n\n"
|
269 |
f"**Active Client:**{wrap_with_spaces(active_client_name, prefix_spaces=5)}"
|
270 |
)
|
271 |
client_callout_kind = "success"
|
272 |
+
else:
|
|
|
|
|
273 |
client_status = mo.md(
|
274 |
+
f"### β Client Instantiation Failed\n**Error:** {instantiation_error}\n\nCheck your region selection and credentials"
|
275 |
)
|
276 |
client_callout_kind = "danger"
|
|
|
277 |
else:
|
|
|
|
|
278 |
client_status = mo.md(
|
279 |
f"### Client Instantiation Status will turn Green When Ready\n\n"
|
280 |
f"{client_selector}\n\n"
|
281 |
f"**Active Client:**{wrap_with_spaces(active_client_name, prefix_spaces=5)}"
|
282 |
)
|
283 |
client_callout_kind = "neutral"
|
284 |
+
|
285 |
+
return active_client_name, client_callout_kind, client_status
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
286 |
|
287 |
|
288 |
@app.cell
|