Improve visualizer output when invalid auth token is provided (#140)

This commit is contained in:
Suchintan
2024-04-01 00:36:04 -04:00
committed by GitHub
parent 0124764b6e
commit 14ea1e2417

View File

@@ -256,9 +256,18 @@ with visualizer_tab:
col_steps.markdown(f"#### Steps") col_steps.markdown(f"#### Steps")
col_artifacts.markdown("#### Artifacts") col_artifacts.markdown("#### Artifacts")
tasks_response = repository.get_tasks(task_page_number) tasks_response = repository.get_tasks(task_page_number)
if "error" in tasks_response: if type(tasks_response) is not list:
st.write(tasks_response) st.error("Failed to fetch tasks.")
st.error(tasks_response)
if "Organization not found" in str(tasks_response) or "Could not validate credentials" in str(tasks_response):
st.error("Please check the organization credentials in .streamlit/secrets.toml.")
st.error(
"You can validate the credentials against the postgresql credentials by running\n\n"
'`psql -U skyvern -h localhost -d skyvern -c "SELECT o.organization_id, o.organization_name, token FROM organizations o JOIN organization_auth_tokens oat ON oat.organization_id = o.organization_id;"`.'
"\n\n NOTE: There might be multiple organizations -- each run of ./setup.sh creates a new one. Pick your favourite!"
)
else:
# Display tasks in sidebar for selection # Display tasks in sidebar for selection
tasks = {task["task_id"]: task for task in tasks_response} tasks = {task["task_id"]: task for task in tasks_response}
task_id_buttons = { task_id_buttons = {
@@ -312,7 +321,9 @@ with visualizer_tab:
] ]
) )
tab_task_details, tab_task_steps, tab_task_action_results = tab_task.tabs(["Details", "Steps", "Action Results"]) tab_task_details, tab_task_steps, tab_task_action_results = tab_task.tabs(
["Details", "Steps", "Action Results"]
)
if selected_task: if selected_task:
tab_task_details.json(selected_task) tab_task_details.json(selected_task)
@@ -324,7 +335,9 @@ with visualizer_tab:
col_steps_prev.button( col_steps_prev.button(
"prev", on_click=go_to_previous_step, key="previous_step_button", use_container_width=True "prev", on_click=go_to_previous_step, key="previous_step_button", use_container_width=True
) )
col_steps_next.button("next", on_click=go_to_next_step, key="next_step_button", use_container_width=True) col_steps_next.button(
"next", on_click=go_to_next_step, key="next_step_button", use_container_width=True
)
step_id_buttons = { step_id_buttons = {
step["step_id"]: col_steps.button( step["step_id"]: col_steps.button(
@@ -386,7 +399,10 @@ with visualizer_tab:
) )
elif file_name.endswith("id_xpath_map.json"): elif file_name.endswith("id_xpath_map.json"):
streamlit_content_safe( streamlit_content_safe(
tab_id_to_xpath, tab_id_to_xpath.json, read_artifact_safe(uri), "No ID -> XPath map available." tab_id_to_xpath,
tab_id_to_xpath.json,
read_artifact_safe(uri),
"No ID -> XPath map available.",
) )
elif file_name.endswith("tree.json"): elif file_name.endswith("tree.json"):
streamlit_content_safe( streamlit_content_safe(