Author Topic: [Python API] XSI Submission - API Crash  (Read 10064 times)

pboucher

  • VFX Geek
  • Full Member
  • ***
  • Posts: 24
    • XSIBlog
[Python API] XSI Submission - API Crash
« on: October 26, 2007, 06:03:09 PM »
Starting to write a custom submission for XSI (in Python) and I get a traceback that seems to stem from API internals...

The code is pretty much copied from the Perl example in the developer docs but ported for Python/XSI


import sys
sys.path.append(r'C:\Program Files\pfx\qube\api\python\qb')
import qb
xsi = Application
log = xsi.LogMessage

fn = xsi.ActiveProject.ActiveScene.FileName.Value
log(fn)

env = {}
frames = qb.genframes('1-100')
data = {
   'env': env,
   'cmdline': "echo testing"
}
job = {
   'name': 'Echo Test Job',
   'priority': 1,
   'prototype': 'frame',
   'branch': '/',
   'cpus': 1,
   'data': data,
   'work': frames
}

ret = qb.submit(job)
for j in ret:
   log('submitted job - id: %d\n' % j.id)


Gives the following traceback:



# ERROR : Traceback (most recent call last):
#   File "<Script Block >", line 27, in <module>
#     ret = qb.submit(job)
#   File "C:\Program Files\pfx\qube\api\python\qb\__init__.py", line 1394, in submit
#     return [Job(i) for i in _qb.submit(joblist)]
#   File "C:\Program Files\pfx\qube\api\python\qb\__init__.py", line 173, in __init__
#     self['subjobs']   = [Subjob(i)   for i in data['subjobs']]
# TypeError: expected string or Unicode object, dict found
#  - [line 27]


Scot Brew

  • Hero Member
  • *****
  • Posts: 272
    • PipelineFX
Re: Python Job Submit examples
« Reply #1 on: October 26, 2007, 07:06:14 PM »
Here are a few example job submissions for python that will work with Qube 5.2.0 on.  These examples will be included in in-line python docs for the next point release of Qube. 

Simple "cmdline" job:
myjob = qb.Job()
myjob['name']      = 'test submit'
myjob['prototype'] = 'cmdline'
myjob['package']   = {'cmdline' : 'set' }
qb.submit(myjob)     # returns a [Job()]


Simple "cmdrange" job:
myjob = qb.Job()
myjob['name']      = 'test cmdrange submit'
myjob['prototype'] = 'cmdrange'
myjob['package']   = {'cmdline' : 'echo "Frame QB_FRAME_NUMBER"',
                      'padding' : 0,
                      'range'   : '1-10',  #QubeGUI uses this if present
                     }
myjob['agenda']    = qb.genframes(myjob['package']['range'])
qb.submit(myjob)     # returns a [Job()]


Please see the in-line python documentation or the pdf on our support website (http://support.pipelinefx.com/) for more information on the classes and functions.  The QubeGUI python source code at .../qube/api/python/qb/gui/ can also be used as reference.