本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
作业捆绑包的作业模板元素
作业模板定义了运行时环境和作为 Deadline Cloud 作业的一部分运行的进程。你可以在模板中创建参数,这样它就可以用来创建只在输入值上有所不同的作业,就像编程语言中的函数一样。
当您向 Deadline Cloud 提交作业时,该任务将在应用于该队列的任何队列环境中运行。队列环境是使用 Open Job Description (OpenJD) 外部环境规范构建的。有关详细信息,请参阅 OpenJD GitHub 存储库中的环境模板
有关使用 OpenJD 作业模板创建作业的简介,请参阅在 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属性定义了使用命令的命令行自动生成的用户界面的行为,也定义了在 Autodesk Maya 等应用程序的作业提交插件中自动生成的用户界面的行为。deadline bundle gui-submit
在此示例中,用于输入BlenderSceneFile参数值的 UI 控件是一个仅显示文件的文件选择对话框。.blend
有关使用该userInteface元素的更多示例,请参阅存储库中的 gui_control_showcase
objectType和dataFlow属性控制从作业捆绑包提交作业时作业附件的行为。在本例中objectType:
FILE,and dataFlow:IN 表示的值BlenderSceneFile是作业附件的输入文件。
相比之下,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属性的更多信息,请参阅 Ope n Job Description 规范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 个任务。每个 has task 的Frame参数值都不同。要运行任务,请执行以下操作:
-
例如,嵌入式文件
data属性中的所有变量引用都会被展开--render-frame 1。 -
该
data属性的内容将写入磁盘上会话工作目录中的一个文件中。 -
任务的
onRun命令解析为,bash然后运行。location of embedded file
有关嵌入文件、会话和路径映射位置的更多信息,请参阅 Open Job Description 规范中的作业运行方式
deadline-cloud-samples/job_bundles