{
  "id": 206618,
  "title": "Debugging strategy",
  "url": "/competitions/riiid-test-answer-prediction/discussion/206618",
  "author_name": "",
  "post_date": "2020-12-25T14:50:18.929850300Z",
  "votes": 4,
  "comment_count": 1,
  "views": 0,
  "content": "<p>It might already be well known I don't know but I found a useful debugging strategy if you have score submission errors.</p>\n<p>Inside my code, I put tests like :</p>\n<pre><code>if num_tasks &gt; 5:\n    raise NotImplementedError('too_many_tasks')\n</code></pre>\n<p>And in the for loop of inference, I encapsulate my code in a try/except block like that :</p>\n<pre><code>for test_df, sample_prediction_df in iter_test():\n    try:\n       my code\n    except NotImplementedError as e:\n        msg = str(e)\n        if msg == 'too_many_tasks':\n            sleep(60 * 5) # waith 5 minutes\n            raise Exception # and stop the program        \n        if msg == 'an_other_customized_error_message':\n            sleep(60 * 6) # waith 6 minutes\n            raise Exception # and stop the program\n</code></pre>\n<p>That way, by measuring how quick you got the error, you can know where the error is coming from and test many different things.<br>\nDebugging these errors is really a pain but it's a bit easier that way (I've not finished but it helped me)</p>",
  "messages": [
    {
      "id": "1126366",
      "postDate": "12/25/2020 14:50:18",
      "content": "<p>It might already be well known I don't know but I found a useful debugging strategy if you have score submission errors.</p>\n<p>Inside my code, I put tests like :</p>\n<pre><code>if num_tasks &gt; 5:\n    raise NotImplementedError('too_many_tasks')\n</code></pre>\n<p>And in the for loop of inference, I encapsulate my code in a try/except block like that :</p>\n<pre><code>for test_df, sample_prediction_df in iter_test():\n    try:\n       my code\n    except NotImplementedError as e:\n        msg = str(e)\n        if msg == 'too_many_tasks':\n            sleep(60 * 5) # waith 5 minutes\n            raise Exception # and stop the program        \n        if msg == 'an_other_customized_error_message':\n            sleep(60 * 6) # waith 6 minutes\n            raise Exception # and stop the program\n</code></pre>\n<p>That way, by measuring how quick you got the error, you can know where the error is coming from and test many different things.<br>\nDebugging these errors is really a pain but it's a bit easier that way (I've not finished but it helped me)</p>",
      "rawMarkdown": "It might already be well known I don't know but I found a useful debugging strategy if you have score submission errors.\n\nInside my code, I put tests like :\n\n```\nif num_tasks > 5:\n    raise NotImplementedError('too_many_tasks')\n```\n\nAnd in the for loop of inference, I encapsulate my code in a try/except block like that :\n\n```\nfor test_df, sample_prediction_df in iter_test():\n    try:\n       my code\n    except NotImplementedError as e:\n        msg = str(e)\n        if msg == 'too_many_tasks':\n            sleep(60 * 5) # waith 5 minutes\n            raise Exception # and stop the program        \n        if msg == 'an_other_customized_error_message':\n            sleep(60 * 6) # waith 6 minutes\n            raise Exception # and stop the program\n```\n\nThat way, by measuring how quick you got the error, you can know where the error is coming from and test many different things.\nDebugging these errors is really a pain but it's a bit easier that way (I've not finished but it helped me)",
      "votes": null
    },
    {
      "id": "1127558",
      "postDate": "12/26/2020 16:32:42",
      "content": "<p>Thank you for sharing. This is useful ..</p>",
      "rawMarkdown": "Thank you for sharing. This is useful ..",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 1127558,
      "author_name": "atharvaingle",
      "author_url": "",
      "post_date": "12/26/2020 16:32:42",
      "content": "<p>Thank you for sharing. This is useful ..</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "1126366": "It might already be well known I don't know but I found a useful debugging strategy if you have score submission errors.\n\nInside my code, I put tests like :\n\n```\nif num_tasks > 5:\n    raise NotImplementedError('too_many_tasks')\n```\n\nAnd in the for loop of inference, I encapsulate my code in a try/except block like that :\n\n```\nfor test_df, sample_prediction_df in iter_test():\n    try:\n       my code\n    except NotImplementedError as e:\n        msg = str(e)\n        if msg == 'too_many_tasks':\n            sleep(60 * 5) # waith 5 minutes\n            raise Exception # and stop the program        \n        if msg == 'an_other_customized_error_message':\n            sleep(60 * 6) # waith 6 minutes\n            raise Exception # and stop the program\n```\n\nThat way, by measuring how quick you got the error, you can know where the error is coming from and test many different things.\nDebugging these errors is really a pain but it's a bit easier that way (I've not finished but it helped me)",
    "1127558": "Thank you for sharing. This is useful .."
  },
  "source": "meta"
}