简体   繁体   中英

Error 429 - too much requests - trying to delete all classifiers of IBM Watson Visual Recognition service

I'm trying to delete all classifiers of my instance of IBM Watson Visual Recognition service so that I can create only the new classifiers that are used for my app.

To do it, I wrote Node.js code that lists all the classifiers and sends a delete request.

When I executed it (hundreds of delete requests in parallel), I received a 429 error - too many requests . After that, all of my delete requests (even individual ones) received an 404 error - Cannot delete classifier .

My questions are:

  1. Is there a better way to delete all classifiers that is not doing it one by one?
  2. Why am I unable to delete individual classifiers now? Is there some policy that blocks me after a 429 too many requests error?

This is the 429 error that I received in the multiple delete requests

code: 429,
  error: '<HTML><BODY><span class=\'networkMessage\'><h2>Wow, is it HOT in here!</h2>My CPU cores are practically burning up thanks to all the great questions from wonderful humans like you.<p>Popularity has its costs however. Right now I just can\'t quite keep up with everything. So I ask your patience while my human subsystems analyze this load spike to get me more Power.<p>I particularly want to <b>thank you</b> for bringing your questions. PLEASE COME BACK - soon and frequently! Not only do I learn from your usage, but my humans learn from workload spikes (like this one) how to better adjust capacity with Power and Elastic Storage.<p>So again, thank you for helping to make me smarter and better. I\'m still young and growing, but with your patience and help, I hope to make you proud someday!</p>Your buddy,<br>Watson<br><span class=\'watsonIcon\'></span>p.s. Please share your experiences in the Watson C

Edit:

I noticed that the error apparently happens only when I try to delete a "default" classifier that is provided by the service (like "Graphics", "Color", "Black_and_white", etc.). The deletion works fine for when I try do delete a classifier that I created with my own pictures.

Is it a characteristic of the service that I'm not allowed to delete the default classifiers ? If it is, any special reason for that ? The app that I'm building doesn't need all those built-in classifiers, so it is useless to have all that.

I understand that I can inform the list of classifiers that I want to use when I request a new classification, but in this situation I'll need to keep a separated list of my classifiers and will not be able to request a more generic classification without getting the default classifiers in the result.

I'm using node js module "watson-developer-cloud": "^1.3.1" - I'm not sure what API versions it uses internally. I just noticed there is a newer version available. I'll update it and report back here if there is any difference.

This is the JS function that I'm using to delete a single classifier

function deleteClassifier(classifier_id,callback){
    var data = {
      "classifier_id": classifier_id,
    };
    visualRecognition.deleteClassifier(data,function(err, response) {
      if (err){
        callback(err);
      }
      else{
        callback(null, response);
      }
    });
  }

-Edit

The occurred when I was using V2 API - But I believe it is not related to API version. See the accepted answer

1-Is there a better way to delete all classifiers that is not doing it one by one ?

No, you must delete them one by one.

2- Why I'm unable to delete individual classifiers now ? Is there some policy that blocks me after a 429 too much requests ?

I suspect that when your request to DELETE /classifiers/{classifier_id} returns a 404, it is because the classifier_id was previously, successfully deleted. You can verify this by doing a GET /classifiers operation to see the list of all current custom classifiers for your account. 404 is the designed response to an attempt to delete a classifier which cannot be found (which would be the case if it previously was deleted.) There is no policy which would block you after encountering a 429.

Could you give an example of the URLs you are using - I am curious if it is the beta service (v2) or the newest version, v3?

I found the problem is that I was trying to delete the default classifiers and that is not allowed.

In the later version of the API (V3 as I write this answer) there is only one default classifier and it can not be deleted.

The 404 errors that I was getting was because I was trying to delete the default classifiers. All my custom classifiers were already deleted as Matt Hill mentioned in his answer

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM