From 4c6bbfc6b0c785b496eba1a9fe519280270a13b3 Mon Sep 17 00:00:00 2001 From: marcopeix Date: Wed, 28 Aug 2024 10:42:24 -0400 Subject: [PATCH 1/8] Raise error when payload is too large and suggest right number of partitions --- nbs/nixtla_client.ipynb | 107 ++++++++++++++++++++++++++++++++++++++-- nixtla/nixtla_client.py | 8 ++- 2 files changed, 110 insertions(+), 5 deletions(-) diff --git a/nbs/nixtla_client.ipynb b/nbs/nixtla_client.ipynb index 172b58b8..4c54f4b3 100644 --- a/nbs/nixtla_client.ipynb +++ b/nbs/nixtla_client.ipynb @@ -36,6 +36,7 @@ "#| export\n", "import logging\n", "import math\n", + "import sys\n", "import os\n", "import warnings\n", "from concurrent.futures import ThreadPoolExecutor, as_completed\n", @@ -156,7 +157,18 @@ "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": null, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "#| hide\n", "load_dotenv(override=True)" @@ -687,6 +699,9 @@ "\n", " ensure_contiguous_arrays(payload)\n", " content = orjson.dumps(payload, option=orjson.OPT_SERIALIZE_NUMPY)\n", + " content_size_mb = sys.getsizeof(content) / (1024*1024)\n", + " if content_size_mb > 200:\n", + " raise ValueError(f'The payload is too large. Set num_partitions={math.ceil(content_size_mb / 200)}')\n", " resp = client.post(url=endpoint, content=content)\n", " resp_body = orjson.loads(resp.content)\n", " if resp.status_code != 200:\n", @@ -1600,7 +1615,25 @@ "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "INFO:__main__:Happy Forecasting! :), If you have questions or need support, please email ops@nixtla.io\n" + ] + }, + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": null, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "#| hide\n", "nixtla_client.validate_api_key()" @@ -1621,7 +1654,20 @@ "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [], + "outputs": [ + { + "ename": "KeyError", + "evalue": "'NIXTLA_API_KEY_CUSTOM'", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mKeyError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[13], line 3\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;66;03m#| hide\u001b[39;00m\n\u001b[1;32m 2\u001b[0m _nixtla_client \u001b[38;5;241m=\u001b[39m NixtlaClient(\n\u001b[0;32m----> 3\u001b[0m api_key\u001b[38;5;241m=\u001b[39m\u001b[43mos\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43menviron\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mNIXTLA_API_KEY_CUSTOM\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m]\u001b[49m, \n\u001b[1;32m 4\u001b[0m base_url\u001b[38;5;241m=\u001b[39mos\u001b[38;5;241m.\u001b[39menviron[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mNIXTLA_BASE_URL_CUSTOM\u001b[39m\u001b[38;5;124m'\u001b[39m],\n\u001b[1;32m 5\u001b[0m )\n\u001b[1;32m 6\u001b[0m _nixtla_client\u001b[38;5;241m.\u001b[39mvalidate_api_key()\n", + "File \u001b[0;32m~/miniconda3/envs/nixtlats/lib/python3.10/os.py:680\u001b[0m, in \u001b[0;36m_Environ.__getitem__\u001b[0;34m(self, key)\u001b[0m\n\u001b[1;32m 677\u001b[0m value \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_data[\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mencodekey(key)]\n\u001b[1;32m 678\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mKeyError\u001b[39;00m:\n\u001b[1;32m 679\u001b[0m \u001b[38;5;66;03m# raise KeyError with the original key value\u001b[39;00m\n\u001b[0;32m--> 680\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mKeyError\u001b[39;00m(key) \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[1;32m 681\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mdecodevalue(value)\n", + "\u001b[0;31mKeyError\u001b[0m: 'NIXTLA_API_KEY_CUSTOM'" + ] + } + ], "source": [ "#| hide\n", "_nixtla_client = NixtlaClient(\n", @@ -1635,7 +1681,15 @@ "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "INFO:__main__:Validating inputs...\n" + ] + } + ], "source": [ "#| hide\n", "test_fail(\n", @@ -2482,6 +2536,51 @@ " assert any(expected_warning in str(warning.message) for warning in w)" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "INFO:__main__:Validating inputs...\n", + "INFO:__main__:Querying model metadata...\n", + "INFO:__main__:Preprocessing dataframes...\n", + "INFO:__main__:Calling Forecast Endpoint...\n" + ] + } + ], + "source": [ + "#| hide\n", + "# Test large requests raise error and suggest partition number\n", + "from datetime import datetime, timedelta\n", + "\n", + "def generate_large_dataframe(n_unique_ids=15_000, rows_per_id=1_000):\n", + " total_rows = n_unique_ids * rows_per_id \n", + " unique_ids = [f'id_{i:05d}' for i in range(n_unique_ids)]\n", + " \n", + " start_date = datetime(2020, 1, 1)\n", + " dates = [start_date + timedelta(minutes=i) for i in range(rows_per_id)]\n", + " \n", + " df = pd.DataFrame({\n", + " 'unique_id': np.repeat(unique_ids, rows_per_id),\n", + " 'ds': dates * n_unique_ids,\n", + " 'y': np.random.rand(total_rows)\n", + " })\n", + " df = df.sort_values(['unique_id', 'ds']).reset_index(drop=True)\n", + " \n", + " return df\n", + "\n", + "df = generate_large_dataframe()\n", + "\n", + "test_fail(\n", + " lambda: NixtlaClient().forecast(df=df, h=1, freq='min', finetune_steps=2),\n", + " contains='num_partitions'\n", + ")" + ] + }, { "cell_type": "markdown", "metadata": {}, diff --git a/nixtla/nixtla_client.py b/nixtla/nixtla_client.py index 69d8e6cb..d9cd7d3f 100644 --- a/nixtla/nixtla_client.py +++ b/nixtla/nixtla_client.py @@ -6,6 +6,7 @@ # %% ../nbs/nixtla_client.ipynb 3 import logging import math +import sys import os import warnings from concurrent.futures import ThreadPoolExecutor, as_completed @@ -620,6 +621,11 @@ def ensure_contiguous_arrays(d: Dict[str, Any]) -> None: ensure_contiguous_arrays(payload) content = orjson.dumps(payload, option=orjson.OPT_SERIALIZE_NUMPY) + content_size_mb = sys.getsizeof(content) / (1024 * 1024) + if content_size_mb > 200: + raise ValueError( + f"The payload is too large. Set num_partitions={math.ceil(content_size_mb / 200)}" + ) resp = client.post(url=endpoint, content=content) resp_body = orjson.loads(resp.content) if resp.status_code != 200: @@ -1500,7 +1506,7 @@ def plot( ax=ax, ) -# %% ../nbs/nixtla_client.ipynb 52 +# %% ../nbs/nixtla_client.ipynb 53 def _forecast_wrapper( df: pd.DataFrame, client: NixtlaClient, From 8d376609b73fe3777f164179077215f716d6f3b9 Mon Sep 17 00:00:00 2001 From: marcopeix Date: Wed, 28 Aug 2024 14:25:03 -0400 Subject: [PATCH 2/8] Trying to fix test for large payloads --- nbs/nixtla_client.ipynb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/nbs/nixtla_client.ipynb b/nbs/nixtla_client.ipynb index 4c54f4b3..dca94fe6 100644 --- a/nbs/nixtla_client.ipynb +++ b/nbs/nixtla_client.ipynb @@ -2546,7 +2546,6 @@ "output_type": "stream", "text": [ "INFO:__main__:Validating inputs...\n", - "INFO:__main__:Querying model metadata...\n", "INFO:__main__:Preprocessing dataframes...\n", "INFO:__main__:Calling Forecast Endpoint...\n" ] @@ -2576,7 +2575,7 @@ "df = generate_large_dataframe()\n", "\n", "test_fail(\n", - " lambda: NixtlaClient().forecast(df=df, h=1, freq='min', finetune_steps=2),\n", + " lambda: nixtla_client.forecast(df=df, h=1, freq='min', finetune_steps=2),\n", " contains='num_partitions'\n", ")" ] From 5b8604f1829a225f137b0c8659b92d1220560136 Mon Sep 17 00:00:00 2001 From: marcopeix Date: Wed, 28 Aug 2024 14:33:44 -0400 Subject: [PATCH 3/8] Use len to get size of payload --- nbs/nixtla_client.ipynb | 73 ++++------------------------------------- nixtla/nixtla_client.py | 3 +- 2 files changed, 7 insertions(+), 69 deletions(-) diff --git a/nbs/nixtla_client.ipynb b/nbs/nixtla_client.ipynb index dca94fe6..b64b0fe7 100644 --- a/nbs/nixtla_client.ipynb +++ b/nbs/nixtla_client.ipynb @@ -36,7 +36,6 @@ "#| export\n", "import logging\n", "import math\n", - "import sys\n", "import os\n", "import warnings\n", "from concurrent.futures import ThreadPoolExecutor, as_completed\n", @@ -157,18 +156,7 @@ "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "True" - ] - }, - "execution_count": null, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "#| hide\n", "load_dotenv(override=True)" @@ -699,7 +687,7 @@ "\n", " ensure_contiguous_arrays(payload)\n", " content = orjson.dumps(payload, option=orjson.OPT_SERIALIZE_NUMPY)\n", - " content_size_mb = sys.getsizeof(content) / (1024*1024)\n", + " content_size_mb = len(content) / (1024*1024)\n", " if content_size_mb > 200:\n", " raise ValueError(f'The payload is too large. Set num_partitions={math.ceil(content_size_mb / 200)}')\n", " resp = client.post(url=endpoint, content=content)\n", @@ -1615,25 +1603,7 @@ "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "INFO:__main__:Happy Forecasting! :), If you have questions or need support, please email ops@nixtla.io\n" - ] - }, - { - "data": { - "text/plain": [ - "True" - ] - }, - "execution_count": null, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "#| hide\n", "nixtla_client.validate_api_key()" @@ -1654,20 +1624,7 @@ "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [ - { - "ename": "KeyError", - "evalue": "'NIXTLA_API_KEY_CUSTOM'", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mKeyError\u001b[0m Traceback (most recent call last)", - "Cell \u001b[0;32mIn[13], line 3\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;66;03m#| hide\u001b[39;00m\n\u001b[1;32m 2\u001b[0m _nixtla_client \u001b[38;5;241m=\u001b[39m NixtlaClient(\n\u001b[0;32m----> 3\u001b[0m api_key\u001b[38;5;241m=\u001b[39m\u001b[43mos\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43menviron\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mNIXTLA_API_KEY_CUSTOM\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m]\u001b[49m, \n\u001b[1;32m 4\u001b[0m base_url\u001b[38;5;241m=\u001b[39mos\u001b[38;5;241m.\u001b[39menviron[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mNIXTLA_BASE_URL_CUSTOM\u001b[39m\u001b[38;5;124m'\u001b[39m],\n\u001b[1;32m 5\u001b[0m )\n\u001b[1;32m 6\u001b[0m _nixtla_client\u001b[38;5;241m.\u001b[39mvalidate_api_key()\n", - "File \u001b[0;32m~/miniconda3/envs/nixtlats/lib/python3.10/os.py:680\u001b[0m, in \u001b[0;36m_Environ.__getitem__\u001b[0;34m(self, key)\u001b[0m\n\u001b[1;32m 677\u001b[0m value \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_data[\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mencodekey(key)]\n\u001b[1;32m 678\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mKeyError\u001b[39;00m:\n\u001b[1;32m 679\u001b[0m \u001b[38;5;66;03m# raise KeyError with the original key value\u001b[39;00m\n\u001b[0;32m--> 680\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mKeyError\u001b[39;00m(key) \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[1;32m 681\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mdecodevalue(value)\n", - "\u001b[0;31mKeyError\u001b[0m: 'NIXTLA_API_KEY_CUSTOM'" - ] - } - ], + "outputs": [], "source": [ "#| hide\n", "_nixtla_client = NixtlaClient(\n", @@ -1681,15 +1638,7 @@ "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "INFO:__main__:Validating inputs...\n" - ] - } - ], + "outputs": [], "source": [ "#| hide\n", "test_fail(\n", @@ -2540,17 +2489,7 @@ "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "INFO:__main__:Validating inputs...\n", - "INFO:__main__:Preprocessing dataframes...\n", - "INFO:__main__:Calling Forecast Endpoint...\n" - ] - } - ], + "outputs": [], "source": [ "#| hide\n", "# Test large requests raise error and suggest partition number\n", diff --git a/nixtla/nixtla_client.py b/nixtla/nixtla_client.py index d9cd7d3f..765ed216 100644 --- a/nixtla/nixtla_client.py +++ b/nixtla/nixtla_client.py @@ -6,7 +6,6 @@ # %% ../nbs/nixtla_client.ipynb 3 import logging import math -import sys import os import warnings from concurrent.futures import ThreadPoolExecutor, as_completed @@ -621,7 +620,7 @@ def ensure_contiguous_arrays(d: Dict[str, Any]) -> None: ensure_contiguous_arrays(payload) content = orjson.dumps(payload, option=orjson.OPT_SERIALIZE_NUMPY) - content_size_mb = sys.getsizeof(content) / (1024 * 1024) + content_size_mb = len(content) / (1024 * 1024) if content_size_mb > 200: raise ValueError( f"The payload is too large. Set num_partitions={math.ceil(content_size_mb / 200)}" From 4a2cc03eb967f6f11c2a86bd0d6e9941b4a67563 Mon Sep 17 00:00:00 2001 From: marcopeix Date: Fri, 30 Aug 2024 13:46:35 -0400 Subject: [PATCH 4/8] rewrite test to see if it passes CI --- nbs/nixtla_client.ipynb | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/nbs/nixtla_client.ipynb b/nbs/nixtla_client.ipynb index b64b0fe7..15e51968 100644 --- a/nbs/nixtla_client.ipynb +++ b/nbs/nixtla_client.ipynb @@ -2511,12 +2511,17 @@ " \n", " return df\n", "\n", - "df = generate_large_dataframe()\n", + "def test_large_payload_error():\n", + " df = generate_large_dataframe()\n", + " try:\n", + " nixtla_client.forecast(df=df, h=1, freq='min', finetune_steps=2)\n", + " assert False, \"Expected ValueError was not raised\"\n", + " except ValueError:\n", + " pass\n", + " except Exception as e:\n", + " assert False, f\"Expected ValueError, but got {type(e).__name__}\"\n", "\n", - "test_fail(\n", - " lambda: nixtla_client.forecast(df=df, h=1, freq='min', finetune_steps=2),\n", - " contains='num_partitions'\n", - ")" + "test_large_payload_error()" ] }, { From ecfff494c6ef78defde3a87ae76e0a8fdd6d4cae Mon Sep 17 00:00:00 2001 From: marcopeix Date: Fri, 30 Aug 2024 13:59:27 -0400 Subject: [PATCH 5/8] Put imports in separate cell --- nbs/nixtla_client.ipynb | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/nbs/nixtla_client.ipynb b/nbs/nixtla_client.ipynb index 15e51968..96731936 100644 --- a/nbs/nixtla_client.ipynb +++ b/nbs/nixtla_client.ipynb @@ -2485,6 +2485,16 @@ " assert any(expected_warning in str(warning.message) for warning in w)" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "#| hide\n", + "from datetime import datetime, timedelta" + ] + }, { "cell_type": "code", "execution_count": null, @@ -2493,7 +2503,6 @@ "source": [ "#| hide\n", "# Test large requests raise error and suggest partition number\n", - "from datetime import datetime, timedelta\n", "\n", "def generate_large_dataframe(n_unique_ids=15_000, rows_per_id=1_000):\n", " total_rows = n_unique_ids * rows_per_id \n", @@ -2511,17 +2520,12 @@ " \n", " return df\n", "\n", - "def test_large_payload_error():\n", - " df = generate_large_dataframe()\n", - " try:\n", - " nixtla_client.forecast(df=df, h=1, freq='min', finetune_steps=2)\n", - " assert False, \"Expected ValueError was not raised\"\n", - " except ValueError:\n", - " pass\n", - " except Exception as e:\n", - " assert False, f\"Expected ValueError, but got {type(e).__name__}\"\n", + "df = generate_large_dataframe()\n", "\n", - "test_large_payload_error()" + "test_fail(\n", + " lambda: nixtla_client.forecast(df=df, h=1, freq='min', finetune_steps=2),\n", + " contains=\"num_partitions\"\n", + ")" ] }, { From 4adc675ef8f889d85f49e1ae97d51a1383ad9c99 Mon Sep 17 00:00:00 2001 From: marcopeix Date: Fri, 30 Aug 2024 15:17:49 -0400 Subject: [PATCH 6/8] Use generate_series in test --- nbs/nixtla_client.ipynb | 30 +----------------------------- 1 file changed, 1 insertion(+), 29 deletions(-) diff --git a/nbs/nixtla_client.ipynb b/nbs/nixtla_client.ipynb index 96731936..757f3dc9 100644 --- a/nbs/nixtla_client.ipynb +++ b/nbs/nixtla_client.ipynb @@ -2485,16 +2485,6 @@ " assert any(expected_warning in str(warning.message) for warning in w)" ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "#| hide\n", - "from datetime import datetime, timedelta" - ] - }, { "cell_type": "code", "execution_count": null, @@ -2503,25 +2493,7 @@ "source": [ "#| hide\n", "# Test large requests raise error and suggest partition number\n", - "\n", - "def generate_large_dataframe(n_unique_ids=15_000, rows_per_id=1_000):\n", - " total_rows = n_unique_ids * rows_per_id \n", - " unique_ids = [f'id_{i:05d}' for i in range(n_unique_ids)]\n", - " \n", - " start_date = datetime(2020, 1, 1)\n", - " dates = [start_date + timedelta(minutes=i) for i in range(rows_per_id)]\n", - " \n", - " df = pd.DataFrame({\n", - " 'unique_id': np.repeat(unique_ids, rows_per_id),\n", - " 'ds': dates * n_unique_ids,\n", - " 'y': np.random.rand(total_rows)\n", - " })\n", - " df = df.sort_values(['unique_id', 'ds']).reset_index(drop=True)\n", - " \n", - " return df\n", - "\n", - "df = generate_large_dataframe()\n", - "\n", + "df = generate_series(15_000, min_length=1_000, max_length=1_000)\n", "test_fail(\n", " lambda: nixtla_client.forecast(df=df, h=1, freq='min', finetune_steps=2),\n", " contains=\"num_partitions\"\n", From ba1ad50c0fed0372e736a108fe720d01f0e65018 Mon Sep 17 00:00:00 2001 From: marcopeix Date: Fri, 30 Aug 2024 16:27:11 -0400 Subject: [PATCH 7/8] Modify test for missing X_df --- nbs/nixtla_client.ipynb | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/nbs/nixtla_client.ipynb b/nbs/nixtla_client.ipynb index 8d34c4f2..b9e7c03a 100644 --- a/nbs/nixtla_client.ipynb +++ b/nbs/nixtla_client.ipynb @@ -2486,15 +2486,10 @@ "#| hide\n", "# test for showing the correct warning if X_df is missing but df has exogenous columns\n", "df = generate_series(n_series=2, min_length=5, max_length=20, n_static_features=3)\n", - "missing_exogenous = df.columns.drop(['unique_id', 'ds', 'y']).tolist()\n", - "expected_warning = (\n", - " f'`df` contains the following exogenous features: {missing_exogenous}, '\n", - " 'but `X_df` was not provided. They will be ignored.' \n", - ")\n", - "\n", - "with warnings.catch_warnings(record=True) as w:\n", - " forecasts = nixtla_client.forecast(df, h=5)\n", - " assert any(expected_warning in str(warning.message) for warning in w)" + "test_fail(\n", + " lambda: nixtla_client.forecast(df, h=5),\n", + " contains=\"status_code: 422\"\n", + ")" ] }, { @@ -2505,11 +2500,11 @@ "source": [ "#| hide\n", "# Test large requests raise error and suggest partition number\n", - "df = generate_series(15_000, min_length=1_000, max_length=1_000)\n", + "df = generate_series(20_000, min_length=1_000, max_length=1_000, freq='min')\n", "test_fail(\n", " lambda: nixtla_client.forecast(df=df, h=1, freq='min', finetune_steps=2),\n", " contains=\"num_partitions\"\n", - ")" + ")\n" ] }, { From ca2c9f1e65a6dc4c5051efbc2f0d49c1b2d8afbe Mon Sep 17 00:00:00 2001 From: marcopeix Date: Tue, 3 Sep 2024 10:42:50 -0400 Subject: [PATCH 8/8] Potential fix for CI tests --- nbs/src/nixtla_client.ipynb | 17 +---------------- nixtla/nixtla_client.py | 2 +- 2 files changed, 2 insertions(+), 17 deletions(-) diff --git a/nbs/src/nixtla_client.ipynb b/nbs/src/nixtla_client.ipynb index 89c112ab..5ce30f76 100644 --- a/nbs/src/nixtla_client.ipynb +++ b/nbs/src/nixtla_client.ipynb @@ -2492,21 +2492,6 @@ ")" ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "#| hide\n", - "# test for showing the correct warning if X_df is missing but df has exogenous columns\n", - "df = generate_series(n_series=2, min_length=5, max_length=20, n_static_features=3)\n", - "test_fail(\n", - " lambda: nixtla_client.forecast(df, h=5),\n", - " contains=\"status_code: 422\"\n", - ")" - ] - }, { "cell_type": "code", "execution_count": null, @@ -2519,7 +2504,7 @@ "test_fail(\n", " lambda: nixtla_client.forecast(df=df, h=1, freq='min', finetune_steps=2),\n", " contains=\"num_partitions\"\n", - ")\n" + ")" ] }, { diff --git a/nixtla/nixtla_client.py b/nixtla/nixtla_client.py index bd7b54f7..b86a5cd0 100644 --- a/nixtla/nixtla_client.py +++ b/nixtla/nixtla_client.py @@ -1536,7 +1536,7 @@ def plot( ax=ax, ) -# %% ../nbs/src/nixtla_client.ipynb 53 +# %% ../nbs/src/nixtla_client.ipynb 52 def _forecast_wrapper( df: pd.DataFrame, client: NixtlaClient,