actinia-org / actinia-python-client

Python Client Library for actinia
https://actinia-org.github.io/actinia-python-client/
GNU General Public License v3.0
5 stars 7 forks source link

Error 400 when trying to delete a non-existing mapset with Mapset.delete_mapset() #29

Closed neteler closed 9 months ago

neteler commented 12 months ago

When deleting a mapset which already exists the error isn't caught yet:

# request all locations
locations = actinia_mundialis.get_locations()

mapsets = actinia_mundialis.locations["latlong_wgs84"].get_mapsets()
print_dict_keys(mapsets, "Mapsets in latlong_wgs84:")
​

# remove leftover mapset from previous run
locations["latlong_wgs84"].delete_mapset("elevation")

---------------------------------------------------------------------------
Exception                                 Traceback (most recent call last)
Cell In [15], line 8
      5 print_dict_keys(mapsets, "Mapsets in latlong_wgs84:")
      7 # remove leftover mapset from previous run
----> 8 locations["latlong_wgs84"].delete_mapset("elevation")
     10 # Create a new mapset for the upload
     11 mapset_name = "elevation"

File ~/.local/lib/python3.11/site-packages/actinia/location.py:118, in Location.delete_mapset(self, name)
    114 def delete_mapset(self, name):
    115     """
    116     Deletes a mapset and returns an updated mapset list for the location.
    117     """
--> 118     Mapset.delete_mapset_request(
    119         name, self.name, self.__actinia, self.__auth
    120     )
    121     del self.mapsets[name]
    122     return self.mapsets

File ~/.local/lib/python3.11/site-packages/actinia/mapset.py:225, in Mapset.delete_mapset_request(cls, mapset_name, location_name, actinia, auth)
    223 resp = requests.delete(url, auth=(auth))
    224 if resp.status_code != 200:
--> 225     raise Exception(f"Error {resp.status_code}: {resp.text}")
    226 return None

Exception: Error 400: {"accept_datetime":"2023-09-21 14:47:45.816467","accept_timestamp":1695307665.8164663,"api_info":{"endpoint":"mapsetmanagementresourceadmin","method":"DELETE","path":"/api/v3/locations/latlong_wgs84/mapsets/elevation","request_url":"http://actinia.mundialis.de/api/v3/locations/latlong_wgs84/mapsets/elevation"},"datetime":"2023-09-21 14:47:45.937043","exception":{"message":"AsyncProcessError:  Mapset <elevation> does not exits","traceback":["  File \"/usr/lib/python3.9/site-packages/actinia_core/processing/actinia_processing/ephemeral_processing.py\", line 1944, in run\n    self._execute()\n","  File \"/usr/lib/python3.9/site-packages/actinia_core/processing/actinia_processing/persistent/mapset_management.py\", line 247, in _execute\n    raise AsyncProcessError(\n"],"type":"<class 'actinia_core.core.common.exceptions.AsyncProcessError'>"},"http_code":400,"message":"AsyncProcessError:  Mapset <elevation> does not exits","process_chain_list":[],"process_log":[],"progress":{"num_of_steps":0,"step":0},"queue":"local","resource_id":"resource_id-e0d56b92-2fe8-48ec-afd5-f1b306b800cc","status":"error","time_delta":0.12059497833251953,"timestamp":1695307665.9370203,"urls":{"resources":[],"status":"https://actinia.mundialis.de/api/v3/resources/fossgis2023/resource_id-e0d56b92-2fe8-48ec-afd5-f1b306b800cc"},"user_id":"fossgis2023"}
anikaweinmann commented 9 months ago

Fixed in version 0.3.1