def validate_use_ci()

in google_cloud_automlops/utils/utils.py [0:0]


def validate_use_ci(deployment_framework: str,
                    setup_model_monitoring: bool,
                    schedule_pattern: str,
                    source_repo_type: str,
                    use_ci: str):
    """Validates that the inputted schedule parameter and model_monitoring parameter align with the 
    use_ci configuration. Also checks unsupported configurations (e.g. using Cloudbuild with Github)

    Note: this function does not validate that schedule_pattern is a properly formatted cron value.
    Cron format validation is done in the backend by GCP.

    Args:
        deployment_framework (str): The CI tool to use (e.g. cloud build, github actions, etc.)
        setup_model_monitoring (bool): Specifies whether to set up a Vertex AI Model Monitoring Job.
        schedule_pattern (str): Cron formatted value used to create a Scheduled retrain job.
        source_repo_type (str): The type of source repository to use (e.g. gitlab, github, etc.)
        use_ci (bool): Specifies whether to use Cloud CI/CD.

    Raises:
        Exception: use_ci validation failed.
    """
    if setup_model_monitoring and not use_ci:
        raise ValueError('use_ci must be set to True to use Model Monitoring.')
    if schedule_pattern != DEFAULT_SCHEDULE_PATTERN and not use_ci:
        raise ValueError('use_ci must be set to True to use Cloud Scheduler.')
    if use_ci and source_repo_type == CodeRepository.GITHUB.value and deployment_framework == Deployer.CLOUDBUILD.value:
        raise ValueError('Using Github and Cloud Build for CI is not currently supported. '
                         'Please use Github Actions instead.')