

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

# 使用 `dataprocessing` 命令处理数据
<a name="machine-learning-api-dataprocessing"></a>

您可以使用 Neptune ML `dataprocessing` 命令创建数据处理任务、检查其状态、停止它或列出所有活动的数据处理任务。

## 使用 Neptune ML `dataprocessing` 命令创建数据处理任务
<a name="machine-learning-api-dataprocessing-create-job"></a>

用于创建新任务的典型 Neptune ML `dataprocessing` 命令如下所示：

------
#### [ AWS CLI ]

```
aws neptunedata start-ml-data-processing-job \
  --endpoint-url https://{{your-neptune-endpoint}}:{{port}} \
  --input-data-s3-location "s3://{{(S3 bucket name)}}/{{(path to your input folder)}}" \
  --id "{{(a job ID for the new job)}}" \
  --processed-data-s3-location "s3://{{(S3 bucket name)}}/{{(path to your output folder)}}"
```

有关更多信息，请参阅《 AWS CLI 命令参考》中的 [start-ml-data-processing-job](https://docs.aws.amazon.com/cli/latest/reference/neptunedata/start-ml-data-processing-job.html)。

------
#### [ 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.start_ml_data_processing_job(
    inputDataS3Location='s3://{{(S3 bucket name)}}/{{(path to your input folder)}}',
    id='{{(a job ID for the new job)}}',
    processedDataS3Location='s3://{{(S3 bucket name)}}/{{(path to your output folder)}}'
)

print(response)
```

------
#### [ awscurl ]

```
awscurl https://{{your-neptune-endpoint}}:{{port}}/ml/dataprocessing \
  --region {{us-east-1}} \
  --service neptune-db \
  -X POST \
  -H 'Content-Type: application/json' \
  -d '{
        "inputDataS3Location" : "s3://{{(S3 bucket name)}}/{{(path to your input folder)}}",
        "id" : "{{(a job ID for the new job)}}",
        "processedDataS3Location" : "s3://{{(S3 bucket name)}}/{{(path to your output folder)}}"
      }'
```

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

------
#### [ curl ]

```
curl \
  -X POST https://{{your-neptune-endpoint}}:{{port}}/ml/dataprocessing \
  -H 'Content-Type: application/json' \
  -d '{
        "inputDataS3Location" : "s3://{{(S3 bucket name)}}/{{(path to your input folder)}}",
        "id" : "{{(a job ID for the new job)}}",
        "processedDataS3Location" : "s3://{{(S3 bucket name)}}/{{(path to your output folder)}}"
      }'
```

------

启动增量重新处理的命令如下所示：

------
#### [ AWS CLI ]

```
aws neptunedata start-ml-data-processing-job \
  --endpoint-url https://{{your-neptune-endpoint}}:{{port}} \
  --input-data-s3-location "s3://{{(S3 bucket name)}}/{{(path to your input folder)}}" \
  --id "{{(a job ID for this job)}}" \
  --processed-data-s3-location "s3://{{(S3 bucket name)}}/{{(path to your output folder)}}" \
  --previous-data-processing-job-id "{{(the job ID of a previously completed job to update)}}"
```

有关更多信息，请参阅《 AWS CLI 命令参考》中的 [start-ml-data-processing-job](https://docs.aws.amazon.com/cli/latest/reference/neptunedata/start-ml-data-processing-job.html)。

------
#### [ 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.start_ml_data_processing_job(
    inputDataS3Location='s3://{{(S3 bucket name)}}/{{(path to your input folder)}}',
    id='{{(a job ID for this job)}}',
    processedDataS3Location='s3://{{(S3 bucket name)}}/{{(path to your output folder)}}',
    previousDataProcessingJobId='{{(the job ID of a previously completed job to update)}}'
)

print(response)
```

------
#### [ awscurl ]

```
awscurl https://{{your-neptune-endpoint}}:{{port}}/ml/dataprocessing \
  --region {{us-east-1}} \
  --service neptune-db \
  -X POST \
  -H 'Content-Type: application/json' \
  -d '{
        "inputDataS3Location" : "s3://{{(S3 bucket name)}}/{{(path to your input folder)}}",
        "id" : "{{(a job ID for this job)}}",
        "processedDataS3Location" : "s3://{{(S3 bucket name)}}/{{(path to your output folder)}}",
        "previousDataProcessingJobId" : "{{(the job ID of a previously completed job to update)}}"
      }'
```

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

------
#### [ curl ]

```
curl \
  -X POST https://{{your-neptune-endpoint}}:{{port}}/ml/dataprocessing \
  -H 'Content-Type: application/json' \
  -d '{
        "inputDataS3Location" : "s3://{{(S3 bucket name)}}/{{(path to your input folder)}}",
        "id" : "{{(a job ID for this job)}}",
        "processedDataS3Location" : "s3://{{(S3 bucket name)}}/{{(path to your output folder)}}",
        "previousDataProcessingJobId" : "{{(the job ID of a previously completed job to update)}}"
      }'
```

------

**用于创建 `dataprocessing` 任务的参数**
+ **`id`** –（*可选*）新任务的唯一标识符。

  *类型*：字符串。*默认*：自动生成的 UUID。
+ **`previousDataProcessingJobId`** –（*可选*）在较早版本的数据上运行的已完成数据处理任务的任务 ID。

  *类型*：字符串。*默认值*：*无*。

  *注意*：使用它进行增量数据处理，以便在图形数据发生变化（但不是在数据已被删除）时更新模型。
+ **`inputDataS3Location`**—（*必填*）您希望 AI 下载运行数据处理任务所需的数据的 SageMaker Amazon S3 位置的 URI。

  *类型*：字符串。
+ **`processedDataS3Location`**—（*必填*）您希望 AI 保存数据处理任务结果的 SageMaker Amazon S3 位置的 URI。

  *类型*：字符串。
+ **`sagemakerIamRoleArn`**—（*可选*）用于 A SageMaker I 执行的 IAM 角色的 ARN。

  *类型*：字符串。*注意*：必须将其列在您的数据库集群参数组中，否则将发生错误。
+ **`neptuneIamRoleArn`**—（*可选*）A SageMaker I 可以代替您执行任务的 IAM 角色的亚马逊资源名称 (ARN)。

  *类型*：字符串。*注意*：必须将其列在您的数据库集群参数组中，否则将发生错误。
+ **`processingInstanceType`** –（*可选*）在数据处理期间使用的机器学习实例的类型。它的内存应该足够大，可以容纳处理后的数据集。

  *类型*：字符串。*默认*：内存比磁盘上导出的图形数据大小大十倍的最小 `ml.r5` 类型。

  *注意*：Neptune ML 可以自动选择实例类型。请参阅[选择进行数据处理的实例](machine-learning-on-graphs-instance-selection.md#machine-learning-on-graphs-processing-instance-size)。
+ **`processingInstanceVolumeSizeInGB`** –（*可选*）处理实例的磁盘卷大小。输入数据和处理后的数据都存储在磁盘上，因此卷大小必须足够大，以容纳两个数据集。

  *类型*：整数。*默认值*：`0`。

  *注意*：如果未指定或为 0，则 Neptune ML 会根据数据大小自动选择卷大小。
+ **`processingTimeOutInSeconds`** –（*可选*）数据处理任务的超时（以秒为单位）。

  *类型*：整数。*默认值*：`86,400`（1 天）。
+ **`modelType`** –（*可选*）Neptune ML 当前支持的两种模型类型之一：异构图模型 (`heterogeneous`) 和知识图谱 (`kge`)。

  *类型*：字符串。*默认值*：*无*。

  *注意*：如果未指定，Neptune ML 会根据数据自动选择模型类型。
+ **`configFileName`** –（*可选*）描述如何加载导出的图形数据进行训练的数据规范文件。该文件由 Neptune 导出工具包自动生成。

  *类型*：字符串。*默认值*：`training-data-configuration.json`。
+ **`subnets`**—（*可选*）Ne IDs ptune VPC 中的子网。

  *类型*：字符串列表。*默认值*：*无*。
+ **`securityGroupIds`**—（*可选*）VPC 安全组 IDs。

  *类型*：字符串列表。*默认值*：*无*。
+ **`volumeEncryptionKMSKey`**—（*可选*） SageMaker AI 用来加密连接到运行处理作业的 ML 计算实例的存储卷上的数据的 AWS Key Management Service (AWS KMS) 密钥。

  *类型*：字符串。*默认值*：*无*。
+ **`enableInterContainerTrafficEncryption`** –（*可选*）在训练或超参数调整任务中启用或禁用容器间流量加密。

  *类型*：布尔值。*默认值*：*True*。
**注意**  
`enableInterContainerTrafficEncryption` 参数仅在[引擎版本 1.2.0.2.R3](engine-releases-1.2.0.2.R3.md) 中可用。
+ **`s3OutputEncryptionKMSKey`**—（*可选*AWS KMS） SageMaker AI 用来加密训练作业输出的 AWS Key Management Service () 密钥。

  *类型*：字符串。*默认值*：*无*。

## 使用 Neptune ML `dataprocessing` 命令获取数据处理任务的状态
<a name="machine-learning-api-dataprocessing-get-job-status"></a>

用于显示任务状态的示例 Neptune ML `dataprocessing` 命令如下所示：

------
#### [ AWS CLI ]

```
aws neptunedata get-ml-data-processing-job \
  --endpoint-url https://{{your-neptune-endpoint}}:{{port}} \
  --id "{{(the job ID)}}"
```

有关更多信息，请参阅《 AWS CLI 命令参考》中的 [get-ml-data-processing-job](https://docs.aws.amazon.com/cli/latest/reference/neptunedata/get-ml-data-processing-job.html)。

------
#### [ 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_data_processing_job(
    id='{{(the job ID)}}'
)

print(response)
```

------
#### [ awscurl ]

```
awscurl https://{{your-neptune-endpoint}}:{{port}}/ml/dataprocessing/{{(the job ID)}} \
  --region {{us-east-1}} \
  --service neptune-db \
  -X GET
```

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

------
#### [ curl ]

```
curl -s \
  "https://{{your-neptune-endpoint}}:{{port}}/ml/dataprocessing/{{(the job ID)}}" \
  | python -m json.tool
```

------

**`dataprocessing` 任务状态的参数**
+ **`id`** –（*必需*）数据处理任务的唯一标识符。

  *类型*：字符串。
+ **`neptuneIamRoleArn`**—（*可选*）向 Neptune 提供 AI 和 A SageMaker mazon S3 资源访问权限的 IAM 角色的 ARN。

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

## 使用 Neptune ML `dataprocessing` 命令停止数据处理任务
<a name="machine-learning-api-dataprocessing-stop-job"></a>

用于停止任务的示例 Neptune ML `dataprocessing` 命令如下所示：

------
#### [ AWS CLI ]

```
aws neptunedata cancel-ml-data-processing-job \
  --endpoint-url https://{{your-neptune-endpoint}}:{{port}} \
  --id "{{(the job ID)}}"
```

要同时清理 Amazon S3 工件，请执行以下操作：

```
aws neptunedata cancel-ml-data-processing-job \
  --endpoint-url https://{{your-neptune-endpoint}}:{{port}} \
  --id "{{(the job ID)}}" \
  --clean
```

有关更多信息，请参阅《 AWS CLI 命令参考》中的 [cancel-ml-data-processing-job](https://docs.aws.amazon.com/cli/latest/reference/neptunedata/cancel-ml-data-processing-job.html)。

------
#### [ 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.cancel_ml_data_processing_job(
    id='{{(the job ID)}}',
    clean=True
)

print(response)
```

------
#### [ awscurl ]

```
awscurl https://{{your-neptune-endpoint}}:{{port}}/ml/dataprocessing/{{(the job ID)}} \
  --region {{us-east-1}} \
  --service neptune-db \
  -X DELETE
```

要同时清理 Amazon S3 工件，请执行以下操作：

```
awscurl "https://{{your-neptune-endpoint}}:{{port}}/ml/dataprocessing/{{(the job 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/dataprocessing/{{(the job ID)}}"
```

或者：

```
curl -s \
  -X DELETE "https://{{your-neptune-endpoint}}:{{port}}/ml/dataprocessing/{{(the job ID)}}?clean=true"
```

------

**`dataprocessing` 停止任务的参数**
+ **`id`** –（*必需*）数据处理任务的唯一标识符。

  *类型*：字符串。
+ **`neptuneIamRoleArn`**—（*可选*）向 Neptune 提供 AI 和 A SageMaker mazon S3 资源访问权限的 IAM 角色的 ARN。

  *类型*：字符串。*注意*：必须将其列在您的数据库集群参数组中，否则将发生错误。
+ **`clean`** –（*可选*）此标志指定在任务停止时应删除所有 Amazon S3 构件。

  *类型*：布尔值。*默认值*：`FALSE`。

## 使用 Neptune ML `dataprocessing` 命令列出处于活动状态的数据处理任务
<a name="machine-learning-api-dataprocessing-list-jobs"></a>

用于列出活动任务的示例 Neptune ML `dataprocessing` 命令如下所示：

------
#### [ AWS CLI ]

```
aws neptunedata list-ml-data-processing-jobs \
  --endpoint-url https://{{your-neptune-endpoint}}:{{port}}
```

要限制结果数量，请执行以下操作：

```
aws neptunedata list-ml-data-processing-jobs \
  --endpoint-url https://{{your-neptune-endpoint}}:{{port}} \
  --max-items 3
```

有关更多信息，请参阅《 AWS CLI 命令参考》中的 [list-ml-data-processing-job](https://docs.aws.amazon.com/cli/latest/reference/neptunedata/list-ml-data-processing-jobs.html) s。

------
#### [ 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_data_processing_jobs(
    maxItems=3
)

print(response)
```

------
#### [ awscurl ]

```
awscurl https://{{your-neptune-endpoint}}:{{port}}/ml/dataprocessing \
  --region {{us-east-1}} \
  --service neptune-db \
  -X GET
```

要限制结果数量，请执行以下操作：

```
awscurl "https://{{your-neptune-endpoint}}:{{port}}/ml/dataprocessing?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/dataprocessing"
```

或者：

```
curl -s "https://{{your-neptune-endpoint}}:{{port}}/ml/dataprocessing?maxItems=3"
```

------

**`dataprocessing` 列出任务的参数**
+ **`maxItems`** –（*可选*），表示要返回的最大项目数。

  *类型*：整数。*默认值*：`10`。*允许的最大值*：`1024`。
+ **`neptuneIamRoleArn`**—（*可选*）向 Neptune 提供 AI 和 A SageMaker mazon S3 资源访问权限的 IAM 角色的 ARN。

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