in source/forecast-shared/shared/Forecast/forecast.py [0:0]
def status(self) -> Status:
"""
Get the status of this forecast as defined. The status might be DOES_NOT_EXSIST if a forecast of the desired
format does not yet exist.
:return: Status
"""
past_forecasts = self.history()
# check if a forecast has been created:
if not past_forecasts:
logger.debug("No past forecasts found")
return Status.DOES_NOT_EXIST
past_status = self.cli.describe_forecast(
ForecastArn=past_forecasts[0].get("ForecastArn")
)
# if the past forecast was generated with a different predictor, regenerate
if past_status.get("PredictorArn") != self._predictor_arn:
logger.debug(
"Most recent forecast was generated with a different predictor, a new forecast should be created"
)
return Status.DOES_NOT_EXIST
# if the datasets in the datasetgroup have changed after the previous forecast
# was generated, regenerate the forecast.
for dataset in self._dataset_group.datasets:
if dataset.get("LastModificationTime") > past_status.get("CreationTime"):
logger.debug(
"Datasets have changed since last forecast generation, a new forecast should be created "
)
return Status.DOES_NOT_EXIST
self.set_user_tags(resource_arn=past_forecasts[0].get("ForecastArn"))
return Status[past_status.get("Status")]