

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

# Deadline Cloud가 Amazon S3에 파일을 업로드하는 방법
<a name="what-job-attachments-uploads-to-amazon-s3"></a>

이 예제는 Deadline Cloud가 워크스테이션 또는 작업자 호스트에서 Amazon S3로 파일을 업로드하여 공유할 수 있도록 하는 방법을 보여줍니다. GitHub 및 Deadline Cloud CLI의 샘플 작업 번들을 사용하여 작업을 제출합니다.

 [먼저 Deadline Cloud 샘플 GitHub 리포지토리](https://github.com/aws-deadline/deadline-cloud-samples)를 [AWS CloudShell](https://docs.aws.amazon.com/cloudshell/latest/userguide/welcome.html) 환경에 복제한 다음 `job_attachments_devguide` 작업 번들을 홈 디렉터리에 복사합니다.

```
git clone https://github.com/aws-deadline/deadline-cloud-samples.git
cp -r deadline-cloud-samples/job_bundles/job_attachments_devguide ~/
```

 [Deadline Cloud CLI](https://pypi.org/project/deadline/)를 설치하여 작업 번들을 제출합니다.

```
pip install deadline --upgrade
```

 `job_attachments_devguide` 작업 번들에는 파일 시스템 위치가 작업 파라미터로 전달되는 bash 셸 스크립트를 실행하는 작업이 포함된 단일 단계가 있습니다. 작업 파라미터의 정의는 다음과 같습니다.

```
...
- name: ScriptFile
  type: PATH
  default: script.sh
  dataFlow: IN
  objectType: FILE
...
```

 `dataFlow` 속성 값은 작업 연결에 `ScriptFile` 파라미터 값이 작업에 대한 입력임을 `IN` 알려줍니다. `default` 속성 값은 작업 번들 디렉터리의 상대 위치이지만 절대 경로일 수도 있습니다. 이 파라미터 정의는 작업 번들의 디렉터리에 있는 `script.sh` 파일을 작업을 실행하는 데 필요한 입력 파일로 선언합니다.

 그런 다음 Deadline Cloud CLI에 스토리지 프로파일이 구성되어 있지 않은지 확인한 다음 작업을 대기열에 제출합니다. `Q1` 

```
# Change the value of FARM_ID to your farm's identifier
FARM_ID=farm-{{00112233445566778899aabbccddeeff}}
# Change the value of QUEUE1_ID to queue Q1's identifier
QUEUE1_ID=queue-{{00112233445566778899aabbccddeeff}}

deadline config set settings.storage_profile_id ''

deadline bundle submit --farm-id $FARM_ID --queue-id $QUEUE1_ID job_attachments_devguide/
```

 이 명령이 실행된 후 Deadline Cloud CLI의 출력은 다음과 같습니다.

```
Submitting to Queue: Q1
...
Hashing Attachments  [####################################]  100%
Hashing Summary:
    Processed 1 file totaling 39.0 B.
    Skipped re-processing 0 files totaling 0.0 B.
    Total processing time of 0.0327 seconds at 1.19 KB/s.

Uploading Attachments  [####################################]  100%
Upload Summary:
    Processed 1 file totaling 39.0 B.
    Skipped re-processing 0 files totaling 0.0 B.
    Total processing time of 0.25639 seconds at 152.0 B/s.

Waiting for Job to be created...
Submitted job bundle:
   job_attachments_devguide/
Job creation completed successfully
job-74148c13342e4514b63c7a7518657005
```

작업을 제출하면 Deadline Cloud는 먼저 `script.sh` 파일을 해시한 다음 Amazon S3에 업로드합니다.

Deadline Cloud는 S3 버킷을 콘텐츠 주소 지정 스토리지로 취급합니다. 파일은 S3 객체에 업로드됩니다. 객체 이름은 파일 콘텐츠의 해시에서 파생됩니다. 두 파일의 콘텐츠가 동일한 경우 파일의 위치나 이름에 관계없이 해시 값이 동일합니다. 이 콘텐츠 주소 지정 스토리지를 사용하면 Deadline Cloud가 이미 사용 가능한 파일을 업로드하지 않아도 됩니다.

 [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-welcome.html)를 사용하여 Amazon S3에 업로드된 객체를 볼 수 있습니다.

```
# The name of queue `Q1`'s job attachments S3 bucket
Q1_S3_BUCKET=$(
  aws deadline get-queue --farm-id $FARM_ID --queue-id $QUEUE1_ID \
    --query 'jobAttachmentSettings.s3BucketName' | tr -d '"'
)

aws s3 ls s3://$Q1_S3_BUCKET --recursive
```

 두 개의 객체가 S3에 업로드되었습니다.
+  `DeadlineCloud/Data/87cb19095dd5d78fcaf56384ef0e6241.xxh128` -의 내용입니다`script.sh`. 객체 키`87cb19095dd5d78fcaf56384ef0e6241`의 값은 파일 내용의 해시이며 확장자는 해시 값이 128비트 [xxhash](https://xxhash.com/)로 계산되었음을 `xxh128` 나타냅니다.
+  `DeadlineCloud/Manifests/<farm-id>/<queue-id>/Inputs/<guid>/a1d221c7fd97b08175b3872a37428e8c_input` - 작업 제출을 위한 매니페스트 객체입니다. 값 `<farm-id>`, 및 `<queue-id>``<guid>`는 팜 식별자, 대기열 식별자 및 무작위 16진수 값입니다. 이 예제`a1d221c7fd97b08175b3872a37428e8c`의 값은가 위치한 디렉터리`/home/cloudshell-user/job_attachments_devguide`인 문자열에서 계산된 해시 값`script.sh`입니다.

 매니페스트 객체에는 작업 제출의 일부로 S3에 업로드된 특정 루트 경로의 입력 파일에 대한 정보가 포함됩니다. 이 매니페스트 파일(`aws s3 cp s3://$Q1_S3_BUCKET/<objectname>`)을 다운로드합니다. 콘텐츠는 다음과 유사합니다.

```
{
    "hashAlg": "xxh128",
    "manifestVersion": "2023-03-03",
    "paths": [
        {
            "hash": "87cb19095dd5d78fcaf56384ef0e6241",
            "mtime": 1721147454416085,
            "path": "script.sh",
            "size": 39
        }
    ],
    "totalSize": 39
}
```

이는 파일이 업로드`script.sh`되었고 해당 파일 콘텐츠의 해시가 임을 나타냅니다`87cb19095dd5d78fcaf56384ef0e6241`. 이 해시 값은 객체 이름의 값과 일치합니다`DeadlineCloud/Data/87cb19095dd5d78fcaf56384ef0e6241.xxh128`. Deadline Cloud는이 파일의 콘텐츠에 대해 다운로드할 객체를 파악하는 데 사용됩니다.

 이 파일의 전체 스키마는 [ GitHub에서 사용할 수](https://github.com/aws-deadline/deadline-cloud/blob/mainline/src/deadline/job_attachments/asset_manifests/v2023_03_03/validate.py) 있습니다.

[CreateJob 작업을](https://docs.aws.amazon.com/deadline-cloud/latest/APIReference/API_CreateJob.html) 사용할 때 매니페스트 객체의 위치를 설정할 수 있습니다. [GetJob 작업을](https://docs.aws.amazon.com/deadline-cloud/latest/APIReference/API_GetJob.html) 사용하여 위치를 확인할 수 있습니다.

```
{
    "attachments": {
        "file system": "COPIED",
        "manifests": [
            {
                "inputManifestHash": "5b0db3d311805ea8de7787b64cbbe8b3",
                "inputManifestPath": "<farm-id>/<queue-id>/Inputs/<guid>/a1d221c7fd97b08175b3872a37428e8c_input",
                "rootPath": "/home/cloudshell-user/job_attachments_devguide",
                "rootPathFormat": "posix"
            }
        ]
    },
    ...
}
```