Subjob Zip Files (#18)

* Transfer any uploaded zip files to subjobs instead of extracted zips

* Fix Blender naming scheme
This commit is contained in:
2023-06-15 19:21:10 -05:00
committed by GitHub
parent 78a51ffea0
commit 54ec5f0e9c
2 changed files with 9 additions and 7 deletions

View File

@@ -357,7 +357,8 @@ def add_job_handler():
logger.info(f"Import complete for {loaded_project_local_path.split(server.config['UPLOAD_FOLDER'])[-1]}") logger.info(f"Import complete for {loaded_project_local_path.split(server.config['UPLOAD_FOLDER'])[-1]}")
# process uploaded zip files # process uploaded zip files
if loaded_project_local_path.lower().endswith('.zip'): zip_path = loaded_project_local_path if loaded_project_local_path.lower().endswith('.zip') else None
if zip_path:
zip_path = loaded_project_local_path zip_path = loaded_project_local_path
work_path = os.path.dirname(zip_path) work_path = os.path.dirname(zip_path)
try: try:
@@ -387,12 +388,12 @@ def add_job_handler():
for job_data in jobs_list: for job_data in jobs_list:
try: try:
# prepare output paths # prepare output paths
output_dir = os.path.join(job_dir, job_data.get('name', None) or 'output') output_dir = os.path.join(job_dir, job_data.get('name') if len(jobs_list) > 1 else 'output')
os.makedirs(output_dir, exist_ok=True) os.makedirs(output_dir, exist_ok=True)
# get new output path in output_dir # get new output path in output_dir
job_data['output_path'] = os.path.join(output_dir, os.path.basename( job_data['output_path'] = os.path.join(output_dir, os.path.basename(
job_data.get('name', None) or job_data.get('output_path', None) or loaded_project_local_path job_data.get('output_path', None) or loaded_project_local_path
)) ))
# create & configure jobs # create & configure jobs
@@ -409,7 +410,7 @@ def add_job_handler():
# determine if we can / should split the job # determine if we can / should split the job
if server.config.get('enable_split_jobs', False) and (worker.total_frames > 1) and not worker.parent: if server.config.get('enable_split_jobs', False) and (worker.total_frames > 1) and not worker.parent:
create_subjobs(worker, job_data, loaded_project_local_path) create_subjobs(worker, job_data, zip_path or loaded_project_local_path)
RenderQueue.add_to_render_queue(worker, force_start=job_data.get('force_start', False)) RenderQueue.add_to_render_queue(worker, force_start=job_data.get('force_start', False))
make_job_ready(worker.id) make_job_ready(worker.id)

View File

@@ -40,7 +40,8 @@ class BlenderRenderWorker(BaseRenderWorker):
if self.camera: if self.camera:
cmd.extend(['--python-expr', f"import bpy;bpy.context.scene.camera = bpy.data.objects['{self.camera}'];"]) cmd.extend(['--python-expr', f"import bpy;bpy.context.scene.camera = bpy.data.objects['{self.camera}'];"])
cmd.extend(['-E', self.blender_engine, '-o', self.output_path, '-F', self.export_format]) path_without_ext = os.path.splitext(self.output_path)[0] + "_"
cmd.extend(['-E', self.blender_engine, '-o', path_without_ext, '-F', self.export_format])
# set frame range # set frame range
cmd.extend(['-s', self.start_frame, '-e', self.end_frame, '-a']) cmd.extend(['-s', self.start_frame, '-e', self.end_frame, '-a'])
@@ -121,10 +122,10 @@ class BlenderRenderWorker(BaseRenderWorker):
return most_common_ext return most_common_ext
output_dir_files = os.listdir(os.path.dirname(self.output_path)) output_dir_files = os.listdir(os.path.dirname(self.output_path))
if self.total_frames > 1 and len(output_dir_files) > 1: if self.total_frames > 1 and len(output_dir_files) > 1 and not self.parent:
logger.info("Generating preview for image sequence") logger.info("Generating preview for image sequence")
try: try:
pattern = self.output_path + "%04d" + most_common_extension(output_dir_files) pattern = os.path.splitext(self.output_path)[0] + "_%04d" + most_common_extension(output_dir_files)
image_sequence_to_video(source_glob_pattern=pattern, image_sequence_to_video(source_glob_pattern=pattern,
output_path=self.output_path + '.mov', output_path=self.output_path + '.mov',
framerate=self.scene_info['fps']) framerate=self.scene_info['fps'])