Job submission code and API cleanup (#127)

* Refactor add jobs and make add_job api only be one job (instead of a list)

* Renamed to JobImportHandler and misc cleanup

* Dont bury exceptions in server proxy post_job

* Update code to create child jobs in a cleaner manner
This commit is contained in:
2025-12-31 23:14:28 -06:00
committed by GitHub
parent e335328530
commit d8af7c878e
10 changed files with 267 additions and 357 deletions

View File

@@ -450,7 +450,7 @@ class SubmitWorker(QThread):
try:
hostname = self.window.server_input.currentText()
job_json = {'owner': psutil.Process().username() + '@' + socket.gethostname(),
'engine': self.window.engine_type.currentText().lower(),
'engine_name': self.window.engine_type.currentText().lower(),
'engine_version': self.window.engine_version_combo.currentText(),
'args': {'raw': self.window.raw_args.text(),
'export_format': self.window.file_format_combo.currentText()},
@@ -485,26 +485,26 @@ class SubmitWorker(QThread):
# process cameras into nested format
input_path = self.window.scene_file_input.text()
if selected_cameras:
job_list = []
if selected_cameras and self.window.cameras_list.count() > 1:
children_jobs = []
for cam in selected_cameras:
job_copy = copy.deepcopy(job_json)
job_copy['args']['camera'] = cam
job_copy['name'] = job_copy['name'].replace(' ', '-') + "_" + cam.replace(' ', '')
job_copy['output_path'] = job_copy['name']
job_list.append(job_copy)
else:
job_list = [job_json]
child_job_data = dict()
child_job_data['args'] = {}
child_job_data['args']['camera'] = cam
child_job_data['name'] = job_json['name'].replace(' ', '-') + "_" + cam.replace(' ', '')
child_job_data['output_path'] = child_job_data['name']
children_jobs.append(child_job_data)
job_json['child_jobs'] = children_jobs
# presubmission tasks
engine = EngineManager.engine_with_name(self.window.engine_type.currentText().lower())
input_path = engine().perform_presubmission_tasks(input_path)
# submit
err_msg = ""
result = self.window.server_proxy.post_job_to_server(file_path=input_path, job_list=job_list,
result = self.window.server_proxy.post_job_to_server(file_path=input_path, job_data=job_json,
callback=create_callback)
if not (result and result.ok):
err_msg = "Error posting job to server."
err_msg = f"Error posting job to server: {result.message}"
self.message_signal.emit(err_msg)