Closed zhongguojunhun1 closed 1 week ago
Hi @zhongguojunhun1 please keep in mind that your token is private, so be mindful of that when sharing screenshoots that show part of it. I recommend using an environment variable for your token. You can learn how to use one here.
Now, regarding your issue, can you share what the error is? Since the image is cropped, I can't see what it says at the end. Additionally, please make sure you have TimeGPT credits or a valid payment method. The validate_token
method makes an API call, so you need to have credits to do so. You can check this in your dashboard.
Hi,dear developer, I have $1000 credits in my account, as shown in Figure 1 of the zip package. The full information about the connection error problem I encountered is shown in Figure 2-Figure 9. However, when I submit data using the officially recommended request method, I can receive a return from TimeGPT, as shown in Figure 10.Thank you for helping me with my questions.
------------------ 原始邮件 ------------------ 发件人: "Nixtla/nixtla" @.>; 发送时间: 2024年3月6日(星期三) 上午7:36 @.>; @.**@.>; 主题: Re: [Nixtla/nixtla] Connect error (Issue #230)
Hi @zhongguojunhun1 please keep in mind that your token is private, so be mindful of that when sharing screenshoots that show part of it. I recommend using an environment variable for your token. You can learn how to use one here.
Now, regarding your issue, can you share what the error is? Since the image is cropped, I can't see what it says at the end. Additionally, please make sure you have TimeGPT credits or a valid payment method. The validate_token method makes an API call, so you need to have credits to do so. You can check this in your dashboard.
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>
sorry, what zip package? Here I can see that you sent something at 7:36 AM, but I'm not sure to where or whom.
sorry, what zip package? Here I can see that you sent something at 7:36 AM, but I'm not sure to where or whom.
Hi,I re-uploaded the screenshot of the connect error problem, please help me analyze it.
Hi @zhongguojunhun1, thanks for sharing the screenshots here on GitHub. I see now that you're trying to make an API request. Is there a specific reason you're not using nixtlats? The idea behind nixtlats is to avoid making direct API requests. Instead, you can simply instantiate the TimeGPT class and then call the forecast method.
Hi @zhongguojunhun1, thanks for sharing the screenshots here on GitHub. I see now that you're trying to make an API request. Is there a specific reason you're not using nixtlats? The idea behind nixtlats is to avoid making direct API requests. Instead, you can simply instantiate the TimeGPT class and then call the forecast method.
Hi, dear developer! I instantiated a TimeGPT class as you suggested and called the forecast method, but I still encountered connect error. The program error message is as follows:
ConnectError Traceback (most recent call last) D:\anaconda3\lib\site-packages\httpx_transports\default.py in map_httpcore_exceptions() 68 try: ---> 69 yield 70 except Exception as exc:
D:\anaconda3\lib\site-packages\httpx_transports\default.py in handle_request(self, request) 232 with map_httpcore_exceptions(): --> 233 resp = self._pool.handle_request(req) 234
D:\anaconda3\lib\site-packages\httpcore_sync\connection_pool.py in handle_request(self, request) 215 self._close_connections(closing) --> 216 raise exc from None 217
D:\anaconda3\lib\site-packages\httpcore_sync\connection_pool.py in handle_request(self, request) 195 # Send the request on the assigned connection. --> 196 response = connection.handle_request( 197 pool_request.request
D:\anaconda3\lib\site-packages\httpcore_sync\http_proxy.py in handle_request(self, request) 288 ) --> 289 connect_response = self._connection.handle_request( 290 connect_request
D:\anaconda3\lib\site-packages\httpcore_sync\connection.py in handle_request(self, request) 98 self._connect_failed = True ---> 99 raise exc 100
D:\anaconda3\lib\site-packages\httpcore_sync\connection.py in handle_request(self, request) 75 if self._connection is None: ---> 76 stream = self._connect(request) 77
D:\anaconda3\lib\site-packages\httpcore_sync\connection.py in _connect(self, request) 153 with Trace("start_tls", logger, request, kwargs) as trace: --> 154 stream = stream.start_tls(**kwargs) 155 trace.return_value = stream
D:\anaconda3\lib\site-packages\httpcore_backends\sync.py in start_tls(self, ssl_context, server_hostname, timeout) 167 self.close() --> 168 raise exc 169 return SyncStream(sock)
D:\anaconda3\lib\contextlib.py in exit(self, type, value, traceback) 130 try: --> 131 self.gen.throw(type, value, traceback) 132 except StopIteration as exc:
D:\anaconda3\lib\site-packages\httpcore_exceptions.py in map_exceptions(map) 13 if isinstance(exc, from_exc): ---> 14 raise to_exc(exc) from exc 15 raise # pragma: nocover
ConnectError: [Errno 0] Error
The above exception was the direct cause of the following exception:
ConnectError Traceback (most recent call last)
Ok, now that you're using nixtlats
it should be easier to make it work. It looks to me that the error is in how the token is being loaded, so just this time load it directly to the TimeGPT class. Here's how:
from nixtlats import TimeGPT
import os
import pandas as pd
timegpt = TimeGPT(token = 'your token')
df = pd.read_csv('https://raw.githubusercontent.com/Nixtla/transfer-learning-time-series/main/datasets/electricity-short.csv')
fcst_df = timegpt.forecast(df, h=24, level=[80,90])
fcst_df.head()
This should work since you have enough credits in your dashboard. If that works, then please follow this guide to see how to properly secure your token.
You can also use the validate_token
method from the TimeGPT class. Simply call timegpt.validate_token()
after you instantiate the TimeGPT class. This should return True
given that you have credits in your dashboard and assuming the token was copied correctly from there.
Ok, now that you're using
nixtlats
it should be easier to make it work. It looks to me that the error is in how the token is being loaded, so just this time load it directly to the TimeGPT class. Here's how:from nixtlats import TimeGPT import os import pandas as pd timegpt = TimeGPT(token = 'your token') df = pd.read_csv('https://raw.githubusercontent.com/Nixtla/transfer-learning-time-series/main/datasets/electricity-short.csv') fcst_df = timegpt.forecast(df, h=24, level=[80,90]) fcst_df.head()
This should work since you have enough credits in your dashboard. If that works, then please follow this guide to see how to properly secure your token.
You can also use the
validate_token
method from the TimeGPT class. Simply calltimegpt.validate_token()
after you instantiate the TimeGPT class. This should returnTrue
given that you have credits in your dashboard and assuming the token was copied correctly from there.
Hi, dear developer!
I re-initialized the TimeGPT class using the method you provided, but calling the forecast method still encountered connect error. But I can draw the graph by calling the plot method. The operating system I use is windows 10, I would like to know whether it is related to the operating system, or the reason for the poor network.
@zhongguojunhun1 Do you still experience issues?
having the same issue. Any suggestsion? Did you resolved it @zhongguojunhun1 ?
from dotenv import load_dotenv load_dotenv('../../.env') NIXTLA_API_KEY = os.getenv('NIXTLA_API_KEY')
from nixtla import NixtlaClient
if NIXTLA_API_KEY is not None: from nixtla import NixtlaClient nixtla_client = NixtlaClient(api_key=NIXTLA_API_KEY) print("Nixtla client successfully initialized.") else: print("Failed to load NIXTLA_API_KEY from the environment variables.") Nixtla client successfully initialized.
nixtla_client.validate_api_key() False
timegpt_fcst_df = nixtla_client.forecast(df=df, h=12, freq='MS', time_col='timestamp', target_col='value')
ConnectError Traceback (most recent call last) File c:\Users\Anna.Androvitsanea\AppData\Local\Programs\Python\Python310\lib\site-packages\httpx_transports\default.py:69, in map_httpcore_exceptions() 68 try: ---> 69 yield 70 except Exception as exc:
File c:\Users\Anna.Androvitsanea\AppData\Local\Programs\Python\Python310\lib\site-packages\httpx_transports\default.py:233, in HTTPTransport.handle_request(self, request) 232 with map_httpcore_exceptions(): --> 233 resp = self._pool.handle_request(req) 235 assert isinstance(resp.stream, typing.Iterable)
File c:\Users\Anna.Androvitsanea\AppData\Local\Programs\Python\Python310\lib\site-packages\httpcore_sync\connection_pool.py:216, in ConnectionPool.handle_request(self, request) 215 self._close_connections(closing) --> 216 raise exc from None 218 # Return the response. Note that in this case we still have to manage 219 # the point at which the response is closed.
File c:\Users\Anna.Androvitsanea\AppData\Local\Programs\Python\Python310\lib\site-packages\httpcore_sync\connection_pool.py:196, in ConnectionPool.handle_request(self, request) 194 try: 195 # Send the request on the assigned connection. --> 196 response = connection.handle_request( 197 pool_request.request 198 ) 199 except ConnectionNotAvailable: ... 83 raise 85 message = str(exc) ---> 86 raise mapped_exc(message) from exc
ConnectError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:997) Output is truncated. View as a scrollable element or open in a text editor. Adjust cell output settings...
This issue has been automatically closed because it has been awaiting a response for too long. When you have time to to work with the maintainers to resolve this issue, please post a new comment and it will be re-opened. If the issue has been locked for editing by the time you return to it, please open a new issue and reference this one.
First of all, thank you for giving me the permission to experience TimeGPT. I installed nixtlats version 0.19.0 and successfully generated the key, but when I used timegpt.validate_token() to verify the key, ConnectError was displayed. What can I do?![problem](https://github.com/Nixtla/nixtla/assets/154397195/b2db1681-062f-4576-8625-0ff3f31f76c5)