nixtla
nixtla copied to clipboard
500 error code from API call
User is reporting an ApiError: status_code: 500
ApiError Traceback (most recent call last)
Cell In[61], line 2
1 # detect anomalies
----> 2 anomalies_df = nixtla_client.detect_anomalies(
3 df,
4 time_col='planttimestring',
5 target_col='poa',
6 freq='D',
7 )
9 #plot anomalies
10 nixtla_client.plot(
11 df, anomalies_df,
12 time_col='planttimestring',
13 target_col='poa'
14 )
File ~\anaconda3\Lib\site-packages\nixtla\nixtla_client.py:1420, in NixtlaClient.detect_anomalies(self, df, freq, id_col, time_col, target_col, level, clean_ex_first, validate_api_key, date_features, date_features_to_one_hot, model, num_partitions)
1362 """Detect anomalies in your time series using TimeGPT.
1363
1364 Parameters
(...)
1417 DataFrame with anomalies flagged with 1 detected by TimeGPT.
1418 """
1419 if isinstance(df, pd.DataFrame):
-> 1420 return self._detect_anomalies(
1421 df=df,
1422 freq=freq,
1423 id_col=id_col,
1424 time_col=time_col,
1425 target_col=target_col,
1426 level=level,
1427 clean_ex_first=clean_ex_first,
1428 validate_api_key=validate_api_key,
1429 date_features=date_features,
1430 date_features_to_one_hot=date_features_to_one_hot,
1431 model=model,
1432 num_partitions=num_partitions,
1433 )
1434 else:
1435 dist_nixtla_client = self._instantiate_distributed_nixtla_client()
File ~\anaconda3\Lib\site-packages\nixtla\nixtla_client.py:730, in validate_model_parameter.<locals>.wrapper(self, *args, **kwargs)
725 if model not in self.supported_models:
726 raise ValueError(
727 f'unsupported model: {kwargs["model"]} '
728 f'supported models: {", ".join(self.supported_models)}'
729 )
--> 730 return func(self, *args, **kwargs)
File ~\anaconda3\Lib\site-packages\nixtla\nixtla_client.py:748, in partition_by_uid.<locals>.wrapper(self, num_partitions, **kwargs)
746 def wrapper(self, num_partitions, **kwargs):
747 if num_partitions is None or num_partitions == 1:
--> 748 return func(self, **kwargs, num_partitions=1)
749 df = kwargs.pop("df")
750 X_df = kwargs.pop("X_df", None)
File ~\anaconda3\Lib\site-packages\nixtla\nixtla_client.py:1021, in _NixtlaClient._detect_anomalies(self, df, freq, id_col, time_col, target_col, level, clean_ex_first, validate_api_key, date_features, date_features_to_one_hot, model, num_partitions)
1002 nixtla_client_model = _NixtlaClientModel(
1003 client=self.client,
1004 h=None,
(...)
1016 max_wait_time=self.max_wait_time,
1017 )
1018 df, X_df, uids_dtype = self._uids_to_categorical(
1019 df=df, X_df=None, id_col=id_col
1020 )
-> 1021 anomalies_df = nixtla_client_model.detect_anomalies(df=df)
1022 anomalies_df = self._restore_uids(anomalies_df, dtype=uids_dtype, id_col=id_col)
1023 self.weights_x = nixtla_client_model.weights_x
File ~\anaconda3\Lib\site-packages\nixtla\nixtla_client.py:634, in _NixtlaClientModel.detect_anomalies(self, df)
632 main_logger.info("Calling Anomaly Detector Endpoint...")
633 y, x = self.dataframes_to_dict(Y_df, X_df)
--> 634 response_timegpt = self._call_api(
635 self.client.anomaly_detection_multi_series,
636 MultiSeriesAnomaly(
637 y=y,
638 x=x,
639 freq=self.freq,
640 level=(
641 [self.level]
642 if (isinstance(self.level, int) or isinstance(self.level, float))
643 else [self.level[0]]
644 ),
645 clean_ex_first=self.clean_ex_first,
646 model=self.model,
647 ),
648 )
649 if "weights_x" in response_timegpt:
650 self.weights_x = pd.DataFrame(
651 {
652 "features": x_cols,
653 "weights": response_timegpt["weights_x"],
654 }
655 )
File ~\anaconda3\Lib\site-packages\nixtla\nixtla_client.py:229, in _NixtlaClientModel._call_api(self, method, request)
228 def _call_api(self, method, request):
--> 229 response = self._retry_strategy()(method)(request=request)
230 if "data" in response:
231 response = response["data"]
File ~\anaconda3\Lib\site-packages\tenacity\__init__.py:289, in BaseRetrying.wraps.<locals>.wrapped_f(*args, **kw)
287 @functools.wraps(f)
288 def wrapped_f(*args: t.Any, **kw: t.Any) -> t.Any:
--> 289 return self(f, *args, **kw)
File ~\anaconda3\Lib\site-packages\tenacity\__init__.py:379, in Retrying.__call__(self, fn, *args, **kwargs)
377 retry_state = RetryCallState(retry_object=self, fn=fn, args=args, kwargs=kwargs)
378 while True:
--> 379 do = self.iter(retry_state=retry_state)
380 if isinstance(do, DoAttempt):
381 try:
File ~\anaconda3\Lib\site-packages\tenacity\__init__.py:314, in BaseRetrying.iter(self, retry_state)
312 is_explicit_retry = fut.failed and isinstance(fut.exception(), TryAgain)
313 if not (is_explicit_retry or self.retry(retry_state)):
--> 314 return fut.result()
316 if self.after is not None:
317 self.after(retry_state)
File ~\anaconda3\Lib\concurrent\futures\_base.py:449, in Future.result(self, timeout)
447 raise CancelledError()
448 elif self._state == FINISHED:
--> 449 return self.__get_result()
451 self._condition.wait(timeout)
453 if self._state in [CANCELLED, CANCELLED_AND_NOTIFIED]:
File ~\anaconda3\Lib\concurrent\futures\_base.py:401, in Future.__get_result(self)
399 if self._exception:
400 try:
--> 401 raise self._exception
402 finally:
403 # Break a reference cycle with the exception in self._exception
404 self = None
File ~\anaconda3\Lib\site-packages\tenacity\__init__.py:382, in Retrying.__call__(self, fn, *args, **kwargs)
380 if isinstance(do, DoAttempt):
381 try:
--> 382 result = fn(*args, **kwargs)
383 except BaseException: # noqa: B902
384 retry_state.set_exception(sys.exc_info()) # type: ignore[arg-type]
File ~\anaconda3\Lib\site-packages\nixtla\client.py:1094, in Nixtla.anomaly_detection_multi_series(self, request, request_options)
1092 except JSONDecodeError:
1093 raise ApiError(status_code=_response.status_code, body=_response.text)
-> 1094 raise ApiError(status_code=_response.status_code, body=_response_json)
ApiError: status_code: 500, body: {'status': 500, 'data': {'detail': 'Internal server error, Please contact us at [[email protected]](mailto:[email protected]) or Azul'}, 'message': 'error', 'details': 'request had an error', 'code': 'B10', 'support': 'If you have questions or need support, please email [[email protected]](mailto:[email protected])', 'requestID': '', 'headers': {}}
[ ]:
Do we have the requestID? That'd help us get more logs
@tracykteal @jmoralez Is this still open / relevant?
This is now resolved, and we're now working through the web team's workflow for investigating 500 errors. So I'll close this.