Skip to content

create_what_if_forecast async

create_what_if_forecast(
    what_if_forecast_name: Name,
    what_if_analysis_arn: Arn,
    *,
    config_overrides: Optional[AsyncforecastClientConfig] = None,
    time_series_transformations: Optional[TimeSeriesTransformations] = None,
    time_series_replacements_data_source: Optional[
        TimeSeriesReplacementsDataSource
    ] = None,
    tags: Optional[Tags] = None,
) -> CreateWhatIfForecastResponse

A what-if forecast is a forecast that is created from a modified version of the baseline forecast. Each what-if forecast incorporates either a replacement dataset or a set of transformations to the original dataset.

Parameters:

  • what_if_forecast_name (Name) –

    The name of the what-if forecast. Names must be unique within each what-if analysis.

  • what_if_analysis_arn (Arn) –

    The Amazon Resource Name (ARN) of the what-if analysis.

  • time_series_transformations (Optional[TimeSeriesTransformations], default: None ) –

    The transformations that are applied to the baseline time series. Each transformation contains an action and a set of conditions. An action is applied only when all conditions are met. If no conditions are provided, the action is applied to all items.

  • time_series_replacements_data_source (Optional[TimeSeriesReplacementsDataSource], default: None ) –

    The replacement time series dataset, which contains the rows that you want to change in the related time series dataset. A replacement time series does not need to contain all rows that are in the baseline related time series. Include only the rows (measure-dimension combinations) that you want to include in the what-if forecast.

    This dataset is merged with the original time series to create a transformed dataset that is used for the what-if analysis.

    This dataset should contain the items to modify (such as item_id or workforce_type), any relevant dimensions, the timestamp column, and at least one of the related time series columns. This file should not contain duplicate timestamps for the same time series.

    Timestamps and item_ids not included in this dataset are not included in the what-if analysis.

  • tags (Optional[Tags], default: None ) –

    A list of tags to apply to the what if forecast.

Raises:

Source code in docs_src/capo_forecast/_services/async_forecast.py
async def create_what_if_forecast(
    self,
    what_if_forecast_name: "capo_forecast.types.name.Name",
    what_if_analysis_arn: "capo_forecast.types.arn.Arn",
    *,
    config_overrides: Optional[AsyncforecastClientConfig] = None,
    time_series_transformations: Optional[
        "capo_forecast.types.time_series_transformations.TimeSeriesTransformations"
    ] = None,
    time_series_replacements_data_source: Optional[
        "capo_forecast.types.time_series_replacements_data_source.TimeSeriesReplacementsDataSource"
    ] = None,
    tags: Optional["capo_forecast.types.tags.Tags"] = None,
) -> "capo_forecast.types.create_what_if_forecast_response.CreateWhatIfForecastResponse":
    """<p>A what-if forecast is a forecast that is created from a modified version of the baseline forecast. Each what-if forecast incorporates either a replacement dataset or a set of transformations to the original dataset. </p>

    Args:
        what_if_forecast_name: <p>The name of the what-if forecast. Names must be unique within each what-if analysis.</p>
        what_if_analysis_arn: <p>The Amazon Resource Name (ARN) of the what-if analysis.</p>
        time_series_transformations: <p>The transformations that are applied to the baseline time series. Each transformation contains an action and a set of conditions. An action is applied only when all conditions are met. If no conditions are provided, the action is applied to all items.</p>
        time_series_replacements_data_source: <p>The replacement time series dataset, which contains the rows that you want to change in the related time series dataset. A replacement time series does not need to contain all rows that are in the baseline related time series. Include only the rows (measure-dimension combinations) that you want to include in the what-if forecast.</p> <p>This dataset is merged with the original time series to create a transformed dataset that is used for the what-if analysis.</p> <p>This dataset should contain the items to modify (such as item_id or workforce_type), any relevant dimensions, the timestamp column, and at least one of the related time series columns. This file should not contain duplicate timestamps for the same time series.</p> <p>Timestamps and item_ids not included in this dataset are not included in the what-if analysis. </p>
        tags: <p>A list of <a href="https://docs.aws.amazon.com/forecast/latest/dg/tagging-forecast-resources.html">tags</a> to apply to the what if forecast.</p>

    Raises:
        capo_forecast.errors.invalid_input_exception.InvalidInputException: <p>We can't process the request because it includes an invalid value or a value that exceeds the valid range.</p>
        capo_forecast.errors.limit_exceeded_exception.LimitExceededException: <p>The limit on the number of resources per account has been exceeded.</p>
        capo_forecast.errors.resource_already_exists_exception.ResourceAlreadyExistsException: <p>There is already a resource with this name. Try again with a different name.</p>
        capo_forecast.errors.resource_in_use_exception.ResourceInUseException: <p>The specified resource is in use.</p>
        capo_forecast.errors.resource_not_found_exception.ResourceNotFoundException: <p>We can't find a resource with that Amazon Resource Name (ARN). Check the ARN and try again.</p>
        capo_forecast.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_forecast.types.create_what_if_forecast_request.CreateWhatIfForecastRequest]",
    ) -> AsyncOperationResponse[
        "capo_forecast.types.create_what_if_forecast_response.CreateWhatIfForecastResponse"
    ]:
        import capo_forecast._operations.amazon_forecast.create_what_if_forecast

        (
            output,
            http_response,
        ) = await capo_forecast._operations.amazon_forecast.create_what_if_forecast.async_create_what_if_forecast(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_forecast.types.create_what_if_forecast_request.CreateWhatIfForecastRequest",
    ) -> dict[str, Any]:
        import capo_forecast.types.create_what_if_forecast_request

        return capo_forecast.types.create_what_if_forecast_request.redact_sensitive(
            input_
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("CreateWhatIfForecast", redact_input=_redact_input),
    )
    input_: capo_forecast.types.create_what_if_forecast_request.CreateWhatIfForecastRequest = {
        "what_if_forecast_name": what_if_forecast_name,
        "what_if_analysis_arn": what_if_analysis_arn,
    }
    if time_series_transformations is not None:
        input_["time_series_transformations"] = time_series_transformations
    if time_series_replacements_data_source is not None:
        input_["time_series_replacements_data_source"] = (
            time_series_replacements_data_source
        )
    if tags is not None:
        input_["tags"] = tags

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output