Skip to content

Commit

Permalink
🌿 Fern Regeneration -- April 6, 2024 (#287)
Browse files Browse the repository at this point in the history
Co-authored-by: fern-api <115122769+fern-api[bot]@users.noreply.github.com>
  • Loading branch information
fern-api[bot] authored Apr 8, 2024
1 parent 9f41eba commit 7a3e52a
Show file tree
Hide file tree
Showing 19 changed files with 144 additions and 84 deletions.
36 changes: 36 additions & 0 deletions nixtlats/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,24 @@ def validate_token_front(self) -> typing.Any:
raise ApiError(status_code=_response.status_code, body=_response.text)
raise ApiError(status_code=_response.status_code, body=_response_json)

def health_health_get(self) -> typing.Any:
"""
Check if server is healthy. Used by the readiness probe to check server is healthy.
"""
_response = self._client_wrapper.httpx_client.request(
"GET",
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "health"),
headers=self._client_wrapper.get_headers(),
timeout=60,
)
if 200 <= _response.status_code < 300:
return pydantic.parse_obj_as(typing.Any, _response.json()) # type: ignore
try:
_response_json = _response.json()
except JSONDecodeError:
raise ApiError(status_code=_response.status_code, body=_response.text)
raise ApiError(status_code=_response.status_code, body=_response_json)

def forecast(self, *, request: SingleSeriesForecast) -> typing.Any:
"""
This endpoint predicts the future values of a single time series based on the provided data. It takes a JSON as an input containing information like the series frequency and historical data. (See below for a full description of the parameters.) The response contains the predicted values based on the input arguments. Get your token for private beta at https://dashboard.nixtla.io
Expand Down Expand Up @@ -476,6 +494,24 @@ async def validate_token_front(self) -> typing.Any:
raise ApiError(status_code=_response.status_code, body=_response.text)
raise ApiError(status_code=_response.status_code, body=_response_json)

async def health_health_get(self) -> typing.Any:
"""
Check if server is healthy. Used by the readiness probe to check server is healthy.
"""
_response = await self._client_wrapper.httpx_client.request(
"GET",
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "health"),
headers=self._client_wrapper.get_headers(),
timeout=60,
)
if 200 <= _response.status_code < 300:
return pydantic.parse_obj_as(typing.Any, _response.json()) # type: ignore
try:
_response_json = _response.json()
except JSONDecodeError:
raise ApiError(status_code=_response.status_code, body=_response.text)
raise ApiError(status_code=_response.status_code, body=_response_json)

async def forecast(self, *, request: SingleSeriesForecast) -> typing.Any:
"""
This endpoint predicts the future values of a single time series based on the provided data. It takes a JSON as an input containing information like the series frequency and historical data. (See below for a full description of the parameters.) The response contains the predicted values based on the input arguments. Get your token for private beta at https://dashboard.nixtla.io
Expand Down
2 changes: 1 addition & 1 deletion nixtlats/types/multi_series_anomaly.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

class MultiSeriesAnomaly(pydantic.BaseModel):
model: typing.Optional[MultiSeriesAnomalyModel] = pydantic.Field(
description="Model to use as a string. Options are: `short-horizon`, and `long-horizon.` We recommend using `long-horizon` for forecasting if you want to predict more than one seasonal period given the frequency of your data."
description="Model to use as a string. Options are: `timegpt-1`, and `timegpt-1-long-horizon.` We recommend using `timegpt-1-long-horizon` for forecasting if you want to predict more than one seasonal period given the frequency of your data."
)
freq: typing.Optional[str] = pydantic.Field(
description="The frequency of the data represented as a string. 'D' for daily, 'M' for monthly, 'H' for hourly, and 'W' for weekly frequencies are available."
Expand Down
22 changes: 13 additions & 9 deletions nixtlats/types/multi_series_anomaly_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,30 @@

class MultiSeriesAnomalyModel(str, enum.Enum):
"""
Model to use as a string. Options are: `short-horizon`, and `long-horizon.` We recommend using `long-horizon` for forecasting if you want to predict more than one seasonal period given the frequency of your data.
Model to use as a string. Options are: `timegpt-1`, and `timegpt-1-long-horizon.` We recommend using `timegpt-1-long-horizon` for forecasting if you want to predict more than one seasonal period given the frequency of your data.
"""

SHORT_HORIZON = "short-horizon"
LONG_HORIZON = "long-horizon"
TIMEGPT_1 = "timegpt-1"
TIMEGPT_1_LONG_HORIZON = "timegpt-1-long-horizon"
SHORT_HORIZON = "short-horizon"
LONG_HORIZON = "long-horizon"
AZUREAI = "azureai"

def visit(
self,
short_horizon: typing.Callable[[], T_Result],
long_horizon: typing.Callable[[], T_Result],
timegpt_1: typing.Callable[[], T_Result],
timegpt_1_long_horizon: typing.Callable[[], T_Result],
short_horizon: typing.Callable[[], T_Result],
long_horizon: typing.Callable[[], T_Result],
azureai: typing.Callable[[], T_Result],
) -> T_Result:
if self is MultiSeriesAnomalyModel.SHORT_HORIZON:
return short_horizon()
if self is MultiSeriesAnomalyModel.LONG_HORIZON:
return long_horizon()
if self is MultiSeriesAnomalyModel.TIMEGPT_1:
return timegpt_1()
if self is MultiSeriesAnomalyModel.TIMEGPT_1_LONG_HORIZON:
return timegpt_1_long_horizon()
if self is MultiSeriesAnomalyModel.SHORT_HORIZON:
return short_horizon()
if self is MultiSeriesAnomalyModel.LONG_HORIZON:
return long_horizon()
if self is MultiSeriesAnomalyModel.AZUREAI:
return azureai()
14 changes: 7 additions & 7 deletions nixtlats/types/multi_series_cross_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@


class MultiSeriesCrossValidation(pydantic.BaseModel):
fewshot_steps: typing.Optional[int] = pydantic.Field(description="Deprecated. Please use finetune_steps instead.")
fewshot_loss: typing.Optional[MultiSeriesCrossValidationFewshotLoss] = pydantic.Field(
description="Deprecated. Please use finetune_loss instead."
)
model: typing.Optional[MultiSeriesCrossValidationModel] = pydantic.Field(
description="Model to use as a string. Options are: `short-horizon`, and `long-horizon.` We recommend using `long-horizon` for forecasting if you want to predict more than one seasonal period given the frequency of your data."
description="Model to use as a string. Options are: `timegpt-1`, and `timegpt-1-long-horizon.` We recommend using `timegpt-1-long-horizon` for forecasting if you want to predict more than one seasonal period given the frequency of your data."
)
freq: typing.Optional[str] = pydantic.Field(
description="The frequency of the data represented as a string. 'D' for daily, 'M' for monthly, 'H' for hourly, and 'W' for weekly frequencies are available."
Expand All @@ -36,15 +40,11 @@ class MultiSeriesCrossValidation(pydantic.BaseModel):
clean_ex_first: typing.Optional[bool] = pydantic.Field(
description="A boolean flag that indicates whether the API should preprocess (clean) the exogenous signal before applying the large time model. If True, the exogenous signal is cleaned; if False, the exogenous variables are applied after the large time model."
)
fewshot_steps: typing.Optional[int] = pydantic.Field(
finetune_steps: typing.Optional[int] = pydantic.Field(
description="The number of tuning steps used to train the large time model on the data. Set this value to 0 for zero-shot inference, i.e., to make predictions without any further model tuning."
)
fewshot_loss: typing.Optional[MultiSeriesCrossValidationFewshotLoss] = pydantic.Field(
description="The loss used to train the large time model on the data. Select from ['default', 'mae', 'mse', 'rmse', 'mape', 'smape']. It will only be used if finetune_steps larger than 0. Default is a robust loss function that is less sensitive to outliers."
)
finetune_steps: typing.Optional[int] = pydantic.Field(description="Deprecated. Please use fewshot_steps instead.")
finetune_loss: typing.Optional[MultiSeriesCrossValidationFinetuneLoss] = pydantic.Field(
description="Deprecated. Please use fewshot_loss instead."
description="The loss used to train the large time model on the data. Select from ['default', 'mae', 'mse', 'rmse', 'mape', 'smape']. It will only be used if finetune_steps larger than 0. Default is a robust loss function that is less sensitive to outliers."
)

def json(self, **kwargs: typing.Any) -> str:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class MultiSeriesCrossValidationFewshotLoss(str, enum.Enum):
"""
The loss used to train the large time model on the data. Select from ['default', 'mae', 'mse', 'rmse', 'mape', 'smape']. It will only be used if finetune_steps larger than 0. Default is a robust loss function that is less sensitive to outliers.
Deprecated. Please use finetune_loss instead.
"""

DEFAULT = "default"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class MultiSeriesCrossValidationFinetuneLoss(str, enum.Enum):
"""
Deprecated. Please use fewshot_loss instead.
The loss used to train the large time model on the data. Select from ['default', 'mae', 'mse', 'rmse', 'mape', 'smape']. It will only be used if finetune_steps larger than 0. Default is a robust loss function that is less sensitive to outliers.
"""

DEFAULT = "default"
Expand Down
22 changes: 13 additions & 9 deletions nixtlats/types/multi_series_cross_validation_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,30 @@

class MultiSeriesCrossValidationModel(str, enum.Enum):
"""
Model to use as a string. Options are: `short-horizon`, and `long-horizon.` We recommend using `long-horizon` for forecasting if you want to predict more than one seasonal period given the frequency of your data.
Model to use as a string. Options are: `timegpt-1`, and `timegpt-1-long-horizon.` We recommend using `timegpt-1-long-horizon` for forecasting if you want to predict more than one seasonal period given the frequency of your data.
"""

SHORT_HORIZON = "short-horizon"
LONG_HORIZON = "long-horizon"
TIMEGPT_1 = "timegpt-1"
TIMEGPT_1_LONG_HORIZON = "timegpt-1-long-horizon"
SHORT_HORIZON = "short-horizon"
LONG_HORIZON = "long-horizon"
AZUREAI = "azureai"

def visit(
self,
short_horizon: typing.Callable[[], T_Result],
long_horizon: typing.Callable[[], T_Result],
timegpt_1: typing.Callable[[], T_Result],
timegpt_1_long_horizon: typing.Callable[[], T_Result],
short_horizon: typing.Callable[[], T_Result],
long_horizon: typing.Callable[[], T_Result],
azureai: typing.Callable[[], T_Result],
) -> T_Result:
if self is MultiSeriesCrossValidationModel.SHORT_HORIZON:
return short_horizon()
if self is MultiSeriesCrossValidationModel.LONG_HORIZON:
return long_horizon()
if self is MultiSeriesCrossValidationModel.TIMEGPT_1:
return timegpt_1()
if self is MultiSeriesCrossValidationModel.TIMEGPT_1_LONG_HORIZON:
return timegpt_1_long_horizon()
if self is MultiSeriesCrossValidationModel.SHORT_HORIZON:
return short_horizon()
if self is MultiSeriesCrossValidationModel.LONG_HORIZON:
return long_horizon()
if self is MultiSeriesCrossValidationModel.AZUREAI:
return azureai()
14 changes: 7 additions & 7 deletions nixtlats/types/multi_series_forecast.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@


class MultiSeriesForecast(pydantic.BaseModel):
fewshot_steps: typing.Optional[int] = pydantic.Field(description="Deprecated. Please use finetune_steps instead.")
fewshot_loss: typing.Optional[MultiSeriesForecastFewshotLoss] = pydantic.Field(
description="Deprecated. Please use finetune_loss instead."
)
model: typing.Optional[MultiSeriesForecastModel] = pydantic.Field(
description="Model to use as a string. Options are: `short-horizon`, and `long-horizon.` We recommend using `long-horizon` for forecasting if you want to predict more than one seasonal period given the frequency of your data."
description="Model to use as a string. Options are: `timegpt-1`, and `timegpt-1-long-horizon.` We recommend using `timegpt-1-long-horizon` for forecasting if you want to predict more than one seasonal period given the frequency of your data."
)
freq: typing.Optional[str] = pydantic.Field(
description="The frequency of the data represented as a string. 'D' for daily, 'M' for monthly, 'H' for hourly, and 'W' for weekly frequencies are available."
Expand All @@ -32,15 +36,11 @@ class MultiSeriesForecast(pydantic.BaseModel):
clean_ex_first: typing.Optional[bool] = pydantic.Field(
description="A boolean flag that indicates whether the API should preprocess (clean) the exogenous signal before applying the large time model. If True, the exogenous signal is cleaned; if False, the exogenous variables are applied after the large time model."
)
fewshot_steps: typing.Optional[int] = pydantic.Field(
finetune_steps: typing.Optional[int] = pydantic.Field(
description="The number of tuning steps used to train the large time model on the data. Set this value to 0 for zero-shot inference, i.e., to make predictions without any further model tuning."
)
fewshot_loss: typing.Optional[MultiSeriesForecastFewshotLoss] = pydantic.Field(
description="The loss used to train the large time model on the data. Select from ['default', 'mae', 'mse', 'rmse', 'mape', 'smape']. It will only be used if finetune_steps larger than 0. Default is a robust loss function that is less sensitive to outliers."
)
finetune_steps: typing.Optional[int] = pydantic.Field(description="Deprecated. Please use fewshot_steps instead.")
finetune_loss: typing.Optional[MultiSeriesForecastFinetuneLoss] = pydantic.Field(
description="Deprecated. Please use fewshot_loss instead."
description="The loss used to train the large time model on the data. Select from ['default', 'mae', 'mse', 'rmse', 'mape', 'smape']. It will only be used if finetune_steps larger than 0. Default is a robust loss function that is less sensitive to outliers."
)

def json(self, **kwargs: typing.Any) -> str:
Expand Down
2 changes: 1 addition & 1 deletion nixtlats/types/multi_series_forecast_fewshot_loss.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class MultiSeriesForecastFewshotLoss(str, enum.Enum):
"""
The loss used to train the large time model on the data. Select from ['default', 'mae', 'mse', 'rmse', 'mape', 'smape']. It will only be used if finetune_steps larger than 0. Default is a robust loss function that is less sensitive to outliers.
Deprecated. Please use finetune_loss instead.
"""

DEFAULT = "default"
Expand Down
2 changes: 1 addition & 1 deletion nixtlats/types/multi_series_forecast_finetune_loss.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class MultiSeriesForecastFinetuneLoss(str, enum.Enum):
"""
Deprecated. Please use fewshot_loss instead.
The loss used to train the large time model on the data. Select from ['default', 'mae', 'mse', 'rmse', 'mape', 'smape']. It will only be used if finetune_steps larger than 0. Default is a robust loss function that is less sensitive to outliers.
"""

DEFAULT = "default"
Expand Down
22 changes: 13 additions & 9 deletions nixtlats/types/multi_series_forecast_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,30 @@

class MultiSeriesForecastModel(str, enum.Enum):
"""
Model to use as a string. Options are: `short-horizon`, and `long-horizon.` We recommend using `long-horizon` for forecasting if you want to predict more than one seasonal period given the frequency of your data.
Model to use as a string. Options are: `timegpt-1`, and `timegpt-1-long-horizon.` We recommend using `timegpt-1-long-horizon` for forecasting if you want to predict more than one seasonal period given the frequency of your data.
"""

SHORT_HORIZON = "short-horizon"
LONG_HORIZON = "long-horizon"
TIMEGPT_1 = "timegpt-1"
TIMEGPT_1_LONG_HORIZON = "timegpt-1-long-horizon"
SHORT_HORIZON = "short-horizon"
LONG_HORIZON = "long-horizon"
AZUREAI = "azureai"

def visit(
self,
short_horizon: typing.Callable[[], T_Result],
long_horizon: typing.Callable[[], T_Result],
timegpt_1: typing.Callable[[], T_Result],
timegpt_1_long_horizon: typing.Callable[[], T_Result],
short_horizon: typing.Callable[[], T_Result],
long_horizon: typing.Callable[[], T_Result],
azureai: typing.Callable[[], T_Result],
) -> T_Result:
if self is MultiSeriesForecastModel.SHORT_HORIZON:
return short_horizon()
if self is MultiSeriesForecastModel.LONG_HORIZON:
return long_horizon()
if self is MultiSeriesForecastModel.TIMEGPT_1:
return timegpt_1()
if self is MultiSeriesForecastModel.TIMEGPT_1_LONG_HORIZON:
return timegpt_1_long_horizon()
if self is MultiSeriesForecastModel.SHORT_HORIZON:
return short_horizon()
if self is MultiSeriesForecastModel.LONG_HORIZON:
return long_horizon()
if self is MultiSeriesForecastModel.AZUREAI:
return azureai()
2 changes: 1 addition & 1 deletion nixtlats/types/multi_series_insample_forecast.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

class MultiSeriesInsampleForecast(pydantic.BaseModel):
model: typing.Optional[MultiSeriesInsampleForecastModel] = pydantic.Field(
description="Model to use as a string. Options are: `short-horizon`, and `long-horizon.` We recommend using `long-horizon` for forecasting if you want to predict more than one seasonal period given the frequency of your data."
description="Model to use as a string. Options are: `timegpt-1`, and `timegpt-1-long-horizon.` We recommend using `timegpt-1-long-horizon` for forecasting if you want to predict more than one seasonal period given the frequency of your data."
)
freq: typing.Optional[str] = pydantic.Field(
description="The frequency of the data represented as a string. 'D' for daily, 'M' for monthly, 'H' for hourly, and 'W' for weekly frequencies are available."
Expand Down
22 changes: 13 additions & 9 deletions nixtlats/types/multi_series_insample_forecast_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,30 @@

class MultiSeriesInsampleForecastModel(str, enum.Enum):
"""
Model to use as a string. Options are: `short-horizon`, and `long-horizon.` We recommend using `long-horizon` for forecasting if you want to predict more than one seasonal period given the frequency of your data.
Model to use as a string. Options are: `timegpt-1`, and `timegpt-1-long-horizon.` We recommend using `timegpt-1-long-horizon` for forecasting if you want to predict more than one seasonal period given the frequency of your data.
"""

SHORT_HORIZON = "short-horizon"
LONG_HORIZON = "long-horizon"
TIMEGPT_1 = "timegpt-1"
TIMEGPT_1_LONG_HORIZON = "timegpt-1-long-horizon"
SHORT_HORIZON = "short-horizon"
LONG_HORIZON = "long-horizon"
AZUREAI = "azureai"

def visit(
self,
short_horizon: typing.Callable[[], T_Result],
long_horizon: typing.Callable[[], T_Result],
timegpt_1: typing.Callable[[], T_Result],
timegpt_1_long_horizon: typing.Callable[[], T_Result],
short_horizon: typing.Callable[[], T_Result],
long_horizon: typing.Callable[[], T_Result],
azureai: typing.Callable[[], T_Result],
) -> T_Result:
if self is MultiSeriesInsampleForecastModel.SHORT_HORIZON:
return short_horizon()
if self is MultiSeriesInsampleForecastModel.LONG_HORIZON:
return long_horizon()
if self is MultiSeriesInsampleForecastModel.TIMEGPT_1:
return timegpt_1()
if self is MultiSeriesInsampleForecastModel.TIMEGPT_1_LONG_HORIZON:
return timegpt_1_long_horizon()
if self is MultiSeriesInsampleForecastModel.SHORT_HORIZON:
return short_horizon()
if self is MultiSeriesInsampleForecastModel.LONG_HORIZON:
return long_horizon()
if self is MultiSeriesInsampleForecastModel.AZUREAI:
return azureai()
Loading

0 comments on commit 7a3e52a

Please sign in to comment.