Created
January 26, 2019 09:38
-
-
Save paulwinex/d2c48510ff608bd30447a3cb9eeccf40 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@classmethod | |
def create_avatar_job(cls, JOB, **kwargs): | |
fake_render = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'cmd', 'fake_render.py') | |
blocks = [ | |
dict( | |
name='Block 1', | |
tasks=['Task 1', 'Task 2'], | |
capacity=1000, | |
), dict( | |
name='Block 2', | |
tasks=['Single Task'], | |
capacity=1000, | |
), dict( | |
name='Render Sequence', | |
# tasks=[('frame %s' % x) for x in range(1000)] + ['Compile Video File'], | |
frames=[0, 3], | |
capacity=250, | |
), dict( | |
name='Final BLock', | |
tasks=['Final Task'], | |
capacity=1000, | |
) | |
] | |
sec = 15 | |
if init_cgru.init(): | |
import af | |
job = af.Job(JOB.name) | |
for b in blocks: | |
block = af.Block(b['name']) | |
if b.get('tasks'): | |
for i, t in enumerate(b['tasks']): | |
task = af.Task(t) | |
task.setCommand('python3 {} -f {} -t {} -r 3'.format(fake_render, i, sec * 1000)) | |
block.tasks.append(task) | |
elif b.get('frames'): | |
st, en = b['frames'] | |
block.setNumeric(start=st, end=en) | |
block.setCommand('python3 {} -f @#@ -t {} -r 3'.format(fake_render, sec * 1000)) | |
else: | |
continue | |
block.setCapacity(b.get('capacity', 1000)) | |
job.blocks.append(block) | |
uuid, job = cls.add_meta_data(job, user_id=JOB.user.pk, uuid=str(JOB.uuid), job_type=JOB.job_type) | |
if kwargs.get('paused'): | |
job.pause() | |
job.send() | |
return uuid |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment