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

Feat/new faqs #250

Merged
merged 8 commits into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
10 changes: 9 additions & 1 deletion nbs/docs/getting-started/1_getting_started_short.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@
"id": "8e7cea32-ade9-4b23-be93-9a4fbea7c6b2",
Copy link
Member

@mergenthaler mergenthaler Mar 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I personally prefer to me more concise. E.g. instead of

"You can test the validity of your token calling the validate_token method"

you can simply write:

Check your token status with the validate_token method.


Reply via ReviewNB

"metadata": {},
"source": [
"You can test the validate of your token calling the `validate_token` method:"
"You can test the validity of your token calling the `validate_token` method:"
]
},
{
Expand Down Expand Up @@ -198,6 +198,14 @@
"timegpt.validate_token()"
]
},
{
"cell_type": "markdown",
"id": "a2597400",
"metadata": {},
"source": [
"To learn more about how to set up your token, please refer to the [Setting Up your Authentication Token](https://nixtlaverse.nixtla.io/nixtla/docs/getting-started/setting_up_your_authentication_token.html) tutorial. "
]
},
{
"cell_type": "markdown",
"id": "8ca0d1f7-9730-4146-b6f3-596099ce6e3b",
Expand Down
224 changes: 224 additions & 0 deletions nbs/docs/getting-started/2_setting_up_your_authentication_token.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,224 @@
{
Copy link
Member

@mergenthaler mergenthaler Mar 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There might be confusion with tokens as in input tokens and tokens as in API Key. Maybe:

A token (aka as API Key )is a unique string of characters that serves as a key to authenticate your requests to TimeGTP. This tutorial will explain how to set up your token when using the Nixtla SDK.


Reply via ReviewNB

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, I also think that can be confusing, so I added the distinction.

"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Setting Up Your Authentication Token "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"A **token** is a unique string of characters that serves as a key to authenticate your requests to `TimeGTP`. This tutorial will explain how to set up your token when using the Nixtla SDK. \n",
"\n",
"Upon [registration](https://dashboard.nixtla.io/), you will recibe an email asking you to confirm your signup. After confirming, you will receive access to your dashboard. There, under `API Keys`, you will find your token. To integrate your token into your development workflow with the Nixtla SDK, you have two methods. "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 1. Direct copy and paste \n",
"\n",
"- **Step 1**: Copy the token found in the `API Keys` of your [dashboard]((https://dashboard.nixtla.io/)). \n",
"- **Step 2**: Instantiate the `TimeGPT` class by directly pasting your token into the code, as shown below:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from nixtlats import TimeGPT \n",
"timegpt = TimeGPT(token = 'your token here')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This approach is straightforward and best for quick tests or scripts that won’t be shared."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 2. Using an environment variable"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"- **Step 1:** Store your token in an environment variable named `TIMEGPT_TOKEN`. This can be done for a session or permanently, depending on your preference.\n",
"- **Step 2:** When you instantiate the `TimeGPT` class, the SDK will automatically look for the `TIMEGPT_TOKEN` environment variable and use it to authenticate your requests."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": null,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"#| hide\n",
"from dotenv import load_dotenv\n",
"load_dotenv()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from nixtlats import TimeGPT\n",
"timegpt = TimeGPT()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"::: {.callout-important}\n",
"The environment variable must be named exactly `TIMEGPT_TOKEN`, with all capital letters and no deviations in spelling, for the SDK to recognize it.\n",
"::: "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"There are several ways to set an environment variable. "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### a. From the Terminal\n",
"Use the `export` command to set `TIMEGPT_TOKEN`. \n",
"\n",
"``` bash\n",
"export TIMEGPT_TOKEN=your_token\n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### b. Using a `.env` file\n",
"\n",
"For a more persistent solution that can be version-controlled if private, or for ease of use across different projects, place your token in a `.env` file.\n",
"\n",
"``` bash\n",
"# Inside a file named .env\n",
"TIMEGPT_TOKEN=your_token\n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**Within Python:** If using a `.env` file, you can load the environment variable within your Python script. Use the `dotenv` package to load the `.env` file and then instantiate the `TimeGPT` class."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from dotenv import load_dotenv\n",
"load_dotenv()\n",
"\n",
"from nixtlats import TimeGPT\n",
"timegpt = TimeGPT()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This approach is more secure and suitable for applications that will be deployed or shared, as it keeps tokens out of the source code."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"::: {.callout-important}\n",
"Remember, your token is like a password - keep it secret, keep it safe!\n",
"::: "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Validate your token\n",
"\n",
"As explained before, you can find your token in the `API Keys` section of your [dashboard]((https://dashboard.nixtla.io/)). If you want to ensure its validity, you can use the [`validate_token` method](https://nixtlaverse.nixtla.io/nixtla/timegpt.html#timegpt-validate-token) of the `TimeGPT` class. This method will return `True` if the token is valid and `False` otherwise. "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:nixtlats.timegpt:Happy Forecasting! :), If you have questions or need support, please email [email protected]\n"
]
},
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": null,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"timegpt.validate_token()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You don't need to validate your token every time you use `TimeGPT`. This function is provided for your convenience to ensure its validity. For full access to `TimeGPT`'s functionalities, in addition to a valid token, you also need sufficient credits in your account. You can check your credits in the `Usage` section of your [dashboard]((https://dashboard.nixtla.io/)). "
]
}
],
"metadata": {
"kernelspec": {
"display_name": "python3",
"language": "python",
"name": "python3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Loading
Loading