More jobs API cleanup

This commit is contained in:
Brett Williams
2026-06-06 08:09:45 -05:00
parent 5e154b6bab
commit 62e4a214e1
9 changed files with 31 additions and 31 deletions
+3 -3
View File
@@ -95,7 +95,7 @@ def main():
new_job = {"name": job_name, "engine_name": args.engine} new_job = {"name": job_name, "engine_name": args.engine}
try: try:
response = found_proxy.post_job_to_server(file_path, new_job) response = found_proxy.create_job(file_path, new_job)
except Exception as e: except Exception as e:
print(f"Error creating job: {e}") print(f"Error creating job: {e}")
exit(1) exit(1)
@@ -113,7 +113,7 @@ def main():
while percent_complete < 1.0: while percent_complete < 1.0:
# add checks for errors # add checks for errors
time.sleep(1) time.sleep(1)
running_job_data = found_proxy.get_job_info(job_id) running_job_data = found_proxy.get_job(job_id)
percent_complete = running_job_data['percent_complete'] percent_complete = running_job_data['percent_complete']
sys.stdout.write("\x1b[1A") # Move up 1 sys.stdout.write("\x1b[1A") # Move up 1
sys.stdout.write("\x1b[0J") # Clear from cursor to end of screen (optional) sys.stdout.write("\x1b[0J") # Clear from cursor to end of screen (optional)
@@ -128,4 +128,4 @@ def main():
if __name__ == "__main__": if __name__ == "__main__":
main() main()
+6 -6
View File
@@ -45,7 +45,7 @@ Response:
Known callers: Known callers:
- `RenderServerProxy.get_all_jobs()` - `RenderServerProxy.get_jobs()`
- `src/ui/main_window.py` - `src/ui/main_window.py`
### `GET /api/jobs/long_poll` ### `GET /api/jobs/long_poll`
@@ -66,7 +66,7 @@ Responses:
Known callers: Known callers:
- `RenderServerProxy.get_all_jobs()` through the background cache updater. - `RenderServerProxy.get_jobs()` through the background cache updater.
### `GET /api/jobs/status/<status_val>` ### `GET /api/jobs/status/<status_val>`
@@ -92,7 +92,7 @@ Returns one job as JSON.
Known callers: Known callers:
- `RenderServerProxy.get_job_info()` - `RenderServerProxy.get_job()`
- `add_job.py` - `add_job.py`
- `src/ui/main_window.py` - `src/ui/main_window.py`
- `src/distributed_job_manager.py` - `src/distributed_job_manager.py`
@@ -112,7 +112,7 @@ Returns a list of output filenames for the job.
Known callers: Known callers:
- `RenderServerProxy.get_job_files_list()` - `RenderServerProxy.get_job_files()`
- `src/utilities/server_helper.py` - `src/utilities/server_helper.py`
### `GET /api/jobs/<job_id>/download` ### `GET /api/jobs/<job_id>/download`
@@ -201,7 +201,7 @@ Responses:
Known callers: Known callers:
- `RenderServerProxy.post_job_to_server()` - `RenderServerProxy.create_job()`
- `add_job.py` - `add_job.py`
- `src/ui/add_job_window.py` - `src/ui/add_job_window.py`
- `src/distributed_job_manager.py` - `src/distributed_job_manager.py`
@@ -298,7 +298,7 @@ Returns a multi-server shaped status payload with the local server populated.
Known callers: Known callers:
- `RenderServerProxy.get_data()` - `RenderServerProxy.get_full_status()`
- `dashboard.py` - `dashboard.py`
Review note: this currently reports only the local server. The response shape Review note: this currently reports only the local server. The response shape
+5 -5
View File
@@ -282,7 +282,7 @@
}</code></pre> }</code></pre>
<p>Known callers:</p> <p>Known callers:</p>
<ul class="callers"> <ul class="callers">
<li><code>RenderServerProxy.get_all_jobs()</code></li> <li><code>RenderServerProxy.get_jobs()</code></li>
<li><code>src/ui/main_window.py</code></li> <li><code>src/ui/main_window.py</code></li>
</ul> </ul>
</article> </article>
@@ -306,7 +306,7 @@
<article class="endpoint"> <article class="endpoint">
<div class="endpoint-header"><span class="method get">GET</span><span class="path">/api/jobs/&lt;job_id&gt;</span></div> <div class="endpoint-header"><span class="method get">GET</span><span class="path">/api/jobs/&lt;job_id&gt;</span></div>
<p>Returns one job as JSON.</p> <p>Returns one job as JSON.</p>
<p>Known callers include <code>RenderServerProxy.get_job_info()</code>, <code>add_job.py</code>, <code>src/ui/main_window.py</code>, <code>src/distributed_job_manager.py</code>, and <code>tests/job_creation_tests.py</code>.</p> <p>Known callers include <code>RenderServerProxy.get_job()</code>, <code>add_job.py</code>, <code>src/ui/main_window.py</code>, <code>src/distributed_job_manager.py</code>, and <code>tests/job_creation_tests.py</code>.</p>
</article> </article>
<article class="endpoint"> <article class="endpoint">
@@ -317,7 +317,7 @@
<article class="endpoint"> <article class="endpoint">
<div class="endpoint-header"><span class="method get">GET</span><span class="path">/api/jobs/&lt;job_id&gt;/files</span></div> <div class="endpoint-header"><span class="method get">GET</span><span class="path">/api/jobs/&lt;job_id&gt;/files</span></div>
<p>Returns a list of output filenames for the job.</p> <p>Returns a list of output filenames for the job.</p>
<p>Known callers: <code>RenderServerProxy.get_job_files_list()</code> and <code>src/utilities/server_helper.py</code>.</p> <p>Known callers: <code>RenderServerProxy.get_job_files()</code> and <code>src/utilities/server_helper.py</code>.</p>
</article> </article>
<article class="endpoint"> <article class="endpoint">
@@ -365,7 +365,7 @@
<tr><td><code>child_jobs</code></td><td>Optional subjob definitions.</td></tr> <tr><td><code>child_jobs</code></td><td>Optional subjob definitions.</td></tr>
<tr><td><code>local_path</code></td><td>Local file path used when posting to localhost.</td></tr> <tr><td><code>local_path</code></td><td>Local file path used when posting to localhost.</td></tr>
</table> </table>
<p>Known callers include <code>RenderServerProxy.post_job_to_server()</code>, <code>add_job.py</code>, <code>src/ui/add_job_window.py</code>, <code>src/distributed_job_manager.py</code>, and integration tests.</p> <p>Known callers include <code>RenderServerProxy.create_job()</code>, <code>add_job.py</code>, <code>src/ui/add_job_window.py</code>, <code>src/distributed_job_manager.py</code>, and integration tests.</p>
</article> </article>
<article class="endpoint"> <article class="endpoint">
@@ -414,7 +414,7 @@
<article class="endpoint"> <article class="endpoint">
<div class="endpoint-header"><span class="method get">GET</span><span class="path">/api/full_status</span></div> <div class="endpoint-header"><span class="method get">GET</span><span class="path">/api/full_status</span></div>
<p>Returns a multi-server shaped status payload with the local server populated. Used by <code>RenderServerProxy.get_data()</code> and <code>dashboard.py</code>.</p> <p>Returns a multi-server shaped status payload with the local server populated. Used by <code>RenderServerProxy.get_full_status()</code> and <code>dashboard.py</code>.</p>
<div class="note">The response shape suggests an intended future aggregation point, but it currently reports only the local server.</div> <div class="note">The response shape suggests an intended future aggregation point, but it currently reports only the local server.</div>
</article> </article>
+5 -5
View File
@@ -158,12 +158,12 @@ class RenderServerProxy:
# Get System Info: # Get System Info:
# -------------------------------------------- # --------------------------------------------
def get_all_jobs(self, timeout=5, ignore_token=False): def get_jobs(self, timeout=5, ignore_token=False):
if not self.__update_in_background or ignore_token: if not self.__update_in_background or ignore_token:
self.__update_job_cache(timeout, ignore_token) self.__update_job_cache(timeout, ignore_token)
return self.__jobs_cache.copy() if self.__jobs_cache else None return self.__jobs_cache.copy() if self.__jobs_cache else None
def get_data(self, timeout=5): def get_full_status(self, timeout=5):
return self.request_data('full_status', timeout=timeout) return self.request_data('full_status', timeout=timeout)
def get_status(self): def get_status(self):
@@ -180,17 +180,17 @@ class RenderServerProxy:
# Get Job Info: # Get Job Info:
# -------------------------------------------- # --------------------------------------------
def get_job_info(self, job_id, timeout=5): def get_job(self, job_id, timeout=5):
return self.request_data(f'jobs/{job_id}', timeout=timeout) return self.request_data(f'jobs/{job_id}', timeout=timeout)
def get_job_files_list(self, job_id): def get_job_files(self, job_id):
return self.request_data(f'jobs/{job_id}/files') return self.request_data(f'jobs/{job_id}/files')
# -------------------------------------------- # --------------------------------------------
# Job Lifecycle: # Job Lifecycle:
# -------------------------------------------- # --------------------------------------------
def post_job_to_server(self, file_path: Path, job_data, callback=None): def create_job(self, file_path: Path, job_data, callback=None):
""" """
Posts a job to the server. Posts a job to the server.
+2 -2
View File
@@ -172,7 +172,7 @@ class DistributedJobManager:
subjob_id = child_key.split('@')[0] subjob_id = child_key.split('@')[0]
subjob_hostname = child_key.split('@')[-1] subjob_hostname = child_key.split('@')[-1]
subjob_data = RenderServerProxy(subjob_hostname).get_job_info(subjob_id) subjob_data = RenderServerProxy(subjob_hostname).get_job(subjob_id)
if not subjob_data: if not subjob_data:
logger.warning(f"No response from {subjob_hostname}") logger.warning(f"No response from {subjob_hostname}")
parent_job.children[child_key]['download_status'] = f'error: No response from {subjob_hostname}' parent_job.children[child_key]['download_status'] = f'error: No response from {subjob_hostname}'
@@ -260,7 +260,7 @@ class DistributedJobManager:
subjob['engine_version'] = parent_worker.engine_version subjob['engine_version'] = parent_worker.engine_version
logger.debug(f"Posting subjob with frames {subjob['start_frame']}-" logger.debug(f"Posting subjob with frames {subjob['start_frame']}-"
f"{subjob['end_frame']} to {server_hostname}") f"{subjob['end_frame']} to {server_hostname}")
post_results = RenderServerProxy(server_hostname).post_job_to_server( post_results = RenderServerProxy(server_hostname).create_job(
file_path=project_path, job_data=subjob) file_path=project_path, job_data=subjob)
return post_results return post_results
+2 -2
View File
@@ -608,8 +608,8 @@ class SubmitWorker(QThread):
input_path = Path(latest_engine.perform_presubmission_tasks(input_path)) input_path = Path(latest_engine.perform_presubmission_tasks(input_path))
# submit # submit
err_msg = "" err_msg = ""
result = self.window.server_proxy.post_job_to_server(file_path=input_path, job_data=job_json, result = self.window.server_proxy.create_job(file_path=input_path, job_data=job_json,
callback=create_callback) callback=create_callback)
if not (result and result.ok): if not (result and result.ok):
err_msg = f"Error posting job to server: {result.text}" err_msg = f"Error posting job to server: {result.text}"
+4 -4
View File
@@ -563,7 +563,7 @@ class MainWindow(QMainWindow):
return return
if len(job_ids) == 1: if len(job_ids) == 1:
job = next((job for job in self.current_server_proxy.get_all_jobs() if job.get('id') == job_ids[0]), None) job = next((job for job in self.current_server_proxy.get_jobs() if job.get('id') == job_ids[0]), None)
if job: if job:
display_name = job.get('name', os.path.basename(job.get('input_path', ''))) display_name = job.get('name', os.path.basename(job.get('input_path', '')))
message = f"Are you sure you want to stop job: {display_name}?" message = f"Are you sure you want to stop job: {display_name}?"
@@ -592,7 +592,7 @@ class MainWindow(QMainWindow):
return return
if len(job_ids) == 1: if len(job_ids) == 1:
job = next((job for job in self.current_server_proxy.get_all_jobs() if job.get('id') == job_ids[0]), None) job = next((job for job in self.current_server_proxy.get_jobs() if job.get('id') == job_ids[0]), None)
if job: if job:
display_name = job.get('name', os.path.basename(job.get('input_path', ''))) display_name = job.get('name', os.path.basename(job.get('input_path', '')))
message = f"Are you sure you want to delete the job:\n{display_name}?" message = f"Are you sure you want to delete the job:\n{display_name}?"
@@ -627,7 +627,7 @@ class MainWindow(QMainWindow):
return return
for job_id in job_ids: for job_id in job_ids:
job_info = self.current_server_proxy.get_job_info(job_id) job_info = self.current_server_proxy.get_job(job_id)
path = os.path.dirname(job_info['output_path']) path = os.path.dirname(job_info['output_path'])
launch_url(path) launch_url(path)
@@ -666,7 +666,7 @@ class BackgroundUpdater(QThread):
ZeroconfServer.get_hostname_properties(x)['api_version'] == API_VERSION] ZeroconfServer.get_hostname_properties(x)['api_version'] == API_VERSION]
if self.window.current_server_proxy: if self.window.current_server_proxy:
self.window.job_data[self.window.current_server_proxy.hostname] = \ self.window.job_data[self.window.current_server_proxy.hostname] = \
self.window.current_server_proxy.get_all_jobs(ignore_token=False) self.window.current_server_proxy.get_jobs(ignore_token=False)
self.needs_update = False self.needs_update = False
self.updated_signal.emit() self.updated_signal.emit()
time.sleep(0.05) time.sleep(0.05)
+1 -1
View File
@@ -17,7 +17,7 @@ def download_missing_frames_from_subjob(local_job, subjob_id, subjob_hostname):
try: try:
local_files = [os.path.basename(x) for x in local_job.file_list()] local_files = [os.path.basename(x) for x in local_job.file_list()]
subjob_proxy = RenderServerProxy(subjob_hostname) subjob_proxy = RenderServerProxy(subjob_hostname)
subjob_files = subjob_proxy.get_job_files_list(job_id=subjob_id) or [] subjob_files = subjob_proxy.get_job_files(job_id=subjob_id) or []
for subjob_filename in subjob_files: for subjob_filename in subjob_files:
if subjob_filename not in local_files: if subjob_filename not in local_files:
+3 -3
View File
@@ -52,8 +52,8 @@ class SubmissionTestCase(unittest.TestCase):
'enable_split_jobs': False, 'enable_split_jobs': False,
} }
response = self.render_server.post_job_to_server( response = self.render_server.create_job(
file_path=sample_file_path, job_list=[sample_job]) file_path=sample_file_path, job_data=sample_job)
self.assertIsNotNone(response, msg='No response from server') self.assertIsNotNone(response, msg='No response from server')
self.assertTrue(response.ok, msg=f'Server returned {response.status_code}') self.assertTrue(response.ok, msg=f'Server returned {response.status_code}')
@@ -68,7 +68,7 @@ class SubmissionTestCase(unittest.TestCase):
file_count = 0 file_count = 0
while True: while True:
update_response = self.render_server.get_job_info(self.__class__.test_job_id) update_response = self.render_server.get_job(self.__class__.test_job_id)
if update_response: if update_response:
print(f"Status: {update_response['status']}") print(f"Status: {update_response['status']}")