Task 3 – Create a Job
In this task, you will use the job API to submit a job that contains a task to execute your Bifrost graph.
By the end of this task, you will know how to submit a job to the bifrost executor.
You will use the following operations for this task:
Operation | Method + Endpoint |
---|---|
Create a new job | POST queues/{queueId}/jobs |
Step 1 - Create a job
Use Create a new job to submit your Bifrost Graph execution. Save the job id from the response for use with subsequent tasks of this walkthrough.
Notes:
- The tasks array contains the tasks that must be executed for this job. In this case, there is only one task, which is to execute a Bifrost Graph.
- The executor of the task is bifrost, because you want the job to execute a Bifrost Graph.
- The payload section contains parameters specific to the executor you select, which is bifrost in this case.
- The action attribute in the payload must be set to Evaluate because the purpose of the job is to evaluate a Bifrost Graph.
- The compound attribute in the options section of the payload is used to specify the Bifrost compound to execute. This compound comes from your Bifrost Graph.
- The definitionFiles section of the payload is used to specify the location of the file to be loaded by Bifrost. Add the Bifrost Graph file you uploaded in Task 2 using the URN found in the response to the complete upload request.
- The inputs section of the payload is used to specify the input files to download before executing the task. In this case, you must use the input file you uploaded to the scratch space in Task 2, using the URN in the response of the complete upload request.
- The ports section of the payload is used to specify the input ports for your compound as well as the job ports inside your graph. In this case you will only set the input ports specific to your compound.
- The inputFilename and inputPorts will be set to plane.usd. This is the location the input file will be downloaded to, based on the information you specified in the inputs section of the payload.
- The outputFilename and inputPorts will be set to planeWithTrees.usd. This is the port in your graph that specifies where the output file will be written.
- The amount and inputPorts will be set to 1000. This is the port in your graph that specifies the amount of trees to add to the plane.
- The executions section of the payload is used to specify parameters specific to each execution. In this case, you only have a single execution for frame 1.
- The outputs section of the executions is used to specify the output files to upload after executing the task. In this case, you will upload the output file planeWithTrees.usd to the output space under the tutorialResult output path.
- The requirements section of the task is used to specify the resource requirements for the task. In this case, you will request at least 4 CPUs and 30720 MB of memory.
Request
curl -v 'https://developer.api.autodesk.com/flow/compute/v1/queues/@default/jobs' \
-X 'POST' \
-H 'Authorization: Bearer <ACCESS_TOKEN_FROM_TASK_1>' \
-H 'Content-Type: application/json' \
-d '{
"name": "tutorial job",
"tags": [
"tutorial job"
],
"tasks": [
{
"name": "execute bifrost graph",
"type": "task",
"executor": "bifrost",
"inputs": [
{
"source": {
"uri": "urn:adsk:fc.scratch:us-west.prd:resource:@default/inputfile"
},
"target": {
"path": "plane.usd"
}
}
],
"limitations": {
"maxExecutionTimeInSeconds": 600
},
"payload": {
"action": "Evaluate",
"options": {
"compound": "User::Graphs::addTrees",
"frames": {
"start": 1,
"end": 1
}
},
"definitionFiles": [
{
"source": {
"uri": "urn:adsk:fc.scratch:us-west.prd:resource:@default/graphfile"
},
"target": {
"path": "graphfile.json"
}
}
],
"ports": {
"inputPorts": [
{
"name": "inputFilename",
"value": "plane.usd",
"type": "string"
},
{
"name": "outputFilename",
"value": "planeWithTrees.usd",
"type": "string"
},
{
"name": "amount",
"value": "1000",
"type": "float"
}
],
"jobPorts": []
},
"executions": [
{
"outputs": [
{
"source": {
"path": "planeWithTrees.usd"
},
"target": {
"name": "tutorialResult"
}
}
],
"frameId": 1
}
]
},
"requirements": {
"cpu": 4,
"memory": 30720
}
}
]
}'
Show More
Response
{
"createdAt": "0001-01-01T00:00:00.000Z",
"id": "fa8270a2-b32e-43d5-8f7b-3771fd46277e",
"name": "tutorial job",
"progress": {
"percent": 0,
"details": {
"stats": {
"tasks": {
"scheduled": 1,
"total": 1
}
}
}
},
"status": "SCHEDULED",
"tags": [
"tutorial job"
],
"updatedAt": "0001-01-01T00:00:00.000Z"
}
Show More