Combine RenderWorker creation into RenderJob creation. Misc cleanup.

This commit is contained in:
Brett Williams
2022-10-28 09:58:32 -07:00
parent 39d6e95e9a
commit 37f91c6f8a
10 changed files with 108 additions and 396 deletions

View File

@@ -48,7 +48,7 @@ def get_job_status(job_id):
def get_file_list(job_id):
found_job = RenderQueue.job_with_id(job_id)
if found_job:
job_dir = os.path.dirname(found_job.render.output_path)
job_dir = os.path.dirname(found_job.worker.output_path)
return os.listdir(job_dir)
else:
return f'Cannot find job with ID {job_id}', 400
@@ -67,9 +67,9 @@ def download_all(job_id):
found_job = RenderQueue.job_with_id(job_id)
if found_job:
output_dir = os.path.dirname(found_job.render.output_path)
output_dir = os.path.dirname(found_job.worker.output_path)
if os.path.exists(output_dir):
zip_filename = pathlib.Path(found_job.render.input_path).stem + '.zip'
zip_filename = pathlib.Path(found_job.worker.input_path).stem + '.zip'
with ZipFile(zip_filename, 'w') as zipObj:
for f in os.listdir(output_dir):
zipObj.write(filename=os.path.join(output_dir, f),
@@ -187,19 +187,16 @@ def add_job():
if client == RenderQueue.host_name:
logger.info(f"Creating job locally - {input_path}")
try:
render_job = RenderWorkerFactory.create_worker(renderer, input_path, output_path, args)
render_job.log_path = os.path.join(os.path.dirname(input_path), os.path.basename(input_path) + '.log')
render_job = RenderJob(renderer, input_path, output_path, args, priority, job_owner, client,
notify=False, custom_id=custom_id)
RenderQueue.add_to_render_queue(render_job, force_start=force_start)
return render_job.json()
except Exception as e:
err_msg = f"Error creating job: {str(e)}"
logger.exception(err_msg)
remove_job_dir()
return err_msg, 400
new_job = RenderJob(render_job, priority=priority, owner=job_owner, custom_id=custom_id)
RenderQueue.add_to_render_queue(new_job, force_start=force_start)
return new_job.json()
# client renders
elif client in RenderQueue.render_clients: