Info |
---|
This page refers to job-specific callbacks. For callbacks that are applied to all jobs see the documentation for Universal Callbacks |
A callback is Qube's mechanism to allow custom execution of queuing logic depending upon the events which occur during the lifetime of a Qube job or upon pre-defined system events.
The use of callbacks can range from sending email when a job has completed, to designing complex dependency trees or direct integration with an asset tracking system. There is also a special case that allows for delayed execution of the job, see: How to submit a job that will wait until later to run
When specifying a callback, Qube requires a little information in order to execute it properly. Each callback must include:
- The trigger expression to specify when the callback should be executed.
- The scripting language to use for the callback.
- The action or code the callback will execute each time the trigger condition is met.
Callbacks In Detail:
Callbacks are defined as a list of one or more key/value pairs which is appended to the job's callback
list.
...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
jobA = { 'label': 'ribGen', . . } jobB = { 'label': 'render', . . } jobC = { 'label': 'composite' . . } callbacks = [] for work in jobC['agenda']: work['status'] = 'blocked' frameNumber = work['name'] # the agenda item's callback should unblock both itself and the job cbCode = 'jobId = qb.jobid()\n' cbCode += 'qb.workunblock("%%s:%s" %% jobId)\n' % frameNumber cbCode += 'qb.unblock(jobId)\n' triggerStr = 'complete-work-ribgen-%s' % frameNumber' triggerStr += ' AND&& ' triggerStr += 'complete-work-render-%s' % frameNumber' callbacks.append( { 'triggers': triggerStr, 'language': 'python', 'code': cbCode, } ) ] jobB['callbacks'] = callbacks qb.submit( [jobA, jobB, jobC] ) |
...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
jobA = { 'label': 'ribGen', . . } jobB = { 'label': 'render', . . } jobC = { 'label': 'composite', . . } jobD = { 'label': 'sendToDailies', . . } callbacks = [] for work in jobD['agenda']: work['status'] = 'blocked', frameNumber = work['name'] # the agenda item's callback should unblock both itself and the job cbCode = 'jobId = qb.jobid()\n' cbCode += 'qb.workunblock("%%s:%s" %% jobId)\n' % frameNumber cbCode += 'qb.unblock(jobId)\n' triggerSt = '(' triggerStr += 'complete-work-ribgen-%s' % frameNumber' triggerStr += ' AND&& ' triggerStr += 'complete-work-render-%s' % frameNumber' triggerStr += ')' triggerStr += ' OR|| ' triggerStr = 'complete-work-composite-%s' % frameNumber' callbacks.append( { 'triggers': triggerStr, 'language': 'python', 'code': cbCode, } ) ] jobB['callbacks'] = callbacks qb.submit( [jobA, jobB, jobC, jobD] ) |