Skip to content

Commit

Permalink
feat: better error handling on project app
Browse files Browse the repository at this point in the history
  • Loading branch information
dbirman committed Jan 13, 2025
1 parent 4ede0a8 commit c7963b4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
8 changes: 5 additions & 3 deletions src/aind_qc_portal/qc_project_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,11 @@ def update_header(project_name):
def update_project_view(project_name):
"""Helper to update project view and return the new panel object
"""
project_view.update(project_name)

return project_view.panel()
try:
project_view.update(project_name)
return project_view.panel()
except Exception as e:
return pn.pane.Alert(f"Error loading project data: {e}.\n\nThis error likely indicates your metadata is invalid, the QC portal *requires* valid metadata in every data asset to function. Please reach out to Scientific Computing for help repairing your assets, you can use the metadata portal at metadata-portal.allenneuraldynamics.org to help find errors in your metadata.", alert_type="danger")


# Add the header project dropdown list
Expand Down
8 changes: 6 additions & 2 deletions src/aind_qc_portal/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,9 @@ def range_unit_format(time_range):
unit = "year"
format = "%Y"
else:
raise ValueError(f"Time range: {time_range} is too large")
# Default to five years
unit = "year"
format = "%Y"

return unit, format

Expand Down Expand Up @@ -216,7 +218,9 @@ def timestamp_range(min_date, max_date):
min_range = min_date - (TEN_YEARS - time_range) / 2
max_range = max_date + (TEN_YEARS - time_range) / 2
else:
raise ValueError(f"Time range: {time_range} is too large")
# Default to five years
min_range = min_date - (FIVE_YEARS - time_range) / 2
max_range = max_date + (FIVE_YEARS - time_range) / 2

unit, format = range_unit_format(time_range)

Expand Down

0 comments on commit c7963b4

Please sign in to comment.