Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: defuault token to os.environ.get and remove os.environ #164

Merged
merged 4 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ Get started with TimeGPT now:
df = pd.read_csv('https://raw.githubusercontent.com/Nixtla/transfer-learning-time-series/main/datasets/electricity-short.csv')

from nixtlats import TimeGPT
timegpt = TimeGPT(token=os.environ['TIMEGPT_TOKEN'])
timegpt = TimeGPT(
# defaults to os.environ.get("TIMEGPT_TOKEN")
token = 'my_token_provided_by_nixtla'
)
fcst_df = timegpt.forecast(df, h=24, level=[80, 90])
```

Expand Down
9 changes: 3 additions & 6 deletions nbs/distributed.timegpt.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@
"\n",
" def __init__(\n",
" self, \n",
" token: str, \n",
" environment: str,\n",
" token: Optional[str] = None, \n",
" environment: Optional[str] = None,\n",
" max_retries: int = 6,\n",
" retry_interval: int = 10,\n",
" max_wait_time: int = 60,\n",
Expand Down Expand Up @@ -801,10 +801,7 @@
"outputs": [],
"source": [
"#| hide\n",
"distributed_timegpt = _DistributedTimeGPT(\n",
" token=os.environ['TIMEGPT_TOKEN'], \n",
" environment=None,\n",
")"
"distributed_timegpt = _DistributedTimeGPT()"
]
},
{
Expand Down
83 changes: 52 additions & 31 deletions nbs/docs/getting-started/1_getting_started_short.ipynb

Large diffs are not rendered by default.

94 changes: 87 additions & 7 deletions nbs/docs/how-to-guides/0_distributed_fcst_spark.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,42 @@
"execution_count": null,
"id": "fcf6004b-ebd0-4a3c-8c02-d5463c62f79e",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/home/ubuntu/miniconda/envs/nixtlats/lib/python3.11/site-packages/statsforecast/core.py:25: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
" from tqdm.autonotebook import tqdm\n"
]
}
],
"source": [
"from nixtlats import TimeGPT"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "bec2b1fb-74fb-4464-b57b-84c676cb997c",
"metadata": {},
"outputs": [],
"source": [
"from nixtlats import TimeGPT\n",
"\n",
"timegpt = TimeGPT(token=os.environ['TIMEGPT_TOKEN'])"
"timegpt = TimeGPT(\n",
" # defaults to os.environ.get(\"TIMEGPT_TOKEN\")\n",
" token = 'my_token_provided_by_nixtla'\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "57091ace-6068-410d-82fc-2b0bd20d63c1",
"metadata": {},
"outputs": [],
"source": [
"#| hide\n",
"timegpt = TimeGPT()"
]
},
{
Expand All @@ -110,8 +141,8 @@
"text": [
"Setting default log level to \"WARN\".\n",
"To adjust logging level use sc.setLogLevel(newLevel). For SparkR, use setLogLevel(newLevel).\n",
"23/11/08 02:44:31 WARN NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable\n",
"23/11/08 02:44:31 WARN Utils: Service 'SparkUI' could not bind on port 4040. Attempting port 4041.\n"
"23/11/09 17:49:01 WARN NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable\n",
"23/11/09 17:49:02 WARN Utils: Service 'SparkUI' could not bind on port 4040. Attempting port 4041.\n"
]
}
],
Expand Down Expand Up @@ -228,7 +259,55 @@
"execution_count": null,
"id": "ce55c5fa-ddd7-454a-aa43-697aa8c805d8",
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:nixtlats.timegpt:Validating inputs...\n",
"INFO:nixtlats.timegpt:Preprocessing dataframes...\n",
"INFO:nixtlats.timegpt:Inferred freq: H\n",
"INFO:nixtlats.timegpt:Calling Forecast Endpoint... (36 + 60) / 96]\n",
"INFO:nixtlats.timegpt:Validating inputs... (54 + 42) / 96]\n",
"INFO:nixtlats.timegpt:Preprocessing dataframes...\n",
"INFO:nixtlats.timegpt:Inferred freq: H\n",
"INFO:nixtlats.timegpt:Validating inputs...\n",
"INFO:nixtlats.timegpt:Preprocessing dataframes...\n",
"INFO:nixtlats.timegpt:Inferred freq: H\n",
"INFO:nixtlats.timegpt:Validating inputs...\n",
"INFO:nixtlats.timegpt:Preprocessing dataframes...\n",
"INFO:nixtlats.timegpt:Inferred freq: H\n",
"INFO:nixtlats.timegpt:Validating inputs...========> (71 + 25) / 96]\n",
"INFO:nixtlats.timegpt:Preprocessing dataframes...\n",
"INFO:nixtlats.timegpt:Inferred freq: H\n",
"INFO:nixtlats.timegpt:Calling Forecast Endpoint...=============> (92 + 4) / 96]\n",
"INFO:nixtlats.timegpt:Calling Forecast Endpoint...\n",
"INFO:nixtlats.timegpt:Calling Forecast Endpoint...\n",
"INFO:nixtlats.timegpt:Calling Forecast Endpoint...\n",
"INFO:nixtlats.timegpt:Validating inputs... \n",
"INFO:nixtlats.timegpt:Preprocessing dataframes...\n",
"INFO:nixtlats.timegpt:Inferred freq: H\n",
"INFO:nixtlats.timegpt:Validating inputs...\n",
"INFO:nixtlats.timegpt:Preprocessing dataframes...\n",
"INFO:nixtlats.timegpt:Inferred freq: H\n",
"INFO:nixtlats.timegpt:Calling Forecast Endpoint...===> (76 + 20) / 96]\n",
"INFO:nixtlats.timegpt:Calling Forecast Endpoint...\n",
"INFO:nixtlats.timegpt:Validating inputs...\n",
"INFO:nixtlats.timegpt:Preprocessing dataframes...\n",
"INFO:nixtlats.timegpt:Inferred freq: H\n",
"INFO:nixtlats.timegpt:Validating inputs...\n",
"INFO:nixtlats.timegpt:Preprocessing dataframes...\n",
"INFO:nixtlats.timegpt:Inferred freq: H\n",
"INFO:nixtlats.timegpt:Validating inputs...\n",
"INFO:nixtlats.timegpt:Preprocessing dataframes...\n",
"INFO:nixtlats.timegpt:Inferred freq: H\n",
"INFO:nixtlats.timegpt:Calling Forecast Endpoint...=============> (92 + 4) / 96]\n",
"INFO:nixtlats.timegpt:Calling Forecast Endpoint...==============> (93 + 3) / 96]\n",
"INFO:nixtlats.timegpt:Calling Forecast Endpoint...\n",
" \r"
]
}
],
"source": [
"#| hide\n",
"# test different results for different models\n",
Expand Down Expand Up @@ -349,8 +428,9 @@
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:nixtlats.timegpt:Validating inputs... \n",
"INFO:nixtlats.timegpt:Validating inputs...\n",
"INFO:nixtlats.timegpt:Preprocessing dataframes...\n",
"INFO:nixtlats.timegpt:Inferred freq: H\n",
"INFO:nixtlats.timegpt:Calling Forecast Endpoint...=============> (19 + 1) / 20]\n"
]
},
Expand Down
51 changes: 42 additions & 9 deletions nbs/docs/how-to-guides/1_distributed_cv_spark.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,44 @@
{
"cell_type": "code",
"execution_count": null,
"id": "fcf6004b-ebd0-4a3c-8c02-d5463c62f79e",
"id": "21bbe459-ed98-4ac1-8da7-2287305b3680",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/home/ubuntu/miniconda/envs/nixtlats/lib/python3.11/site-packages/statsforecast/core.py:25: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
" from tqdm.autonotebook import tqdm\n"
]
}
],
"source": [
"from nixtlats import TimeGPT"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "97681b52-4e0e-420d-bcb9-e616dbd3b1b3",
"metadata": {},
"outputs": [],
"source": [
"from nixtlats import TimeGPT\n",
"\n",
"timegpt = TimeGPT(token=os.environ['TIMEGPT_TOKEN'])"
"timegpt = TimeGPT(\n",
" # defaults to os.environ.get(\"TIMEGPT_TOKEN\")\n",
" token = 'my_token_provided_by_nixtla'\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0d1f3709-0f62-424c-a066-41efb1bfa2fe",
"metadata": {},
"outputs": [],
"source": [
"#| hide\n",
"timegpt = TimeGPT()"
]
},
{
Expand All @@ -110,8 +141,10 @@
"text": [
"Setting default log level to \"WARN\".\n",
"To adjust logging level use sc.setLogLevel(newLevel). For SparkR, use setLogLevel(newLevel).\n",
"23/11/09 00:34:59 WARN NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable\n",
"23/11/09 00:34:59 WARN Utils: Service 'SparkUI' could not bind on port 4040. Attempting port 4041.\n"
"23/11/09 17:49:20 WARN NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable\n",
"23/11/09 17:49:21 WARN Utils: Service 'SparkUI' could not bind on port 4040. Attempting port 4041.\n",
"23/11/09 17:49:21 WARN Utils: Service 'SparkUI' could not bind on port 4041. Attempting port 4042.\n",
"23/11/09 17:49:21 WARN Utils: Service 'SparkUI' could not bind on port 4042. Attempting port 4043.\n"
]
}
],
Expand Down Expand Up @@ -176,7 +209,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:nixtlats.timegpt:Validating inputs... (4 + 16) / 20]\n",
"INFO:nixtlats.timegpt:Validating inputs... (5 + 15) / 20]\n",
"INFO:nixtlats.timegpt:Inferred freq: H\n",
"INFO:nixtlats.timegpt:Validating inputs...\n",
"INFO:nixtlats.timegpt:Preprocessing dataframes...\n",
Expand Down Expand Up @@ -305,15 +338,15 @@
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:nixtlats.timegpt:Validating inputs...=====================> (19 + 1) / 20]\n",
"INFO:nixtlats.timegpt:Validating inputs...\n",
"INFO:nixtlats.timegpt:Inferred freq: H\n",
"INFO:nixtlats.timegpt:Validating inputs...\n",
"INFO:nixtlats.timegpt:Preprocessing dataframes...\n",
"INFO:nixtlats.timegpt:Inferred freq: H\n",
"WARNING:nixtlats.timegpt:The specified horizon \"h\" exceeds the model horizon. This may lead to less accurate forecasts. Please consider using a smaller horizon.\n",
"INFO:nixtlats.timegpt:Restricting input...\n",
"INFO:nixtlats.timegpt:Calling Forecast Endpoint...\n",
"INFO:nixtlats.timegpt:Validating inputs...\n",
"INFO:nixtlats.timegpt:Validating inputs...=====================> (19 + 1) / 20]\n",
"INFO:nixtlats.timegpt:Validating inputs...\n",
"INFO:nixtlats.timegpt:Preprocessing dataframes...\n",
"INFO:nixtlats.timegpt:Inferred freq: H\n",
Expand Down
38 changes: 26 additions & 12 deletions nbs/docs/tutorials/0_anomaly_detection.ipynb

Large diffs are not rendered by default.

39 changes: 31 additions & 8 deletions nbs/docs/tutorials/1_exogenous_variables.ipynb

Large diffs are not rendered by default.

71 changes: 46 additions & 25 deletions nbs/docs/tutorials/2_holidays.ipynb

Large diffs are not rendered by default.

86 changes: 53 additions & 33 deletions nbs/docs/tutorials/4_prediction_intervals.ipynb

Large diffs are not rendered by default.

31 changes: 26 additions & 5 deletions nbs/docs/tutorials/5_finetuning.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,43 @@
"execution_count": null,
"id": "98942108-d427-42d6-81f8-fa0bb5859395",
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/home/ubuntu/miniconda/envs/nixtlats/lib/python3.11/site-packages/statsforecast/core.py:25: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
" from tqdm.autonotebook import tqdm\n"
]
}
],
"source": [
"import os\n",
"\n",
"import pandas as pd\n",
"from nixtlats import TimeGPT"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "34496235-66f3-46a9-9565-b7924ea3c715",
"id": "64178d1c-957e-4a04-ab64-fde332b1840c",
"metadata": {},
"outputs": [],
"source": [
"timegpt = TimeGPT(token=os.environ['TIMEGPT_TOKEN'])"
"timegpt = TimeGPT(\n",
" # defaults to os.environ.get(\"TIMEGPT_TOKEN\")\n",
" token = 'my_token_provided_by_nixtla'\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5cd61549-0b00-4a42-a98e-239fa4fae5e5",
"metadata": {},
"outputs": [],
"source": [
"#| hide\n",
"timegpt = TimeGPT()"
]
},
{
Expand Down
106 changes: 65 additions & 41 deletions nbs/docs/tutorials/6_multiple_series.ipynb

Large diffs are not rendered by default.

36 changes: 29 additions & 7 deletions nbs/docs/tutorials/7_historical_forecast.ipynb

Large diffs are not rendered by default.

137 changes: 83 additions & 54 deletions nbs/docs/tutorials/8_irregular_timestamps.ipynb

Large diffs are not rendered by default.

31 changes: 26 additions & 5 deletions nbs/docs/tutorials/9_cross_validation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,43 @@
"execution_count": null,
"id": "77c6d3be-dd0c-4590-b59f-0b3495e00839",
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/home/ubuntu/miniconda/envs/nixtlats/lib/python3.11/site-packages/statsforecast/core.py:25: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
" from tqdm.autonotebook import tqdm\n"
]
}
],
"source": [
"import os\n",
"\n",
"import pandas as pd\n",
"from nixtlats import TimeGPT"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e5b91f74-f5f6-4d0c-8f5c-0c89502c23c8",
"id": "462c262f-172a-430e-9883-c6684a5c4760",
"metadata": {},
"outputs": [],
"source": [
"timegpt = TimeGPT(token=os.environ['TIMEGPT_TOKEN'])"
"timegpt = TimeGPT(\n",
" # defaults to os.environ.get(\"TIMEGPT_TOKEN\")\n",
" token = 'my_token_provided_by_nixtla'\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a505e6e4-61bd-4762-943b-c55e4e31c193",
"metadata": {},
"outputs": [],
"source": [
"#| hide\n",
"timegpt = TimeGPT()"
]
},
{
Expand Down
Loading
Loading