From c897fd463779fb1bc3c96f3420ce5937e8ee70b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Morales?= Date: Mon, 29 Jul 2024 10:15:58 -0600 Subject: [PATCH] handle forks --- .../quick_start_distributed.ipynb | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/nbs/docs/getting-started/quick_start_distributed.ipynb b/nbs/docs/getting-started/quick_start_distributed.ipynb index 785d6cdc..96431499 100644 --- a/nbs/docs/getting-started/quick_start_distributed.ipynb +++ b/nbs/docs/getting-started/quick_start_distributed.ipynb @@ -45,11 +45,13 @@ "source": [ "import platform\n", "import sys\n", + "import tempfile\n", "\n", "import matplotlib.pyplot as plt\n", "import git\n", "import numpy as np\n", "import pandas as pd\n", + "from botocore.exceptions import NoCredentialsError\n", "from sklearn.base import BaseEstimator\n", "\n", "from mlforecast.distributed import DistributedMLForecast\n", @@ -559,7 +561,12 @@ "source": [ "save_dir = build_unique_name('dask')\n", "save_path = f's3://nixtla-tmp/mlf/{save_dir}'\n", - "fcst.save(save_path)" + "tmpdir = tempfile.TemporaryDirectory()\n", + "try:\n", + " fcst.save(save_path)\n", + "except NoCredentialsError:\n", + " save_path = f'{tmpdir.name}/{save_dir}'\n", + " fcst.save(save_path)" ] }, { @@ -1241,7 +1248,11 @@ "source": [ "save_dir = build_unique_name('spark')\n", "save_path = f's3://nixtla-tmp/mlf/{save_dir}'\n", - "fcst.save(save_path)" + "try:\n", + " fcst.save(save_path)\n", + "except NoCredentialsError:\n", + " save_path = f'{tmpdir.name}/{save_dir}'\n", + " fcst.save(save_path)" ] }, { @@ -1793,7 +1804,11 @@ "source": [ "save_dir = build_unique_name('ray')\n", "save_path = f's3://nixtla-tmp/mlf/{save_dir}'\n", - "fcst.save(save_path)" + "try:\n", + " fcst.save(save_path)\n", + "except NoCredentialsError:\n", + " save_path = f'{tmpdir.name}/{save_dir}'\n", + " fcst.save(save_path)" ] }, {