

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

# ジョブバンドルのジョブテンプレート要素
<a name="build-job-bundle-template"></a>

ジョブテンプレートは、Deadline Cloud ジョブの一部として実行されるランタイム環境とプロセスを定義します。テンプレートにパラメータを作成して、プログラミング言語の関数と同様に、入力値のみが異なるジョブを作成することができます。

Deadline Cloud にジョブを送信すると、キューに適用されたキュー環境で実行されます。キュー環境は、Open Job Description (OpenJD) 外部環境仕様を使用して構築されます。詳細については、OpenJD GitHub リポジトリの[環境テンプレート](https://github.com/OpenJobDescription/openjd-specifications/wiki/2023-09-Template-Schemas#12-environment-template)を参照してください。

OpenJD ジョブテンプレートを使用したジョブの作成の概要については、OpenJD GitHub リポジトリでの[ジョブの作成の概要](https://github.com/OpenJobDescription/openjd-specifications/wiki/Introduction-to-Creating-a-Job)」を参照してください。詳細については、[「ジョブの実行方法](https://github.com/OpenJobDescription/openjd-specifications/wiki/How-Jobs-Are-Run)」を参照してください。OpenJD GitHub リポジトリの `samples` ディレクトリの にジョブテンプレートのサンプルがあります。

ジョブテンプレートは、YAML 形式 (`template.yaml`) または JSON 形式 () で定義できます`template.json`。このセクションの例は YAML 形式で示されています。

たとえば、`blender_render`サンプルのジョブテンプレートでは、入力パラメータをファイルパス`BlenderSceneFile`として定義します。

```
- name: BlenderSceneFile
  type: PATH
  objectType: FILE
  dataFlow: IN
  userInterface:
    control: CHOOSE_INPUT_FILE
    label: Blender Scene File
    groupLabel: Render Parameters
    fileFilters:
    - label: Blender Scene Files
      patterns: ["*.blend"]
    - label: All Files
      patterns: ["*"]
  description: >
    Choose the Blender scene file to render. Use the 'Job Attachments' tab
    to add textures and other files that the job needs.
```

`userInterface` プロパティは、 `deadline bundle gui-submit` コマンドを使用するコマンドラインと、Autodesk Maya などのアプリケーションのジョブ送信プラグイン内の両方で自動的に生成されるユーザーインターフェイスの動作を定義します。

この例では、 `BlenderSceneFile`パラメータの値を入力するための UI ウィジェットは、ファイルのみを表示する`.blend`ファイル選択ダイアログです。

![OpenJD ジョブテンプレートのシーンファイルパラメータを入力するためのユーザーインターフェイスウィジェット。](http://docs.aws.amazon.com/ja_jp/deadline-cloud/latest/developerguide/images/blender_submit_scene_file_widget.png)


`userInteface` 要素を使用するその他の例については、GitHub の [deadline-cloud-samples](https://github.com/aws-deadline/deadline-cloud-samples/tree/mainline) リポジトリの [gui\_control\_showcase](https://github.com/aws-deadline/deadline-cloud-samples/tree/mainline/job_bundles/gui_control_showcase) サンプルを参照してください。

`objectType` および `dataFlow`プロパティは、ジョブバンドルからジョブを送信するときのジョブアタッチメントの動作を制御します。この場合、 `objectType: FILE`と `BlenderSceneFile`は、 の値がジョブアタッチメントの入力ファイルである`dataFlow:IN`ことを意味します。

対照的に、 `OutputDir`パラメータの定義には `objectType: DIRECTORY`と があります`dataFlow: OUT`。

```
- name: OutputDir
  type: PATH
  objectType: DIRECTORY
  dataFlow: OUT
  userInterface:
    control: CHOOSE_DIRECTORY
    label: Output Directory
    groupLabel: Render Parameters
  default: "./output"
  description: Choose the render output directory.
```

`OutputDir` パラメータの値は、ジョブが出力ファイルを書き込むディレクトリとしてジョブアタッチメントによって使用されます。

`objectType` および `dataFlow`プロパティの詳細については、[Open Job Description 仕様](https://github.com/OpenJobDescription/openjd-specifications)の[JobPathParameterDefinition](https://github.com/OpenJobDescription/openjd-specifications/wiki/2023-09-Template-Schemas#22-jobpathparameterdefinition)」を参照してください。

残りの`blender_render`ジョブテンプレートサンプルでは、ジョブのワークフローを単一のステップとして定義し、アニメーションの各フレームを個別のタスクとしてレンダリングします。

```
steps:
- name: RenderBlender
  parameterSpace:
    taskParameterDefinitions:
    - name: Frame
      type: INT
      range: "{{Param.Frames}}"
  script:
    actions:
      onRun:
        command: bash
        # Note: {{Task.File.Run}} is a variable that expands to the filename on the worker host's
        # disk where the contents of the 'Run' embedded file, below, is written.
        args: ['{{Task.File.Run}}']
    embeddedFiles:
      - name: Run
        type: TEXT
        data: |
          # Configure the task to fail if any individual command fails.
          set -xeuo pipefail

          mkdir -p '{{Param.OutputDir}}'

          blender --background '{{Param.BlenderSceneFile}}' \
                  --render-output '{{Param.OutputDir}}/{{Param.OutputPattern}}' \
                  --render-format {{Param.Format}} \
                  --use-extension 1 \
                  --render-frame {{Task.Param.Frame}}
```

たとえば、 `Frames`パラメータの値が の場合`1-10`、10 個のタスクを定義します。タスクごとに `Frame`パラメータの値が異なります。タスクを実行するには:

1. 埋め込みファイルの `data`プロパティのすべての変数参照が展開されます。たとえば、 です`--render-frame 1`。

1. `data` プロパティの内容は、ディスク上のセッション作業ディレクトリのファイルに書き込まれます。

1. タスクの `onRun` コマンドは に解決され`bash {{location of embedded file}}`、実行されます。

埋め込みファイル、セッション、パスマップされた場所の詳細については、[Open Job Description 仕様](https://github.com/OpenJobDescription/openjd-specifications/wiki/How-Jobs-Are-Run)の[「How jobs are run](https://github.com/OpenJobDescription/openjd-specifications/wiki/How-Jobs-Are-Run)」を参照してください。

deadline[deadline-cloud-samples/job\_bundles](https://github.com/aws-deadline/deadline-cloud-samples/tree/mainline/job_bundles) リポジトリには、ジョブテンプレートの例と、Open Job Descriptions 仕様で提供されている[テンプレートのサンプル](https://github.com/OpenJobDescription/openjd-specifications/tree/mainline/samples)が他にもあります。