averbis / averbis-python-api

Conveniently access the REST API of Averbis products using Python
Apache License 2.0
12 stars 4 forks source link

Allow for checking if pipeline already exists #47

Closed DavidHuebner closed 3 years ago

DavidHuebner commented 3 years ago

Is your feature request related to a problem? Please describe. Sometimes, it is required to check if a pipeline already exists.

In the Python-API, there is the function pipeline.get_info() which calls the endpoint /v1/textanalysis/projects/{project}/pipelines/{pipeline}. If the pipeline exists, this returns some information about the pipeline. If it does not exists, it returns:

Exception: Unable to perform request: No pipeline named 'my_pipeline_name' exists in project 'my_project_name'.

Currently, some people used a try: ... except: ... block to use this information to conclude if the pipeline exists.This is obviously suboptimal, because it does not allow to differentiate between a 404-error (not found) and other kind of errors (e.g. 401-not authorized).

Describe the solution you'd like I want to have a pipeline function pipeline.exists() that can be used for that purpose

We could implement it in the following way (TO BE DISCUSSED): When handling the errors in the function __handle_error(response) , we could issue a new Exception type NotFoundException for 404-errors. In the new pipeline.exists() method, we would then

Describe alternatives you've considered The alternative is to wait for a new endpoint in the product which is a blocker.

DavidHuebner commented 3 years ago

I think the solution outlined in #52 is best for solving this issue. Let's wait for the upstream changes.