

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

# 작업 첨부 파일을 사용하여 파일 공유
<a name="build-job-attachments"></a>

*작업 첨부* 파일을 사용하여 파일을 공유 디렉터리에서 작업에 사용할 수 없게 하고, 파일이 공유 디렉터리에 기록되지 않은 경우 출력 파일을 캡처합니다. 작업 연결은 Amazon S3를 사용하여 호스트 간에 파일을 복원합니다. 파일은 S3 버킷에 저장되며 콘텐츠가 변경되지 않은 경우 파일을 업로드할 필요가 없습니다.

호스트는 파일 시스템 위치를 공유하지 않으므로 [서비스 관리형 플릿](https://docs.aws.amazon.com/deadline-cloud/latest/userguide/smf-manage.html)에서 작업을 실행할 때 작업 연결을 사용해야 합니다. 작업 연결은 작업 [번들에](https://docs.aws.amazon.com/deadline-cloud/latest/userguide/submit-job-bundle.html) [셸 또는 Python 스크립트가 포함된 경우와 같이 작업의 입력 또는 출력 파일이 공유 네트워크 파일 시스템에 저장되는 경우 고객 관리형 플릿](https://docs.aws.amazon.com/deadline-cloud/latest/userguide/manage-cmf.html)에도 유용합니다.

 [Deadline Cloud CLI](https://pypi.org/project/deadline/) 또는 Deadline Cloud 제출자를 사용하여 작업 번들을 제출하면 작업 첨부 파일은 작업의 스토리지 프로파일과 대기열의 필수 파일 시스템 위치를 사용하여 작업자 호스트에 있지 않으며 작업 제출의 일부로 Amazon S3에 업로드해야 하는 입력 파일을 식별합니다. 또한 이러한 스토리지 프로파일은 Deadline Cloud가 워크스테이션에서 사용할 수 있도록 Amazon S3에 업로드해야 하는 작업자 호스트 위치의 출력 파일을 식별하는 데 도움이 됩니다.

 작업 연결 예제에서는 [샘플 프로젝트 인프라](sample-project-infrastructure.md) 및의 팜, 플릿, 대기열 및 스토리지 프로파일 구성을 사용합니다[스토리지 프로파일 및 경로 매핑](storage-profiles-and-path-mapping.md). 이 섹션보다 먼저 해당 섹션을 살펴봐야 합니다.

다음 예제에서는 샘플 작업 번들을 시작점으로 사용한 다음 수정하여 작업 첨부 파일의 기능을 살펴봅니다. 작업 번들은 작업에서 작업 첨부 파일을 사용하는 가장 좋은 방법입니다. 디렉터리의 [Open Job Description](https://github.com/OpenJobDescription/openjd-specifications/wiki) 작업 템플릿을 작업 번들을 사용하는 작업에 필요한 파일 및 디렉터리를 나열하는 추가 파일과 결합합니다. 작업 번들에 대한 자세한 내용은 섹션을 참조하세요[Deadline Cloud에 대한 Open Job Description(OpenJD) 템플릿](build-job-bundle.md).

# 작업으로 파일 제출
<a name="submitting-files-with-a-job"></a>

Deadline Cloud를 사용하면 작업 워크플로가 작업자 호스트의 공유 파일 시스템 위치에서 사용할 수 없는 입력 파일에 액세스할 수 있습니다. 작업 연결을 사용하면 렌더링 작업이 로컬 워크스테이션 드라이브 또는 서비스 관리형 플릿 환경에만 있는 파일에 액세스할 수 있습니다. 작업 번들을 제출할 때 작업에 필요한 입력 파일 및 디렉터리 목록을 포함할 수 있습니다. Deadline Cloud는 공유되지 않은 이러한 파일을 식별하고 로컬 시스템에서 Amazon S3로 업로드한 다음 작업자 호스트로 다운로드합니다. 입력 자산을 렌더 노드로 전송하는 프로세스를 간소화하여 분산 작업 실행에 필요한 모든 파일에 액세스할 수 있도록 합니다.

작업 번들에서 직접 작업에 대한 파일을 지정하고, 환경 변수 또는 스크립트를 사용하여 제공하는 작업 템플릿의 파라미터를 사용하고, 작업의 `assets_references` 파일을 사용할 수 있습니다. 이러한 방법 중 하나 또는 세 가지 방법의 조합을 사용할 수 있습니다. 로컬 워크스테이션에서 변경된 파일만 업로드하도록 작업에 대한 번들의 스토리지 프로파일을 지정할 수 있습니다.

이 섹션에서는 GitHub의 예제 작업 번들을 사용하여 Deadline Cloud가 업로드할 작업의 파일을 식별하는 방법, Amazon S3에서 해당 파일이 구성되는 방법, 작업을 처리하는 작업자 호스트가 사용할 수 있는 방법을 보여줍니다.

**Topics**
+ [Deadline Cloud가 Amazon S3에 파일을 업로드하는 방법](what-job-attachments-uploads-to-amazon-s3.md)
+ [Deadline Cloud가 업로드할 파일을 선택하는 방법](how-job-attachments-decides-what-to-upload-to-amazon-s3.md)
+ [작업에서 작업 연결 입력 파일을 찾는 방법](how-jobs-find-job-attachments-input-files.md)

# 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"
            }
        ]
    },
    ...
}
```

# Deadline Cloud가 업로드할 파일을 선택하는 방법
<a name="how-job-attachments-decides-what-to-upload-to-amazon-s3"></a>

 작업 첨부 파일이 Amazon S3에 업로드할 때 작업에 대한 입력으로 고려하는 파일 및 디렉터리는 다음과 같습니다.
+  또는 값을 사용하여 작업 번들의 작업 템플릿에 정의된 모든 `PATH`유형 작업 파라미터의 `dataFlow` 값`IN`입니다`INOUT`.
+  작업 번들의 자산 참조 파일에 입력으로 나열된 파일 및 디렉터리입니다.

 스토리지 프로파일이 없는 작업을 제출하면 업로드 대상으로 간주되는 모든 파일이 업로드됩니다. 스토리지 프로파일이 있는 작업을 제출하면 파일이 대기열에 필요한 파일 시스템 위치이기도 한 스토리지 프로파일의 `SHARED`유형 파일 시스템 위치에 있는 경우 Amazon S3에 업로드되지 않습니다. 이러한 위치는 작업을 실행하는 작업자 호스트에서 사용할 수 있을 것으로 예상되므로 S3에 업로드할 필요가 없습니다.

 이 예제에서는 AWS CloudShell 환경의 `WSAll`에서 `SHARED` 파일 시스템 위치를 생성한 다음 해당 파일 시스템 위치에 파일을 추가합니다. 다음 명령을 사용합니다.

```
# Change the value of WSALL_ID to the identifier of the WSAll storage profile
WSALL_ID=sp-00112233445566778899aabbccddeeff

sudo mkdir -p /shared/common /shared/projects/project1 /shared/projects/project2
sudo chown -R cloudshell-user:cloudshell-user /shared

for d in /shared/common /shared/projects/project1 /shared/projects/project2; do
  echo "File contents for $d" > ${d}/file.txt
done
```

 그런 다음 작업에 대한 입력으로 생성한 모든 파일이 포함된 작업 번들에 자산 참조 파일을 추가합니다. 다음 명령을 사용합니다.

```
cat > ${HOME}/job_attachments_devguide/asset_references.yaml << EOF
assetReferences:
  inputs:
    filenames:
    - /shared/common/file.txt
    directories:
    - /shared/projects/project1
    - /shared/projects/project2
EOF
```

 그런 다음 `WSAll` 스토리지 프로파일이 있는 작업을 제출하도록 Deadline Cloud CLI를 구성한 다음 작업 번들을 제출합니다.

```
# 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
# Change the value of WSALL_ID to the identifier of the WSAll storage profile
WSALL_ID=sp-00112233445566778899aabbccddeeff

deadline config set settings.storage_profile_id $WSALL_ID

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

Deadline Cloud는 작업을 제출할 때 Amazon S3에 두 개의 파일을 업로드합니다. S3에서 작업에 대한 매니페스트 객체를 다운로드하여 업로드된 파일을 볼 수 있습니다.

```
for manifest in $( \
  aws deadline get-job --farm-id $FARM_ID --queue-id $QUEUE1_ID --job-id $JOB_ID \
    --query 'attachments.manifests[].inputManifestPath' \
    | jq -r '.[]'
); do
  echo "Manifest object: $manifest"
  aws s3 cp --quiet s3://$Q1_S3_BUCKET/DeadlineCloud/Manifests/$manifest /dev/stdout | jq .
done
```

 이 예제에는 다음 내용이 포함된 단일 매니페스트 파일이 있습니다.

```
{
    "hashAlg": "xxh128",
    "manifestVersion": "2023-03-03",
    "paths": [
        {
            "hash": "87cb19095dd5d78fcaf56384ef0e6241",
            "mtime": 1721147454416085,
            "path": "home/cloudshell-user/job_attachments_devguide/script.sh",
            "size": 39
        },
        {
            "hash": "af5a605a3a4e86ce7be7ac5237b51b79",
            "mtime": 1721163773582362,
            "path": "shared/projects/project2/file.txt",
            "size": 44
        }
    ],
    "totalSize": 83
}
```

 매니페스트에 [GetJob 작업을](https://docs.aws.amazon.com/deadline-cloud/latest/APIReference/API_GetJob.html) 사용하여가 "/"`rootPath`인지 확인합니다.

```
aws deadline get-job --farm-id $FARM_ID --queue-id $QUEUE1_ID --job-id $JOB_ID --query 'attachments.manifests[*]'
```

 입력 파일 세트의 루트 경로는 항상 해당 파일의 가장 긴 공통 하위 경로입니다. 작업이 Windows 대신에서 제출되었고 다른 드라이브에 있었기 때문에 공통 하위 경로가 없는 입력 파일이 있는 경우 각 드라이브에 별도의 루트 경로가 표시됩니다. 매니페스트의 경로는 항상 매니페스트의 루트 경로를 기준으로 하므로 업로드된 입력 파일은 다음과 같습니다.
+  `/home/cloudshell-user/job_attachments_devguide/script.sh` - 작업 번들의 스크립트 파일입니다.
+  `/shared/projects/project2/file.txt` - 대기열에 필요한 `SHARED` 파일 시스템 위치 목록에 **없는** `WSAll` 스토리지 프로파일의 파일 시스템 위치에 있는 파일입니다`Q1`.

파일 시스템 위치`FSCommon`(`/shared/common/file.txt`) 및 `FS1` (`/shared/projects/project1/file.txt`)의 파일은 목록에 없습니다. 이는 이러한 파일 시스템 위치가 `WSAll` 스토리지 프로파일`SHARED`에 있고 둘 다 대기열의 필수 파일 시스템 위치 목록에 있기 때문입니다`Q1`.

[GetStorageProfileForQueue 작업을](https://docs.aws.amazon.com/deadline-cloud/latest/APIReference/API_GetStorageProfileForQueue.html) 사용하여 특정 스토리지 프로파일과 함께 제출된 작업에 `SHARED` 대해 고려되는 파일 시스템 위치를 볼 수 있습니다. `WSAll` 대기열의 스토리지 프로파일을 쿼리하려면 다음 명령을 `Q1` 사용합니다.

```
aws deadline get-storage-profile --farm-id $FARM_ID --storage-profile-id $WSALL_ID

aws deadline get-storage-profile-for-queue --farm-id $FARM_ID --queue-id $QUEUE1_ID --storage-profile-id $WSALL_ID
```

# 작업에서 작업 연결 입력 파일을 찾는 방법
<a name="how-jobs-find-job-attachments-input-files"></a>

 작업이 Deadline Cloud가 작업 첨부 파일을 사용하여 Amazon S3에 업로드하는 파일을 사용하려면 작업자 호스트의 파일 시스템을 통해 해당 파일을 사용할 수 있어야 합니다. 작업 [세션](https://github.com/OpenJobDescription/openjd-specifications/wiki/How-Jobs-Are-Run#sessions)이 작업자 호스트에서 실행되면 Deadline Cloud는 작업에 대한 입력 파일을 작업자 호스트의 로컬 드라이브의 임시 디렉터리에 다운로드하고 작업의 각 루트 경로에 대한 경로 매핑 규칙을 로컬 드라이브의 파일 시스템 위치에 추가합니다.

 이 예제에서는 AWS CloudShell 탭에서 Deadline Cloud 작업자 에이전트를 시작합니다. 이전에 제출한 작업의 실행을 완료한 다음 로그 디렉터리에서 작업 로그를 삭제합니다.

```
rm -rf ~/devdemo-logs/queue-*
```

 다음 스크립트는 작업 번들을 수정하여 세션의 임시 작업 디렉터리에 있는 모든 파일과 경로 매핑 규칙 파일의 내용을 표시한 다음 수정된 번들로 작업을 제출합니다.

```
# 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
# Change the value of WSALL_ID to the identifier of the WSAll storage profile
WSALL_ID=sp-00112233445566778899aabbccddeeff

deadline config set settings.storage_profile_id $WSALL_ID

cat > ~/job_attachments_devguide/script.sh << EOF
#!/bin/bash

echo "Session working directory is: \$(pwd)"
echo
echo "Contents:"
find . -type f
echo
echo "Path mapping rules file: \$1"
jq . \$1
EOF

cat > ~/job_attachments_devguide/template.yaml << EOF
specificationVersion: jobtemplate-2023-09
name: "Job Attachments Explorer"
parameterDefinitions:
- name: ScriptFile
  type: PATH
  default: script.sh
  dataFlow: IN
  objectType: FILE
steps:
- name: Step
  script:
    actions:
      onRun:
        command: /bin/bash
        args:
        - "{{Param.ScriptFile}}"
        - "{{Session.PathMappingRulesFile}}"
EOF

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

 AWS CloudShell 환경에서 작업자가 작업을 실행한 후 작업 실행 로그를 볼 수 있습니다.

```
cat demoenv-logs/queue-*/session*.log
```

로그는 세션에서 첫 번째로 발생하는 작업이 작업자에게 다운로드되는 두 개의 입력 파일임을 보여줍니다.

```
2024-07-17 01:26:37,824 INFO ==============================================
2024-07-17 01:26:37,825 INFO --------- Job Attachments Download for Job
2024-07-17 01:26:37,825 INFO ==============================================
2024-07-17 01:26:37,825 INFO Syncing inputs using Job Attachments
2024-07-17 01:26:38,116 INFO Downloaded 142.0 B / 186.0 B of 2 files (Transfer rate: 0.0 B/s)
2024-07-17 01:26:38,174 INFO Downloaded 186.0 B / 186.0 B of 2 files (Transfer rate: 733.0 B/s)
2024-07-17 01:26:38,176 INFO Summary Statistics for file downloads:
Processed 2 files totaling 186.0 B.
Skipped re-processing 0 files totaling 0.0 B.
Total processing time of 0.09752 seconds at 1.91 KB/s.
```

 다음은 작업에서 `script.sh` 실행한 출력입니다.
+  작업이 제출될 때 업로드된 입력 파일은 세션의 임시 디렉터리에서 이름이 "assetroot"로 시작하는 디렉터리 아래에 있습니다.
+  입력 파일의 경로는 작업의 입력 매니페스트()에 대한 루트 경로 대신 "assetroot" 디렉터리를 기준으로 재배치되었습니다`"/"`.
+  경로 매핑 규칙 파일에는 "assetroot" 디렉터리의 절대 경로`"/"`로 다시 매핑하는 추가 규칙이 포함되어 있습니다.

 예제: 

```
2024-07-17 01:26:38,264 INFO Output:
2024-07-17 01:26:38,267 INFO Session working directory is: /sessions/session-5b33f
2024-07-17 01:26:38,267 INFO 
2024-07-17 01:26:38,267 INFO Contents:
2024-07-17 01:26:38,269 INFO ./tmp_xdhbsdo.sh
2024-07-17 01:26:38,269 INFO ./tmpdi00052b.json
2024-07-17 01:26:38,269 INFO ./assetroot-assetroot-3751a/shared/projects/project2/file.txt
2024-07-17 01:26:38,269 INFO ./assetroot-assetroot-3751a/home/cloudshell-user/job_attachments_devguide/script.sh
2024-07-17 01:26:38,269 INFO 
2024-07-17 01:26:38,270 INFO Path mapping rules file: /sessions/session-5b33f/tmpdi00052b.json
2024-07-17 01:26:38,282 INFO {
2024-07-17 01:26:38,282 INFO   "version": "pathmapping-1.0",
2024-07-17 01:26:38,282 INFO   "path_mapping_rules": [
2024-07-17 01:26:38,282 INFO     {
2024-07-17 01:26:38,282 INFO       "source_path_format": "POSIX",
2024-07-17 01:26:38,282 INFO       "source_path": "/shared/projects/project1",
2024-07-17 01:26:38,283 INFO       "destination_path": "/mnt/projects/project1"
2024-07-17 01:26:38,283 INFO     },
2024-07-17 01:26:38,283 INFO     {
2024-07-17 01:26:38,283 INFO       "source_path_format": "POSIX",
2024-07-17 01:26:38,283 INFO       "source_path": "/shared/common",
2024-07-17 01:26:38,283 INFO       "destination_path": "/mnt/common"
2024-07-17 01:26:38,283 INFO     },
2024-07-17 01:26:38,283 INFO     {
2024-07-17 01:26:38,283 INFO       "source_path_format": "POSIX",
2024-07-17 01:26:38,283 INFO       "source_path": "/",
2024-07-17 01:26:38,283 INFO       "destination_path": "/sessions/session-5b33f/assetroot-assetroot-3751a"
2024-07-17 01:26:38,283 INFO     }
2024-07-17 01:26:38,283 INFO   ]
2024-07-17 01:26:38,283 INFO }
```

**참고**  
 제출하는 작업에 서로 다른 루트 경로를 가진 여러 매니페스트가 있는 경우 각 루트 경로에 대해 서로 다른 "assetroot"-named 디렉터리가 있습니다.

 입력 파일, 디렉터리 또는 파일 시스템 위치 중 하나의 재배치된 파일 시스템 위치를 참조해야 하는 경우 작업에서 경로 매핑 규칙 파일을 처리하고 재매핑을 직접 수행하거나 작업 번들의 작업 템플릿에 `PATH` 유형 작업 파라미터를 추가하고 해당 파라미터의 값으로 재매핑해야 하는 값을 전달할 수 있습니다. 예를 들어 다음 예제에서는 이러한 작업 파라미터 중 하나를 갖도록 작업 번들을 수정한 다음 파일 시스템 위치가 값으로 인 작업을 제출합니다`/shared/projects/project2`.

```
cat > ~/job_attachments_devguide/template.yaml << EOF
specificationVersion: jobtemplate-2023-09
name: "Job Attachments Explorer"
parameterDefinitions:
- name: LocationToRemap
  type: PATH
steps:
- name: Step
  script:
    actions:
      onRun:
        command: /bin/echo
        args:
        - "The location of {{RawParam.LocationToRemap}} in the session is {{Param.LocationToRemap}}"
EOF

deadline bundle submit --farm-id $FARM_ID --queue-id $QUEUE1_ID job_attachments_devguide/ \
  -p LocationToRemap=/shared/projects/project2
```

 이 작업의 실행에 대한 로그 파일에는 다음과 같은 출력이 포함됩니다.

```
2024-07-17 01:40:35,283 INFO Output:
2024-07-17 01:40:35,284 INFO The location of /shared/projects/project2 in the session is /sessions/session-5b33f/assetroot-assetroot-3751a
```

# 작업에서 출력 파일 가져오기
<a name="getting-output-files-from-a-job"></a>

이 예제는 Deadline Cloud가 작업이 생성하는 출력 파일을 식별하는 방법, Amazon S3에 해당 파일을 업로드할지 여부, 워크스테이션에서 해당 출력 파일을 가져올 수 있는 방법을 보여줍니다.

 이 예제에서는 `job_attachments_devguide_output` 작업 번들 대신 `job_attachments_devguide` 작업 번들을 사용합니다. 먼저 Deadline Cloud 샘플 GitHub 리포지토리의 복제본에서 AWS CloudShell 환경의 번들 사본을 만듭니다.

```
cp -r deadline-cloud-samples/job_bundles/job_attachments_devguide_output ~/
```

 이 작업 번들과 `job_attachments_devguide` 작업 번들의 중요한 차이점은 작업 템플릿에 새 작업 파라미터를 추가하는 것입니다.

```
...
parameterDefinitions:
...
- name: OutputDir
  type: PATH
  objectType: DIRECTORY
  dataFlow: OUT
  default: ./output_dir
  description: This directory contains the output for all steps.
...
```

 파라미터의 `dataFlow` 속성에는 값이 있습니다`OUT`. Deadline Cloud는 또는 값이 있는 `dataFlow` 작업 파라미터의 값을 작업의 출력`OUT``INOUT`으로 사용합니다. 이러한 종류의 작업 파라미터에 값으로 전달된 파일 시스템 위치가 작업을 실행하는 작업자의 로컬 파일 시스템 위치로 다시 매핑되는 경우 Deadline Cloud는 해당 위치에서 새 파일을 찾아 작업 출력으로 Amazon S3에 업로드합니다.

 작동 방식을 확인하려면 먼저 AWS CloudShell 탭에서 Deadline Cloud 작업자 에이전트를 시작합니다. 이전에 제출한 작업의 실행을 완료합니다. 그런 다음 로그 디렉터리에서 작업 로그를 삭제합니다.

```
rm -rf ~/devdemo-logs/queue-*
```

 그런 다음이 작업 번들을 사용하여 작업을 제출합니다. CloudShell에서 실행 중인 작업자를 실행한 후 로그를 확인합니다.

```
# 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
# Change the value of WSALL_ID to the identifier of the WSAll storage profile
WSALL_ID=sp-00112233445566778899aabbccddeeff

deadline config set settings.storage_profile_id $WSALL_ID

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

 로그는 파일이 출력으로 감지되어 Amazon S3에 업로드되었음을 보여줍니다.

```
2024-07-17 02:13:10,873 INFO ----------------------------------------------
2024-07-17 02:13:10,873 INFO Uploading output files to Job Attachments
2024-07-17 02:13:10,873 INFO ----------------------------------------------
2024-07-17 02:13:10,873 INFO Started syncing outputs using Job Attachments
2024-07-17 02:13:10,955 INFO Found 1 file totaling 117.0 B in output directory: /sessions/session-7efa/assetroot-assetroot-3751a/output_dir
2024-07-17 02:13:10,956 INFO Uploading output manifest to DeadlineCloud/Manifests/farm-0011/queue-2233/job-4455/step-6677/task-6677-0/2024-07-17T02:13:10.835545Z_sessionaction-8899-1/c6808439dfc59f86763aff5b07b9a76c_output
2024-07-17 02:13:10,988 INFO Uploading 1 output file to S3: s3BucketName/DeadlineCloud/Data
2024-07-17 02:13:11,011 INFO Uploaded 117.0 B / 117.0 B of 1 file (Transfer rate: 0.0 B/s)
2024-07-17 02:13:11,011 INFO Summary Statistics for file uploads:
Processed 1 file totaling 117.0 B.
Skipped re-processing 0 files totaling 0.0 B.
Total processing time of 0.02281 seconds at 5.13 KB/s.
```

 또한 로그는 Deadline Cloud가 대기열의 작업 첨부 파일에서 사용하도록 구성된 Amazon S3 버킷에 새 매니페스트 객체를 생성했음을 보여줍니다`Q1`. 매니페스트 객체의 이름은 출력을 생성한 작업의 팜, 대기열, 작업, 단계, 작업, 타임스탬프 및 `sessionaction` 식별자에서 파생됩니다. 이 매니페스트 파일을 다운로드하여 Deadline Cloud가이 작업에 대한 출력 파일을 배치한 위치를 확인합니다.

```
# 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 '"'
)

# Fill this in with the object name from your log
OBJECT_KEY="DeadlineCloud/Manifests/..."

aws s3 cp --quiet s3://$Q1_S3_BUCKET/$OBJECT_KEY /dev/stdout | jq .
```

 매니페스트는 다음과 같습니다.

```
{
  "hashAlg": "xxh128",
  "manifestVersion": "2023-03-03",
  "paths": [
    {
      "hash": "34178940e1ef9956db8ea7f7c97ed842",
      "mtime": 1721182390859777,
      "path": "output_dir/output.txt",
      "size": 117
    }
  ],
  "totalSize": 117
}
```

 이는 작업 입력 파일이 저장되는 것과 동일한 방식으로 출력 파일의 콘텐츠가 Amazon S3에 저장됨을 보여줍니다. 입력 파일과 마찬가지로 출력 파일은 파일의 해시와 접두사가 포함된 객체 이름과 함께 S3에 저장됩니다`DeadlineCloud/Data`.

```
$ aws s3 ls --recursive s3://$Q1_S3_BUCKET | grep 34178940e1ef9956db8ea7f7c97ed842
2024-07-17 02:13:11        117 DeadlineCloud/Data/34178940e1ef9956db8ea7f7c97ed842.xxh128
```

 Deadline Cloud 모니터 또는 Deadline Cloud CLI를 사용하여 워크스테이션에 작업 출력을 다운로드할 수 있습니다.

```
deadline job download-output --farm-id $FARM_ID --queue-id $QUEUE1_ID --job-id $JOB_ID
```

 제출된 `OutputDir` 작업의 작업 파라미터 값은 `./output_dir`이므로 출력은 작업 번들 디렉터리 `output_dir` 내에서 라는 디렉터리에 다운로드됩니다. 절대 경로 또는 다른 상대 위치를의 값으로 지정한 경우 `OutputDir`출력 파일이 대신 해당 위치에 다운로드됩니다.

```
$ deadline job download-output --farm-id $FARM_ID --queue-id $QUEUE1_ID --job-id $JOB_ID
Downloading output from Job 'Job Attachments Explorer: Output'

Summary of files to download:
    /home/cloudshell-user/job_attachments_devguide_output/output_dir/output.txt (1 file)

You are about to download files which may come from multiple root directories. Here are a list of the current root directories:
[0] /home/cloudshell-user/job_attachments_devguide_output
> Please enter the index of root directory to edit, y to proceed without changes, or n to cancel the download (0, y, n) [y]: 

Downloading Outputs  [####################################]  100%
Download Summary:
    Downloaded 1 files totaling 117.0 B.
    Total download time of 0.14189 seconds at 824.0 B/s.
    Download locations (total file counts):
        /home/cloudshell-user/job_attachments_devguide_output (1 file)
```

# 종속 단계의 단계에서 파일 사용
<a name="using-files-output-from-a-step-in-a-dependent-step"></a>

이 예제는 작업의 한 단계가 동일한 작업에서 의존하는 단계에서 출력에 액세스하는 방법을 보여줍니다.

 한 단계의 출력을 다른 단계에서 사용할 수 있도록 Deadline Cloud는 세션에서 작업을 실행하기 전에 해당 출력을 다운로드하는 추가 작업을 세션에 추가합니다. 출력을 사용해야 하는 단계의 종속성으로 해당 단계를 선언하여에서 출력을 다운로드할 단계를 지정합니다.

이 예제에서는 `job_attachments_devguide_output` 작업 번들을 사용합니다. 먼저 Deadline Cloud 샘플 GitHub 리포지토리의 복제본에서 AWS CloudShell 환경을 복사합니다. 기존 단계 이후에만 실행되고 해당 단계의 출력을 사용하는 종속 단계를 추가하도록 수정합니다.

```
cp -r deadline-cloud-samples/job_bundles/job_attachments_devguide_output ~/

cat >> job_attachments_devguide_output/template.yaml << EOF
- name: DependentStep
  dependencies:
  - dependsOn: Step
  script:
    actions:
      onRun:
        command: /bin/cat
        args:
        - "{{Param.OutputDir}}/output.txt"
EOF
```

 이 수정된 작업 번들로 생성된 작업은 두 개의 개별 세션으로 실행되며, 하나는 "Step" 단계의 작업에 대한 세션이고 다른 하나는 "DependentStep" 단계의 작업에 대한 세션입니다.

먼저 CloudShell 탭에서 Deadline Cloud 작업자 에이전트를 시작합니다. 이전에 제출한 작업의 실행을 완료한 다음 로그 디렉터리에서 작업 로그를 삭제합니다.

```
rm -rf ~/devdemo-logs/queue-*
```

 다음으로 수정된 작업 번들을 사용하여 `job_attachments_devguide_output` 작업을 제출합니다. CloudShell 환경의 작업자에서 실행이 완료될 때까지 기다립니다. 두 세션의 로그를 살펴봅니다.

```
# 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
# Change the value of WSALL_ID to the identifier of the WSAll storage profile
WSALL_ID=sp-00112233445566778899aabbccddeeff

deadline config set settings.storage_profile_id $WSALL_ID

deadline bundle submit --farm-id $FARM_ID --queue-id $QUEUE1_ID ./job_attachments_devguide_output

# Wait for the job to finish running, and then:

cat demoenv-logs/queue-*/session-*
```

 라는 단계의 작업에 대한 세션 로그에는 두 `DependentStep`가지 별도의 다운로드 작업이 실행됩니다.

```
2024-07-17 02:52:05,666 INFO ==============================================
2024-07-17 02:52:05,666 INFO --------- Job Attachments Download for Job
2024-07-17 02:52:05,667 INFO ==============================================
2024-07-17 02:52:05,667 INFO Syncing inputs using Job Attachments
2024-07-17 02:52:05,928 INFO Downloaded 207.0 B / 207.0 B of 1 file (Transfer rate: 0.0 B/s)
2024-07-17 02:52:05,929 INFO Summary Statistics for file downloads:
Processed 1 file totaling 207.0 B.
Skipped re-processing 0 files totaling 0.0 B.
Total processing time of 0.03954 seconds at 5.23 KB/s.

2024-07-17 02:52:05,979 INFO 
2024-07-17 02:52:05,979 INFO ==============================================
2024-07-17 02:52:05,979 INFO --------- Job Attachments Download for Step
2024-07-17 02:52:05,979 INFO ==============================================
2024-07-17 02:52:05,980 INFO Syncing inputs using Job Attachments
2024-07-17 02:52:06,133 INFO Downloaded 117.0 B / 117.0 B of 1 file (Transfer rate: 0.0 B/s)
2024-07-17 02:52:06,134 INFO Summary Statistics for file downloads:
Processed 1 file totaling 117.0 B.
Skipped re-processing 0 files totaling 0.0 B.
Total processing time of 0.03227 seconds at 3.62 KB/s.
```

 첫 번째 작업은 "Step"이라는 단계에서 사용하는 `script.sh` 파일을 다운로드합니다. 두 번째 작업은 해당 단계에서 출력을 다운로드합니다. Deadline Cloud는 해당 단계에서 생성된 출력 매니페스트를 입력 매니페스트로 사용하여 다운로드할 파일을 결정합니다.

 동일한 로그의 후반부에서 "DependentStep"이라는 단계의 출력을 볼 수 있습니다.

```
2024-07-17 02:52:06,213 INFO Output:
2024-07-17 02:52:06,216 INFO Script location: /sessions/session-5b33f/assetroot-assetroot-3751a/script.sh
```