MilanM commited on
Commit
9eb8d65
·
verified ·
1 Parent(s): 8d7c64c

Update visualizer_app.py

Browse files
Files changed (1) hide show
  1. visualizer_app.py +25 -26
visualizer_app.py CHANGED
@@ -128,39 +128,38 @@ def client_instantiation(
128
  ):
129
  ### Instantiate the watsonx.ai client
130
  if client_setup:
131
- wx_credentials = Credentials(
132
- url=wx_url,
133
- api_key=wx_api_key
134
- )
 
 
 
 
 
 
 
 
 
 
 
135
 
136
- if project_id:
137
- project_client = APIClient(credentials=wx_credentials, project_id=project_id)
138
- else:
 
 
 
 
139
  project_client = None
140
-
141
- if space_id:
142
- deployment_client = APIClient(credentials=wx_credentials, space_id=space_id)
143
- else:
144
- deployment_client = None
145
-
146
-
147
- # if project_client is not None:
148
- # task_credentials_details = setup_task_credentials(project_client)
149
- # else:
150
- # task_credentials_details = setup_task_credentials(deployment_client)
151
-
152
  else:
153
  wx_credentials = None
154
  project_client = None
155
  deployment_client = None
156
- # task_credentials_details = None
157
-
158
- client_status = mo.md("### Client Instantiation Status will turn Green When Ready")
159
-
160
- if project_client is not None or deployment_client is not None:
161
- client_callout_kind = "success"
162
- else:
163
  client_callout_kind = "neutral"
 
164
  return (
165
  client_callout_kind,
166
  client_status,
 
128
  ):
129
  ### Instantiate the watsonx.ai client
130
  if client_setup:
131
+ try:
132
+ wx_credentials = Credentials(
133
+ url=wx_url,
134
+ api_key=wx_api_key
135
+ )
136
+
137
+ if project_id:
138
+ project_client = APIClient(credentials=wx_credentials, project_id=project_id)
139
+ else:
140
+ project_client = None
141
+
142
+ if space_id:
143
+ deployment_client = APIClient(credentials=wx_credentials, space_id=space_id)
144
+ else:
145
+ deployment_client = None
146
 
147
+ client_status = mo.md("### ✅ Client Instantiation Successful ✅")
148
+ client_callout_kind = "success"
149
+
150
+ except Exception as e:
151
+ error_message = str(e)
152
+ client_status = mo.md(f"### ❌ Client Instantiation Failed\n**Error:** {error_message}\n\nCheck your region selection and credentials")
153
+ client_callout_kind = "danger"
154
  project_client = None
155
+ deployment_client = None
 
 
 
 
 
 
 
 
 
 
 
156
  else:
157
  wx_credentials = None
158
  project_client = None
159
  deployment_client = None
160
+ client_status = mo.md("### This box will turn Green if client instantiation is successful")
 
 
 
 
 
 
161
  client_callout_kind = "neutral"
162
+
163
  return (
164
  client_callout_kind,
165
  client_status,