Add job polish (#63)

* Remove legacy client

* Misc cleanup

* Add message box after submission success / fail

* Use a new is_localhost method to handle localhost not including '.local'

* Code cleanup

* Fix issue where engine browser would think we're downloading forever

* Add message box after submission success / fail

* Use a new is_localhost method to handle localhost not including '.local'

* Code cleanup

* Fix issue where engine browser would think we're downloading forever

* Add pubsub messages to serverproxy_manager.py

* Add resolution, fps and renderer versions to add_job.py

* Add cameras to add_job.py

* Add message box after submission success / fail

* Use a new is_localhost method to handle localhost not including '.local'

* Code cleanup

* Fix issue where engine browser would think we're downloading forever

* Add message box after submission success / fail

* Code cleanup

* Add cameras to add_job.py

* Add dynamic engine options and output format

* Move UI work out of BG threads and add engine presubmission tasks

* Submit dynamic args when creating a new job

* Hide groups and show messagebox after submission

* Choose file when pressing New Job in main window now
This commit is contained in:
2023-11-11 07:35:56 -06:00
committed by GitHub
parent 0271abf705
commit da61bf72f8
15 changed files with 486 additions and 156 deletions
+13 -1
View File
@@ -63,7 +63,7 @@ class Blender(BaseRenderEngine):
raise FileNotFoundError(f'Python script not found: {script_path}')
raise Exception("Uncaught exception")
def get_scene_info(self, project_path, timeout=10):
def get_project_info(self, project_path, timeout=10):
scene_info = {}
try:
script_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'scripts', 'get_file_info.py')
@@ -138,6 +138,7 @@ class Blender(BaseRenderEngine):
return options
def get_detected_gpus(self):
# no longer works on 4.0
engine_output = subprocess.run([self.renderer_path(), '-E', 'help'], timeout=SUBPROCESS_TIMEOUT,
capture_output=True).stdout.decode('utf-8')
gpu_names = re.findall(r"DETECTED GPU: (.+)", engine_output)
@@ -149,6 +150,17 @@ class Blender(BaseRenderEngine):
render_engines = [x.strip() for x in engine_output.split('Blender Engine Listing:')[-1].strip().splitlines()]
return render_engines
# UI and setup
def get_options(self):
options = [
{'name': 'engine', 'options': self.supported_render_engines()},
]
return options
def perform_presubmission_tasks(self, project_path):
packed_path = self.pack_project_file(project_path, timeout=30)
return packed_path
if __name__ == "__main__":
x = Blender.get_detected_gpus()
+2 -2
View File
@@ -24,7 +24,7 @@ class BlenderRenderWorker(BaseRenderWorker):
self.__frame_percent_complete = 0.0
# Scene Info
self.scene_info = Blender(engine_path).get_scene_info(input_path)
self.scene_info = Blender(engine_path).get_project_info(input_path)
self.start_frame = int(self.scene_info.get('start_frame', 1))
self.end_frame = int(self.scene_info.get('end_frame', self.start_frame))
self.project_length = (self.end_frame - self.start_frame) + 1
@@ -140,7 +140,7 @@ class BlenderRenderWorker(BaseRenderWorker):
if __name__ == '__main__':
import pprint
x = Blender.get_scene_info('/Users/brett/Desktop/TC Previz/nallie_farm.blend')
x = Blender.get_project_info('/Users/brett/Desktop/TC Previz/nallie_farm.blend')
pprint.pprint(x)
# logging.basicConfig(format='%(asctime)s - %(message)s', datefmt='%d-%b-%y %H:%M:%S', level=logging.DEBUG)
+3 -2
View File
@@ -2,6 +2,7 @@ import json
import bpy
# Get all cameras
scene = bpy.data.scenes[0]
cameras = []
for cam_obj in bpy.data.cameras:
user_map = bpy.data.user_map(subset={cam_obj}, value_types={'OBJECT'})
@@ -12,10 +13,10 @@ for cam_obj in bpy.data.cameras:
'lens': cam_obj.lens,
'lens_unit': cam_obj.lens_unit,
'sensor_height': cam_obj.sensor_height,
'sensor_width': cam_obj.sensor_width}
'sensor_width': cam_obj.sensor_width,
'is_active': scene.camera.name_full == cam_obj.name_full}
cameras.append(cam)
scene = bpy.data.scenes[0]
data = {'cameras': cameras,
'engine': scene.render.engine,
'frame_start': scene.frame_start,
+7
View File
@@ -55,6 +55,9 @@ class BaseRenderEngine(object):
timeout=SUBPROCESS_TIMEOUT).decode('utf-8')
return help_doc
def get_project_info(self, project_path, timeout=10):
raise NotImplementedError(f"get_project_info not implemented for {cls.__name__}")
@classmethod
def get_output_formats(cls):
raise NotImplementedError(f"get_output_formats not implemented for {cls.__name__}")
@@ -62,3 +65,7 @@ class BaseRenderEngine(object):
@classmethod
def get_arguments(cls):
pass
def perform_presubmission_tasks(self, project_path):
return project_path
+2
View File
@@ -247,6 +247,8 @@ class EngineManager:
for engine in cls.supported_engines():
if extension in engine.supported_extensions:
return engine
undefined_renderer_support = [x for x in cls.supported_engines() if not x.supported_extensions]
return undefined_renderer_support[0]
if __name__ == '__main__':
+41
View File
@@ -1,3 +1,4 @@
import json
import re
from src.engines.core.base_engine import *
@@ -29,6 +30,46 @@ class FFMPEG(BaseRenderEngine):
logger.error("Failed to get FFMPEG version: {}".format(e))
return version
def get_project_info(self, project_path, timeout=10):
return self.get_video_info_ffprobe(project_path)
@staticmethod
def get_video_info_ffprobe(video_path):
try:
# Run ffprobe and parse the output as JSON
cmd = [
'ffprobe', '-v', 'quiet', '-print_format', 'json',
'-show_streams', '-select_streams', 'v', video_path
]
result = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
video_info = json.loads(result.stdout)
# Extract the necessary information
video_stream = video_info['streams'][0]
frame_rate = eval(video_stream['r_frame_rate'])
duration = float(video_stream['duration'])
width = video_stream['width']
height = video_stream['height']
# Calculate total frames (end frame)
total_frames = int(duration * frame_rate)
end_frame = total_frames - 1
# The start frame is typically 0
start_frame = 0
return {
'frame_start': start_frame,
'frame_end': end_frame,
'fps': frame_rate,
'resolution_x': width,
'resolution_y': height
}
except Exception as e:
print(f"An error occurred: {e}")
return None
def get_encoders(self):
raw_stdout = subprocess.check_output([self.renderer_path(), '-encoders'], stderr=subprocess.DEVNULL,
timeout=SUBPROCESS_TIMEOUT).decode('utf-8')