BCDA-APS / gemviz

Data visualization for tiled
https://bcda-aps.github.io/gemviz/
Other
4 stars 0 forks source link

BUG: app crashes when opening empty catalog #77

Closed prjemian closed 1 year ago

prjemian commented 1 year ago

Since a recent PR was merged, the app now crashes when an empty (no runs) catalog is opened.

olliviergassant commented 1 year ago

Error code in the terminal from catalog 3idc

catalogSelected: args = ('3idc',)  kwargs = {}
Traceback (most recent call last):
  File "/home/beams/OGASSANT/.conda/envs/bluesky_2023_2/lib/python3.10/site-packages/tiled/iterviews.py", line 60, in __getitem__
    (key,) = keys
ValueError: not enough values to unpack (expected 1, got 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/beams0/OGASSANT/Documents/tiled-viz2023/gemviz23/demo/filterpanel.py", line 53, in catalogSelected
    getStartTime(cat.keys().first()),
  File "/home/beams/OGASSANT/.conda/envs/bluesky_2023_2/lib/python3.10/site-packages/tiled/iterviews.py", line 18, in first
    return self[0]
  File "/home/beams/OGASSANT/.conda/envs/bluesky_2023_2/lib/python3.10/site-packages/tiled/iterviews.py", line 62, in __getitem__
    raise IndexError("Index out of range")
IndexError: Index out of range
since='2023-03-23 00:00:00' until='2023-07-25 00:00:00'
filteredCatalog: cat=<Node {}>
Displaying catalog: '3idc'
doPageSize value ='5'
doPager action ='pageSize', value ='5'
self.pageOffset() =0 self.pageSize() =5
prjemian commented 1 year ago

Simpler crash case also. Also crashes after connecting with server, when connecting again with server:

(base) jemian@otz .../BCDA-APS/gemviz23 $ /home/beams/JEMIAN/.conda/envs/bluesky_2023_2/bin/python /home/beams1/JEMIAN/Documents/projects/BCDA-APS/gemviz23/gemviz23/demo/app.py
catalogSelected: args = ('developer',)  kwargs = {}
t_low='2023-03-23 14:07:04.794668' t_high='2023-07-25 22:47:51.536000'
since='2023-03-23 00:00:00' until='2023-07-25 00:00:00'
filteredCatalog: cat=<Node {'77819d1d-5512-4df7-b97a-9ba572c51211', ...} ~133 entries>
Displaying catalog: 'developer'
doPageSize value ='5'
doPager action ='pageSize', value ='5'
self.pageOffset() =0 self.pageSize() =5
catalogSelected: args = ('',)  kwargs = {}
Traceback (most recent call last):
  File "/home/beams1/JEMIAN/Documents/projects/BCDA-APS/gemviz23/gemviz23/demo/filterpanel.py", line 53, in catalogSelected
    getStartTime(cat.keys().first()),
  File "/home/beams1/JEMIAN/Documents/projects/BCDA-APS/gemviz23/gemviz23/demo/filterpanel.py", line 48, in getStartTime
    start_time = run.metadata["start"]["time"]
  File "/home/beams/JEMIAN/.conda/envs/bluesky_2023_2/lib/python3.10/site-packages/tiled/utils.py", line 84, in __getitem__
    return self._internal_dict[key]
KeyError: 'start'
Aborted (core dumped)
prjemian commented 1 year ago

The first problem might be resolved after this line: https://github.com/BCDA-APS/tiled-viz2023/blob/a3525c4737abf94e0f0e48bea34c045952d2803e/gemviz23/demo/filterpanel.py#L51

by adding:

        if len(cat) == 0:
            return
prjemian commented 1 year ago

In the second problem, the expected argument of the catalog name is an empty string. Before this assignment: https://github.com/BCDA-APS/tiled-viz2023/blob/a3525c4737abf94e0f0e48bea34c045952d2803e/gemviz23/demo/filterpanel.py#L44

the method should return if the string (args[0]) is empty or the catalog name does not exist.

prjemian commented 1 year ago

This might be tricky. Using the debugger, seems the code is responding to: https://github.com/BCDA-APS/tiled-viz2023/blob/a3525c4737abf94e0f0e48bea34c045952d2803e/gemviz23/demo/filterpanel.py#L32

The code is clearing all the previous items from the QComboBox that holds the list of catalog names provided by this server. An empty string is passed for a catalog name since the default selection text is "". It is important to return when the length of the catalog name passed as args[0] is zero.