View a markdown version of this page

使用 endpoints 命令管理推理端点 - Amazon Neptune

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

使用 endpoints 命令管理推理端点

您可以使用 Neptune ML endpoints 命令创建推理端点、检查其状态、将其删除或列出现有推理端点。

使用 Neptune ML endpoints 命令创建推理端点

用于根据训练任务创建的模型创建推理端点的 Neptune ML endpoints 命令如下所示:

AWS CLI
aws neptunedata create-ml-endpoint \ --endpoint-url https://your-neptune-endpoint:port \ --id "(a unique ID for the new endpoint)" \ --ml-model-training-job-id "(the model-training job-id of a completed job)"

有关更多信息,请参阅《 AWS CLI 命令参考》create-ml-endpoint中的。

SDK
import boto3 from botocore.config import Config client = boto3.client( 'neptunedata', endpoint_url='https://your-neptune-endpoint:port', config=Config(read_timeout=None, retries={'total_max_attempts': 1}) ) response = client.create_ml_endpoint( id='(a unique ID for the new endpoint)', mlModelTrainingJobId='(the model-training job-id of a completed job)' ) print(response)
awscurl
awscurl https://your-neptune-endpoint:port/ml/endpoints \ --region us-east-1 \ --service neptune-db \ -X POST \ -H 'Content-Type: application/json' \ -d '{ "id" : "(a unique ID for the new endpoint)", "mlModelTrainingJobId": "(the model-training job-id of a completed job)" }'
注意

此示例假设您的 AWS 证书是在您的环境中配置的。us-east-1替换为 Neptune 集群的区域。

curl
curl \ -X POST https://your-neptune-endpoint:port/ml/endpoints \ -H 'Content-Type: application/json' \ -d '{ "id" : "(a unique ID for the new endpoint)", "mlModelTrainingJobId": "(the model-training job-id of a completed job)" }'

用于根据训练任务创建的模型更新现有推理端点的 Neptune ML endpoints 命令如下所示:

AWS CLI
aws neptunedata create-ml-endpoint \ --endpoint-url https://your-neptune-endpoint:port \ --id "(a unique ID for the new endpoint)" \ --update \ --ml-model-training-job-id "(the model-training job-id of a completed job)"

有关更多信息,请参阅《 AWS CLI 命令参考》create-ml-endpoint中的。

SDK
import boto3 from botocore.config import Config client = boto3.client( 'neptunedata', endpoint_url='https://your-neptune-endpoint:port', config=Config(read_timeout=None, retries={'total_max_attempts': 1}) ) response = client.create_ml_endpoint( id='(a unique ID for the new endpoint)', update=True, mlModelTrainingJobId='(the model-training job-id of a completed job)' ) print(response)
awscurl
awscurl https://your-neptune-endpoint:port/ml/endpoints \ --region us-east-1 \ --service neptune-db \ -X POST \ -H 'Content-Type: application/json' \ -d '{ "id" : "(a unique ID for the new endpoint)", "update" : "true", "mlModelTrainingJobId": "(the model-training job-id of a completed job)" }'
注意

此示例假设您的 AWS 证书是在您的环境中配置的。us-east-1替换为 Neptune 集群的区域。

curl
curl \ -X POST https://your-neptune-endpoint:port/ml/endpoints \ -H 'Content-Type: application/json' \ -d '{ "id" : "(a unique ID for the new endpoint)", "update" : "true", "mlModelTrainingJobId": "(the model-training job-id of a completed job)" }'

用于根据模型转换任务创建的模型创建推理端点的 Neptune ML endpoints 命令如下所示:

AWS CLI
aws neptunedata create-ml-endpoint \ --endpoint-url https://your-neptune-endpoint:port \ --id "(a unique ID for the new endpoint)" \ --ml-model-transform-job-id "(the model-transform job-id of a completed job)"

有关更多信息,请参阅《 AWS CLI 命令参考》create-ml-endpoint中的。

SDK
import boto3 from botocore.config import Config client = boto3.client( 'neptunedata', endpoint_url='https://your-neptune-endpoint:port', config=Config(read_timeout=None, retries={'total_max_attempts': 1}) ) response = client.create_ml_endpoint( id='(a unique ID for the new endpoint)', mlModelTransformJobId='(the model-transform job-id of a completed job)' ) print(response)
awscurl
awscurl https://your-neptune-endpoint:port/ml/endpoints \ --region us-east-1 \ --service neptune-db \ -X POST \ -H 'Content-Type: application/json' \ -d '{ "id" : "(a unique ID for the new endpoint)", "mlModelTransformJobId": "(the model-transform job-id of a completed job)" }'
注意

此示例假设您的 AWS 证书是在您的环境中配置的。us-east-1替换为 Neptune 集群的区域。

curl
curl \ -X POST https://your-neptune-endpoint:port/ml/endpoints \ -H 'Content-Type: application/json' \ -d '{ "id" : "(a unique ID for the new endpoint)", "mlModelTransformJobId": "(the model-transform job-id of a completed job)" }'

用于根据模型转换任务创建的模型更新现有推理端点的 Neptune ML endpoints 命令如下所示:

AWS CLI
aws neptunedata create-ml-endpoint \ --endpoint-url https://your-neptune-endpoint:port \ --id "(a unique ID for the new endpoint)" \ --update \ --ml-model-transform-job-id "(the model-transform job-id of a completed job)"

有关更多信息,请参阅《 AWS CLI 命令参考》create-ml-endpoint中的。

SDK
import boto3 from botocore.config import Config client = boto3.client( 'neptunedata', endpoint_url='https://your-neptune-endpoint:port', config=Config(read_timeout=None, retries={'total_max_attempts': 1}) ) response = client.create_ml_endpoint( id='(a unique ID for the new endpoint)', update=True, mlModelTransformJobId='(the model-transform job-id of a completed job)' ) print(response)
awscurl
awscurl https://your-neptune-endpoint:port/ml/endpoints \ --region us-east-1 \ --service neptune-db \ -X POST \ -H 'Content-Type: application/json' \ -d '{ "id" : "(a unique ID for the new endpoint)", "update" : "true", "mlModelTransformJobId": "(the model-transform job-id of a completed job)" }'
注意

此示例假设您的 AWS 证书是在您的环境中配置的。us-east-1替换为 Neptune 集群的区域。

curl
curl \ -X POST https://your-neptune-endpoint:port/ml/endpoints \ -H 'Content-Type: application/json' \ -d '{ "id" : "(a unique ID for the new endpoint)", "update" : "true", "mlModelTransformJobId": "(the model-transform job-id of a completed job)" }'
用于创建 endpoints 推理端点的参数
  • id –(可选)新推理端点的唯一标识符。

    类型:字符串。默认:自动生成的带有时间戳的名称。

  • mlModelTrainingJobId – 已完成的模型训练任务的任务 ID,该任务创建了推理端点将指向的模型。

    类型:字符串。

    注意:您必须提供 mlModelTrainingJobIdmlModelTransformJobId

  • mlModelTransformJobId – 已完成的模型转换任务的任务 ID。

    类型:字符串。

    注意:您必须提供 mlModelTrainingJobIdmlModelTransformJobId

  • update –(可选)如果存在,则此参数表示这是更新请求。

    类型:布尔值。默认值false

    注意:您必须提供 mlModelTrainingJobIdmlModelTransformJobId

  • neptuneIamRoleArn—(可选)向 Neptune 提供 AI 和 A SageMaker mazon S3 资源访问权限的 IAM 角色的 ARN。

    类型:字符串。注意:必须将其列在您的数据库集群参数组中,否则将引发错误。

  • modelName –(可选)训练的模型类型。默认情况下,机器学习模型是根据数据处理中使用的 modelType 自动生成的,但您可以在此处指定不同的模型类型。

    类型:字符串。默认rgcn 用于异构图形,kge 用于知识图谱。有效值:对于异构图形:rgcn。对于知识图谱:kgetransedistmultrotate

  • instanceType –(可选)用于在线服务的机器学习实例的类型。

    类型:字符串。默认值ml.m5.xlarge

    注意:为推理端点选择 ML 实例取决于任务类型、图形大小和预算。请参阅为推理端点选择实例

  • instanceCount –(可选)部署到端点以进行预测的最少 Amazon EC2 实例数量。

    类型:整数。默认值1

  • volumeEncryptionKMSKey—(可选AWS KMS) SageMaker AI 用来加密连接到运行端点的 ML 计算实例的存储卷上的数据的 () 密钥。 AWS Key Management Service

    类型:字符串。默认值

使用 Neptune ML endpoints 命令获取推理端点的状态

用于显示实例端点状态的示例 Neptune ML endpoints 命令如下所示:

AWS CLI
aws neptunedata get-ml-endpoint \ --endpoint-url https://your-neptune-endpoint:port \ --id "(the inference endpoint ID)"

有关更多信息,请参阅《 AWS CLI 命令参考》get-ml-endpoint中的。

SDK
import boto3 from botocore.config import Config client = boto3.client( 'neptunedata', endpoint_url='https://your-neptune-endpoint:port', config=Config(read_timeout=None, retries={'total_max_attempts': 1}) ) response = client.get_ml_endpoint( id='(the inference endpoint ID)' ) print(response)
awscurl
awscurl https://your-neptune-endpoint:port/ml/endpoints/(the inference endpoint ID) \ --region us-east-1 \ --service neptune-db \ -X GET
注意

此示例假设您的 AWS 证书是在您的环境中配置的。us-east-1替换为 Neptune 集群的区域。

curl
curl -s \ "https://your-neptune-endpoint:port/ml/endpoints/(the inference endpoint ID)" \ | python -m json.tool
endpoints 实例端点状态的参数
  • id –(必需)推理端点的唯一标识符。

    类型:字符串。

  • neptuneIamRoleArn—(可选)向 Neptune 提供 AI 和 A SageMaker mazon S3 资源访问权限的 IAM 角色的 ARN。

    类型:字符串。注意:必须将其列在您的数据库集群参数组中,否则将引发错误。

使用 Neptune ML endpoints 命令删除实例端点

用于删除实例端点的 Neptune ML endpoints 命令示例如下所示:

AWS CLI
aws neptunedata delete-ml-endpoint \ --endpoint-url https://your-neptune-endpoint:port \ --id "(the inference endpoint ID)"

要同时清理相关工件,请执行以下操作:

aws neptunedata delete-ml-endpoint \ --endpoint-url https://your-neptune-endpoint:port \ --id "(the inference endpoint ID)" \ --clean

有关更多信息,请参阅《 AWS CLI 命令参考》delete-ml-endpoint中的。

SDK
import boto3 from botocore.config import Config client = boto3.client( 'neptunedata', endpoint_url='https://your-neptune-endpoint:port', config=Config(read_timeout=None, retries={'total_max_attempts': 1}) ) response = client.delete_ml_endpoint( id='(the inference endpoint ID)', clean=True ) print(response)
awscurl
awscurl https://your-neptune-endpoint:port/ml/endpoints/(the inference endpoint ID) \ --region us-east-1 \ --service neptune-db \ -X DELETE

要同时清理相关工件,请执行以下操作:

awscurl "https://your-neptune-endpoint:port/ml/endpoints/(the inference endpoint ID)?clean=true" \ --region us-east-1 \ --service neptune-db \ -X DELETE
注意

此示例假设您的 AWS 证书是在您的环境中配置的。us-east-1替换为 Neptune 集群的区域。

curl
curl -s \ -X DELETE "https://your-neptune-endpoint:port/ml/endpoints/(the inference endpoint ID)"

或者:

curl -s \ -X DELETE "https://your-neptune-endpoint:port/ml/endpoints/(the inference endpoint ID)?clean=true"
endpoints 删除推理端点的参数
  • id –(必需)推理端点的唯一标识符。

    类型:字符串。

  • neptuneIamRoleArn—(可选)向 Neptune 提供 AI 和 A SageMaker mazon S3 资源访问权限的 IAM 角色的 ARN。

    类型:字符串。注意:必须将其列在您的数据库集群参数组中,否则将引发错误。

  • clean –(可选)表示还应删除与此端点相关的所有构件。

    类型:布尔值。默认值FALSE

使用 Neptune ML endpoints 命令列出推理端点

用于列出推理端点的 Neptune ML endpoints 命令如下所示:

AWS CLI
aws neptunedata list-ml-endpoints \ --endpoint-url https://your-neptune-endpoint:port

要限制结果数量,请执行以下操作:

aws neptunedata list-ml-endpoints \ --endpoint-url https://your-neptune-endpoint:port \ --max-items 3

有关更多信息,请参阅《 AWS CLI 命令参考》list-ml-endpoints中的。

SDK
import boto3 from botocore.config import Config client = boto3.client( 'neptunedata', endpoint_url='https://your-neptune-endpoint:port', config=Config(read_timeout=None, retries={'total_max_attempts': 1}) ) response = client.list_ml_endpoints( maxItems=3 ) print(response)
awscurl
awscurl https://your-neptune-endpoint:port/ml/endpoints \ --region us-east-1 \ --service neptune-db \ -X GET

要限制结果数量,请执行以下操作:

awscurl "https://your-neptune-endpoint:port/ml/endpoints?maxItems=3" \ --region us-east-1 \ --service neptune-db \ -X GET
注意

此示例假设您的 AWS 证书是在您的环境中配置的。us-east-1替换为 Neptune 集群的区域。

curl
curl -s "https://your-neptune-endpoint:port/ml/endpoints" \ | python -m json.tool

或者:

curl -s "https://your-neptune-endpoint:port/ml/endpoints?maxItems=3" \ | python -m json.tool
dataprocessing 列出推理端点的参数
  • maxItems –(可选),表示要返回的最大项目数。

    类型:整数。默认值10允许的最大值1024

  • neptuneIamRoleArn—(可选)向 Neptune 提供 AI 和 A SageMaker mazon S3 资源访问权限的 IAM 角色的 ARN。

    类型:字符串。注意:必须将其列在您的数据库集群参数组中,否则将引发错误。