Imageomics / Andromeda

A website that enables users to explore high-dimensional image data
http://andromeda.imageomics.org/
MIT License
2 stars 1 forks source link

Fix SyntaxError when URL field contains empty value #29

Closed johnbradley closed 1 year ago

johnbradley commented 1 year ago

When a dataset is uploaded with a URL field that has empty values an Syntax Error occurs parsing the response from /api/dataset/.../dimensional-reduction/. Example Error:

SyntaxError: Unexpected token 'N', ..."   "url": NaN,
     "... is not valid JSON

The problems seems to be related to the JSON response from dimensional-reduction:

...
    {
      "label": "p6",
      "url": NaN,
      "x": -0.5680886218501551,
      "y": -0.616528483321686
    },
...

This problem can be seen by uploading datasets/testData/mockData_v1.csv, unchecking the max_* columns and clicking "Visualize Data".

johnbradley commented 1 year ago

The problem is that jsonify is creating invalid JSON: https://github.com/Imageomics/Andromeda/blob/836608c1cf2925e437e0412d6c08d2c5522f6ba7/andromeda/main.py#L76 https://github.com/Imageomics/Andromeda/blob/836608c1cf2925e437e0412d6c08d2c5522f6ba7/andromeda/main.py#L93

Surprisingly this seems to be an issue with the python json module: https://bugs.python.org/issue26105

I think this can be fixed by converting NaN to null.

johnbradley commented 1 year ago

The NaN value is coming from the URL value df[self.url_column_name] here: https://github.com/Imageomics/Andromeda/blob/836608c1cf2925e437e0412d6c08d2c5522f6ba7/andromeda/dataset.py#L64-L65