DFO-Ocean-Navigator/Ocean-Data-Map-Project

API Scripts fail

Closed this issue · 0 comments

Describe the bug
The Python API scripts for plots and csv files fail without getting the requested data. The plot script raises the following error:
'''
Traceback (most recent call last):
File "/home/ubuntu/onav-cloud/Ocean-Data-Map-Project/test.py", line 46, in
requestFile()
File "/home/ubuntu/onav-cloud/Ocean-Data-Map-Project/test.py", line 37, in requestFile
img = Image.open(f)
^^^^^^^^^^^^^
File "/home/ubuntu/onav-cloud/tools/miniconda/3/amd64/envs/navigator/lib/python3.12/site-packages/PIL/Image.py", line 3305, in open
raise UnidentifiedImageError(msg)
PIL.UnidentifiedImageError: cannot identify image file <_io.BytesIO object at 0x7ff2fe32afc0>
'''
The URL generated by this script to produce the plot returns an empty image so the issue is likely somewhere in the /plot API endpoint.

The csv script raises the following:
'''
Traceback (most recent call last):
File "/home/ubuntu/onav-cloud/Ocean-Data-Map-Project/test.py", line 53, in
requestFile()
File "/home/ubuntu/onav-cloud/Ocean-Data-Map-Project/test.py", line 45, in requestFile
fname = "ONAV_CSV_" + str(query["dataset"]) + "_" + str(query["variable"]) + ".csv"
~~~~~^^^^^^^^^^^^
KeyError: 'variable'
'''

To Reproduce

  1. Display Class4 data in Navigator and click on a point.
  2. Under the API Script dropdown select Python 3 - Plot or csv
  3. Once the script downloads, copy it to your dev environment and run it.
  4. Script will fail as described above.

Expected behavior
The script should fetch the requested data.