in pai/toolkit/config.py [0:0]
def prompt_config_with_default_dsw_role(user_profile: UserProfile):
print(
localized_text(
"The current DSW instance is bound to the default PAI DSW role,"
" automatically utilizes the instance's workspace and OSS Bucket configurations.",
"当前DSW实例绑定PAI DSW默认角色,自动使用实例的工作空间和OSS Bucket配置",
)
)
instance_id = os.environ.get("DSW_INSTANCE_ID")
if not instance_id:
raise RuntimeError(
"Not found PAI DSW instance id from environment variable: DSW_INSTANCE_ID"
)
instance_info = user_profile.get_instance_info(instance_id=instance_id)
workspace_id = instance_info["WorkspaceId"]
workspace_name = instance_info["WorkspaceName"]
user_id = instance_info["UserId"]
roles = user_profile.get_roles_in_workspace(workspace_id, user_id)
role_info = ", ".join(roles)
print_highlight(
localized_text(
"Current workspace configuration:",
"当前实例的工作空间信息:",
)
)
print_highlight(
"WorkspaceName: {}\nWorkspaceId: {}\nRoles: {}".format(
workspace_name,
workspace_id,
role_info,
)
)
default_storage_uri, endpoint = user_profile.get_default_oss_storage_uri(
workspace_id=workspace_id,
)
if not default_storage_uri:
print_warning(
localized_text(
"WARNING: The STS credential generated by the default ROLE only support accessing "
"the default OSS Bucket storage of the workspace.\n"
"It is not configured for the current workspace, please "
"reference the document to configure the default OSS Bucket storage: \n"
"https://help.aliyun.com/zh/pai/user-guide/manage-workspaces#section-afd-ntr-nwh",
'警告:默认角色产生的STS凭证仅支持访问"工作空间默认存储"的OSS Bucket。\n'
"当前工作空间没有配置默认OSS Bucket存储,请参考帮助文档进行配置:\n"
"https://help.aliyun.com/zh/pai/user-guide/manage-workspaces#section-afd-ntr-nwh",
)
)
bucket_name, endpoint = None, None
else:
bucket_name = OssUriObj(default_storage_uri).bucket_name
return workspace_id, bucket_name, endpoint