in google_cloud_automlops/utils/utils.py [0:0]
def account_permissions_warning(operation: str, defaults: dict):
"""Logs the current gcloud account and generates warnings based on the operation being performed.
Args:
operation (str): Specifies which operation is being performed. Available options {provision,
deploy_with_precheck, deploy_without_precheck, model_monitoring}.
defaults (dict): Contents of the Defaults yaml file (config/defaults.yaml).
"""
bullet_nl = '\n-'
gcp_account = subprocess.check_output(
['gcloud config list account --format "value(core.account)" 2> /dev/null'], shell=True, stderr=subprocess.STDOUT).decode('utf-8').strip('\n')
if operation == 'provision':
logging.warning(f'WARNING: Provisioning requires these permissions:\n-{bullet_nl.join(i for i in get_provision_min_permissions(defaults))}\n\n'
f'You are currently using: {gcp_account}. Please check your account permissions.\n'
f'The following are the recommended roles for provisioning:\n-{bullet_nl.join(i for i in get_provision_recommended_roles(defaults))}\n')
elif operation == 'deploy_with_precheck':
logging.warning(f'WARNING: Running precheck for deploying requires these permissions:\n-{bullet_nl.join(i for i in get_deploy_with_precheck_min_permissions(defaults))}\n\n'
f'You are currently using: {gcp_account}. Please check your account permissions.\n'
f'The following are the recommended roles for deploying with precheck:\n-{bullet_nl.join(i for i in get_deploy_with_precheck_recommended_roles(defaults))}\n')
elif operation == 'deploy_without_precheck':
logging.warning(f'WARNING: Deploying requires these permissions:\n-{bullet_nl.join(i for i in get_deploy_without_precheck_min_permissions(defaults))}\n\n'
f'You are currently using: {gcp_account}. Please check your account permissions.\n'
f'The following are the recommended roles for deploying:\n-{bullet_nl.join(i for i in get_deploy_without_precheck_recommended_roles(defaults))}\n')
elif operation == 'model_monitoring':
logging.warning(f'WARNING: Creating monitoring jobs requires these permissions:\n-{bullet_nl.join(i for i in get_model_monitoring_min_permissions(defaults))}\n\n'
f'You are currently using: {gcp_account}. Please check your account permissions.\n'
f'The following are the recommended roles for creating monitoring jobs:\n-{bullet_nl.join(i for i in get_model_monitoring_recommended_roles(defaults))}\n')