Message-ID: <1777615578.8783.1711698773896.JavaMail.confluence@host3.pipelinefx.com> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_8782_1487002131.1711698773895" ------=_Part_8782_1487002131.1711698773895 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html Callbacks

Callbacks

=20 Icon=20
=20

This page refers to job-specific callbacks.  For c= allbacks that are applied to all jobs see the documentation for Universal Callbacks

=20
=20
=20

A callback is Qube's mechanism to allow custom executio= n of queuing logic depending upon the events which occur during the lifetim= e of a Qube job or upon pre-defined system events.

The use of callbacks can range from sending email when a job has complet= ed, to designing complex dependency trees or direct integration with an ass= et 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:

  1. The trig= ger expression to specify when the callback should be executed.
  2. The scripting language to use for the callback.
  3. The action or code the callback will execute each time= the trigger condition is met.

C= allbacks In Detail:

Callbacks are defined as a list of one or more key/value pairs which is = appended to the job's callback list.

Python API Examples - refer to the above pages for more information

JobB waits for the= entire jobA to complete

Using the "qube" callback language
=20
frameRange =3D '1-10'
 
jobA =3D {
=09'name': 'my ribgen job',
=09'label': 'ribgenLabel',
=09'prototype': 'cmdrange',
=09'package': {
=09=09'cmdline': 'my ribgen command...'
=09},
=09'agenda': qb.genframes(frameRange),
}

jobB =3D {
=09'name': 'my render job',
=09'label': 'render',
=09'status': 'blocked',
=09'prototype': 'cmdrange',
=09'package': {
=09=09'cmdline': 'my render command...'
=09},
=09'agenda': qb.genframes(frameRange),
}

callbacks =3D [
=09{=20
=09=09'triggers': 'complete-job-ribgenLabel',
=09=09'language': 'qube',
=09=09'code': 'unblock-self'
=09}
]
jobB['callbacks'] =3D callbacks
 
qb.submit( [jobA, jobB] )
=20
Using the "python" callback language is identical to the first= example, except the callback's "language" and "code" i= s different
=20
jobA =3D {
=09.
=09.
=09.
}
 
jobB =3D {
=09.
=09.
=09.
}
 
cbCode =3D 'jobId =3D qb.jobid()\n'
cbCode +=3D 'qb.unblock(jobId)\n'

callbacks =3D [
=09{=20
=09=09'triggers': 'complete-job-ribgenLabel',
=09=09'language': 'python',
=09=09'code': cbCode
}
jobB['callbacks'] =3D callbacks
 
qb.submit( [jobA, jobB] )
=20

Each frame in JobB waits for the its corresponding frame in jobA = to complete

Using the "qube" callback language
=20
frameRange =3D '1-10'
 
jobA =3D {
=09'name': 'my ribgen job',
=09'label': 'ribgenLabel',
=09'prototype': 'cmdrange',
=09'package': {
=09=09'cmdline': 'my ribgen command...'
=09},
=09'agenda': qb.genframes(frameRange),
}

jobB =3D {
=09'name': 'my render job',
=09'label': 'render',
=09'status': 'blocked',
=09'prototype': 'cmdrange',
=09'package': {
=09=09'cmdline': 'my render command...'
=09},
=09'agenda': qb.genframes(frameRange),
}

callbacks =3D []
for work in jobB['agenda']:
=09work['status'] =3D 'blocked'
=09callbacks.append(
=09=09{=20
=09=09=09'triggers': 'complete-work-ribgenLabel-%s' % work['name'],
=09=09=09'language': 'qube',
=09=09=09'code': 'unblock-work-self',
=09=09}
=09)
]
jobB['callbacks'] =3D callbacks
 
qb.submit( [jobA, jobB] )
=20
Using the "python" callback language is identical to the first= example, except the callback's "language" and "code" i= s different
=20
jobA =3D {
=09.
=09.
=09.
}
 
jobB =3D {
=09.
=09.
=09.
}
 
callbacks =3D []
for work in jobB['agenda']:
=09work['status'] =3D 'blocked'
=09frameNumber =3D work['name']

    # the agenda item's callback should unblock both itself and the job
    cbCode =3D 'jobId =3D qb.jobid()\n'
    cbCode +=3D 'qb.workunblock("%%s:%s" %% jobId)\n' % frameNumb=
er
    cbCode +=3D 'qb.unblock(jobId)\n'

=09callbacks.append(
=09=09{=20
=09=09=09'triggers': 'complete-work-ribgenLabel-%s' % frameNumber,
=09=09=09'language': 'python',
=09=09=09'code': cbCode,
=09=09}
=09)
]
jobB['callbacks'] =3D callbacks
 
qb.submit( [jobA, jobB] )
=20

JobC waits for jobA and jobB

This can be done using any of the callback languages, the only differenc= e is the triggers value

Using the "python" callback language is identical to the first= example, except the callback's "language" and "code" i= s different
=20
jobA =3D {
=09'label': 'ribGen',
=09.
=09.
}
 
jobB =3D {
=09'label': 'render',
=09.
=09.
}
 
jobC =3D {
=09'label': 'composite'
=09.
=09.
}
 
callbacks =3D []
for work in jobC['agenda']:
=09work['status'] =3D 'blocked'
=09frameNumber =3D work['name']

    # the agenda item's callback should unblock both itself and the job
    cbCode =3D 'jobId =3D qb.jobid()\n'
    cbCode +=3D 'qb.workunblock("%%s:%s" %% jobId)\n' % frameNumb=
er
    cbCode +=3D 'qb.unblock(jobId)\n'

=09triggerStr =3D 'complete-work-ribgen-%s' % frameNumber'
=09triggerStr +=3D ' && '
=09triggerStr +=3D 'complete-work-render-%s' % frameNumber'
=09=09
=09callbacks.append(
=09=09{=20
=09=09=09'triggers': triggerStr,
=09=09=09'language': 'python',
=09=09=09'code': cbCode,
=09=09}
=09)
]
jobB['callbacks'] =3D callbacks
 
qb.submit( [jobA, jobB, jobC] )
=20

JobD waits for e= ither (jobA AND jobB) OR jobC

This is identical to the above example, except the 'triggerStr'" is= different
=20
jobA =3D {
=09'label': 'ribGen',
=09.
=09.
}
 
jobB =3D {
=09'label': 'render',
=09.
=09.
}
 
jobC =3D {
=09'label': 'composite',
=09.
=09.
}
 
jobD =3D {
=09'label': 'sendToDailies',
=09.
=09.
} 
callbacks =3D []
for work in jobD['agenda']:
=09work['status'] =3D 'blocked',
=09frameNumber =3D work['name']

    # the agenda item's callback should unblock both itself and the job
    cbCode =3D 'jobId =3D qb.jobid()\n'
    cbCode +=3D 'qb.workunblock("%%s:%s" %% jobId)\n' % frameNumb=
er
    cbCode +=3D 'qb.unblock(jobId)\n'

=09triggerSt =3D '('
=09triggerStr +=3D 'complete-work-ribgen-%s' % frameNumber'
=09triggerStr +=3D ' && '
=09triggerStr +=3D 'complete-work-render-%s' % frameNumber'
=09triggerStr +=3D ')'
 
=09triggerStr +=3D ' || '
=09triggerStr =3D 'complete-work-composite-%s' % frameNumber'
=09=09
=09callbacks.append(
=09=09{=20
=09=09=09'triggers': triggerStr,
=09=09=09'language': 'python',
=09=09=09'code': cbCode,
=09=09}
=09)
]
jobB['callbacks'] =3D callbacks
 
qb.submit( [jobA, jobB, jobC, jobD] )
=20
------=_Part_8782_1487002131.1711698773895--