in src/hyperpod_cli/commands/job.py [0:0]
def get_user_name():
caller_arn = boto3.client("sts").get_caller_identity().get('Arn')
if 'user/' in caller_arn:
user_name = 'User-' + caller_arn.split('user/')[-1]
elif 'assumed-role' in caller_arn:
user_name = 'AssumedRole-' + caller_arn.split('assumed-role/')[-1]
else:
user_name = 'Unknown'
# label value does not allow slash
user_name = user_name.replace('/', '-')
# 63 is the max length for a Kubernetes label
if len(user_name) > 63:
# Add dots in the end to indicate the username is trimmed
trimmed_user_name = user_name[:55] + '-trimmed'
logger.warning(f"The username is longer than the maximum length (63) of Kubernetes label, trimming to {trimmed_user_name}")
return trimmed_user_name
return user_name