Skip to content

[Bug]: unity-sds-client error response in get_collection_data #50

@rtapella

Description

@rtapella

Describe the bug

@wphyojpl :
https://github.com/unity-sds/unity-monorepo/blob/main/libs/unity-py/unity_sds_client/services/data_service.py#L73

I think this response in unity py should check the status code and throw an error accordingly for 400s and 500s.
Currently, it throws this error

KeyError                                  Traceback (most recent call last)
Cell In[15], line 4
      1 dataManager = s.client(services.DATA_SERVICE)
      2 collection_id = f"URN:NASA:UNITY:{os.environ['PROJECT']}:{os.environ['VENUE']}:QSR_10"
----> 4 cd = dataManager.get_collection_data(Collection(collection_id), limit=100)
      5 for dataset in cd:
      6     print(f'dataset name: {dataset.data_begin_time}')

File ~/.local/lib/python3.11/site-packages/unity_sds_client/services/data_service.py:75, in DataService.get_collection_data(self, collection, limit, filter, output_stac)
     73 if output_stac:
     74     return response.json()
---> 75 results = response.json()['features']
     77 for dataset in results:
     78     ds = Dataset(dataset['id'], collection.collection_id, dataset['properties']['start_datetime'], dataset['properties']['end_datetime'], dataset['properties']['created'], properties=dataset['properties'])

KeyError: 'features'

What did you expect?

catch 400 and 500 responses

Metadata

Metadata

Labels

Type

No type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions