{
  "id": 585784,
  "title": "GatewayRuntimeError: (<GatewayRuntimeErrorType.SERVER_RAISED_EXCEPTION: 3>, 'list.remove(x): x not in list')",
  "url": "/competitions/cmi-detect-behavior-with-sensor-data/discussion/585784",
  "author_name": "",
  "post_date": "2025-06-23T05:01:45.463214800Z",
  "votes": 1,
  "comment_count": 2,
  "views": 0,
  "content": "<p>I have trained a model and i can see that it is working properly:</p>\n<pre><code> () -&gt; :\n    data = sequence.join(demographics,on=,how=)\n    test_demographic_cols = [\n        , , , , , , \n    ]\n    cleaned_data = feature_engineering(data, test_demographic_cols)\n    pdf = cleaned_data.to_pandas().drop(columns=[])\n    corr_feat_list.remove()\n    corr_feat_list.remove()\n    pdfC = pdf[corr_feat_list]\n    predictions = f_model.predict(pdfC).ravel()\n    predictions = le.inverse_transform(predictions)\n     predictions[]\n\npredict(test_pl, test_demo_pl)\n\n[] \n</code></pre>\n<p>But when i run inference server i am getting this error:</p>\n<p>GatewayRuntimeError: (, 'list.remove(x): x not in list')</p>\n<p>I have tested other public notebooks giving same output and working… Why mine is not?</p>",
  "messages": [
    {
      "id": "3230474",
      "postDate": "06/23/2025 05:01:45",
      "content": "<p>I have trained a model and i can see that it is working properly:</p>\n<pre><code> () -&gt; :\n    data = sequence.join(demographics,on=,how=)\n    test_demographic_cols = [\n        , , , , , , \n    ]\n    cleaned_data = feature_engineering(data, test_demographic_cols)\n    pdf = cleaned_data.to_pandas().drop(columns=[])\n    corr_feat_list.remove()\n    corr_feat_list.remove()\n    pdfC = pdf[corr_feat_list]\n    predictions = f_model.predict(pdfC).ravel()\n    predictions = le.inverse_transform(predictions)\n     predictions[]\n\npredict(test_pl, test_demo_pl)\n\n[] \n</code></pre>\n<p>But when i run inference server i am getting this error:</p>\n<p>GatewayRuntimeError: (, 'list.remove(x): x not in list')</p>\n<p>I have tested other public notebooks giving same output and working… Why mine is not?</p>",
      "rawMarkdown": "I have trained a model and i can see that it is working properly:\n\n```python\ndef predict(sequence: pl.DataFrame, demographics: pl.DataFrame) -> str:\n    data = sequence.join(demographics,on=\"subject\",how=\"left\")\n    test_demographic_cols = [\n        \"adult_child\", \"age\", \"sex\", \"handedness\", \"height_cm\", \"shoulder_to_wrist_cm\", \"elbow_to_wrist_cm\"\n    ]\n    cleaned_data = feature_engineering(data, test_demographic_cols)\n    pdf = cleaned_data.to_pandas().drop(columns=[\"sequence_id\"])\n    corr_feat_list.remove('sequence_id')\n    corr_feat_list.remove('gesture')\n    pdfC = pdf[corr_feat_list]\n    predictions = f_model.predict(pdfC).ravel()\n    predictions = le.inverse_transform(predictions)\n    return predictions[0]\n\npredict(test_pl, test_demo_pl)\n\n[] 'Eyebrow - pull hair'\n```\nBut when i run inference server i am getting this error:\n\nGatewayRuntimeError: (<GatewayRuntimeErrorType.SERVER_RAISED_EXCEPTION: 3>, 'list.remove(x): x not in list')\n\nI have tested other public notebooks giving same output and working... Why mine is not?",
      "votes": null
    },
    {
      "id": "3249494",
      "postDate": "07/16/2025 15:48:47",
      "content": "<p>Hello, in case the issue is still of actuality, I am assuming that you declare corr_fea_list outside the cell as a global variable.<br>\nThe first time that <code>predict</code> gets called it will call <code>corr_feat_list.remove</code> it may work fine but the next time that <code>predict</code> gets called (it gets called once per sequence) it will raise an error because 'seqeunce_id' and 'gesture' will not be present in it anymore.</p>\n<p>Maybe just declare the list without those two elements or perform a list comprehension like </p>\n<pre><code>df[[feat  feat  corr_feat_list   feat  [, ]]]\n</code></pre>",
      "rawMarkdown": "Hello, in case the issue is still of actuality, I am assuming that you declare corr_fea_list outside the cell as a global variable.\nThe first time that `predict` gets called it will call `corr_feat_list.remove` it may work fine but the next time that `predict` gets called (it gets called once per sequence) it will raise an error because 'seqeunce_id' and 'gesture' will not be present in it anymore.\n\nMaybe just declare the list without those two elements or perform a list comprehension like \n```python\ndf[[feat for feat in corr_feat_list if not feat in [\"gesture\", \"sequence_id\"]]]\n```",
      "votes": null
    },
    {
      "id": "3249701",
      "postDate": "07/17/2025 00:59:26",
      "content": "<p>Thanks for your answer. In the end i found that we have 15 minutes to start sending answers for test set. It is impossible to train a model in the submission notebook. What i am doing is saving the model and then just load during submission. The train code remains in the notebook as text. It has been working since that.<br>\nThanks for your support.</p>",
      "rawMarkdown": "Thanks for your answer. In the end i found that we have 15 minutes to start sending answers for test set. It is impossible to train a model in the submission notebook. What i am doing is saving the model and then just load during submission. The train code remains in the notebook as text. It has been working since that.\nThanks for your support.",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 3249494,
      "author_name": "mauroabidalcarrer",
      "author_url": "",
      "post_date": "07/16/2025 15:48:47",
      "content": "<p>Hello, in case the issue is still of actuality, I am assuming that you declare corr_fea_list outside the cell as a global variable.<br>\nThe first time that <code>predict</code> gets called it will call <code>corr_feat_list.remove</code> it may work fine but the next time that <code>predict</code> gets called (it gets called once per sequence) it will raise an error because 'seqeunce_id' and 'gesture' will not be present in it anymore.</p>\n<p>Maybe just declare the list without those two elements or perform a list comprehension like </p>\n<pre><code>df[[feat  feat  corr_feat_list   feat  [, ]]]\n</code></pre>",
      "votes": null,
      "replies": [
        {
          "id": 3249701,
          "author_name": "mayobanexsantana",
          "author_url": "",
          "post_date": "07/17/2025 00:59:26",
          "content": "<p>Thanks for your answer. In the end i found that we have 15 minutes to start sending answers for test set. It is impossible to train a model in the submission notebook. What i am doing is saving the model and then just load during submission. The train code remains in the notebook as text. It has been working since that.<br>\nThanks for your support.</p>",
          "votes": null,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "3230474": "I have trained a model and i can see that it is working properly:\n\n```python\ndef predict(sequence: pl.DataFrame, demographics: pl.DataFrame) -> str:\n    data = sequence.join(demographics,on=\"subject\",how=\"left\")\n    test_demographic_cols = [\n        \"adult_child\", \"age\", \"sex\", \"handedness\", \"height_cm\", \"shoulder_to_wrist_cm\", \"elbow_to_wrist_cm\"\n    ]\n    cleaned_data = feature_engineering(data, test_demographic_cols)\n    pdf = cleaned_data.to_pandas().drop(columns=[\"sequence_id\"])\n    corr_feat_list.remove('sequence_id')\n    corr_feat_list.remove('gesture')\n    pdfC = pdf[corr_feat_list]\n    predictions = f_model.predict(pdfC).ravel()\n    predictions = le.inverse_transform(predictions)\n    return predictions[0]\n\npredict(test_pl, test_demo_pl)\n\n[] 'Eyebrow - pull hair'\n```\nBut when i run inference server i am getting this error:\n\nGatewayRuntimeError: (<GatewayRuntimeErrorType.SERVER_RAISED_EXCEPTION: 3>, 'list.remove(x): x not in list')\n\nI have tested other public notebooks giving same output and working... Why mine is not?",
    "3249494": "Hello, in case the issue is still of actuality, I am assuming that you declare corr_fea_list outside the cell as a global variable.\nThe first time that `predict` gets called it will call `corr_feat_list.remove` it may work fine but the next time that `predict` gets called (it gets called once per sequence) it will raise an error because 'seqeunce_id' and 'gesture' will not be present in it anymore.\n\nMaybe just declare the list without those two elements or perform a list comprehension like \n```python\ndf[[feat for feat in corr_feat_list if not feat in [\"gesture\", \"sequence_id\"]]]\n```",
    "3249701": "Thanks for your answer. In the end i found that we have 15 minutes to start sending answers for test set. It is impossible to train a model in the submission notebook. What i am doing is saving the model and then just load during submission. The train code remains in the notebook as text. It has been working since that.\nThanks for your support."
  },
  "source": "meta"
}