def create_variable_and_return_progress()

in common/helpers/common_helpers.py [0:0]


def create_variable_and_return_progress(frauddetector_client, model, progress):
    try:
        if hasattr(model, "Tags"):
            tags = model_helpers.get_tags_from_tag_models(model.Tags)
        else:
            tags = None
        api_helpers.call_create_variable(
            frauddetector_client,
            variable_name=model.Name,
            variable_tags=tags,
            variable_data_type=model.DataType,
            variable_data_source=model.DataSource,
            variable_default_value=model.DefaultValue,
            variable_type=model.VariableType,
            variable_description=model.Description,
        )
        progress.resourceModel = model_helpers.get_variables_and_return_model_for_variable(
            frauddetector_client, model.Name
        )
        progress.status = OperationStatus.SUCCESS
        LOG.info(f"just finished a create variable call: {progress.resourceModel}")
    except RuntimeError as e:
        progress.status = OperationStatus.FAILED
        raise exceptions.InternalFailure(f"Error occurred: {e}")
    return progress