From 62e4a214e1bdb351654b75a05f5324f1d76a87b5 Mon Sep 17 00:00:00 2001 From: Brett Williams Date: Sat, 6 Jun 2026 08:09:45 -0500 Subject: [PATCH] More jobs API cleanup --- add_job.py | 6 +++--- docs/API.md | 12 ++++++------ docs/api.html | 10 +++++----- src/api/server_proxy.py | 10 +++++----- src/distributed_job_manager.py | 4 ++-- src/ui/add_job_window.py | 4 ++-- src/ui/main_window.py | 8 ++++---- src/utilities/server_helper.py | 2 +- tests/job_creation_tests.py | 6 +++--- 9 files changed, 31 insertions(+), 31 deletions(-) diff --git a/add_job.py b/add_job.py index ec0ece3..9fc9674 100644 --- a/add_job.py +++ b/add_job.py @@ -95,7 +95,7 @@ def main(): new_job = {"name": job_name, "engine_name": args.engine} 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: print(f"Error creating job: {e}") exit(1) @@ -113,7 +113,7 @@ def main(): while percent_complete < 1.0: # add checks for errors 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'] sys.stdout.write("\x1b[1A") # Move up 1 sys.stdout.write("\x1b[0J") # Clear from cursor to end of screen (optional) @@ -128,4 +128,4 @@ def main(): if __name__ == "__main__": - main() \ No newline at end of file + main() diff --git a/docs/API.md b/docs/API.md index 526eed8..a171a89 100644 --- a/docs/API.md +++ b/docs/API.md @@ -45,7 +45,7 @@ Response: Known callers: -- `RenderServerProxy.get_all_jobs()` +- `RenderServerProxy.get_jobs()` - `src/ui/main_window.py` ### `GET /api/jobs/long_poll` @@ -66,7 +66,7 @@ Responses: Known callers: -- `RenderServerProxy.get_all_jobs()` through the background cache updater. +- `RenderServerProxy.get_jobs()` through the background cache updater. ### `GET /api/jobs/status/` @@ -92,7 +92,7 @@ Returns one job as JSON. Known callers: -- `RenderServerProxy.get_job_info()` +- `RenderServerProxy.get_job()` - `add_job.py` - `src/ui/main_window.py` - `src/distributed_job_manager.py` @@ -112,7 +112,7 @@ Returns a list of output filenames for the job. Known callers: -- `RenderServerProxy.get_job_files_list()` +- `RenderServerProxy.get_job_files()` - `src/utilities/server_helper.py` ### `GET /api/jobs//download` @@ -201,7 +201,7 @@ Responses: Known callers: -- `RenderServerProxy.post_job_to_server()` +- `RenderServerProxy.create_job()` - `add_job.py` - `src/ui/add_job_window.py` - `src/distributed_job_manager.py` @@ -298,7 +298,7 @@ Returns a multi-server shaped status payload with the local server populated. Known callers: -- `RenderServerProxy.get_data()` +- `RenderServerProxy.get_full_status()` - `dashboard.py` Review note: this currently reports only the local server. The response shape diff --git a/docs/api.html b/docs/api.html index 22fb700..88d501c 100644 --- a/docs/api.html +++ b/docs/api.html @@ -282,7 +282,7 @@ }

Known callers:

    -
  • RenderServerProxy.get_all_jobs()
  • +
  • RenderServerProxy.get_jobs()
  • src/ui/main_window.py
@@ -306,7 +306,7 @@
GET/api/jobs/<job_id>

Returns one job as JSON.

-

Known callers include RenderServerProxy.get_job_info(), add_job.py, src/ui/main_window.py, src/distributed_job_manager.py, and tests/job_creation_tests.py.

+

Known callers include RenderServerProxy.get_job(), add_job.py, src/ui/main_window.py, src/distributed_job_manager.py, and tests/job_creation_tests.py.

@@ -317,7 +317,7 @@
GET/api/jobs/<job_id>/files

Returns a list of output filenames for the job.

-

Known callers: RenderServerProxy.get_job_files_list() and src/utilities/server_helper.py.

+

Known callers: RenderServerProxy.get_job_files() and src/utilities/server_helper.py.

@@ -365,7 +365,7 @@ child_jobsOptional subjob definitions. local_pathLocal file path used when posting to localhost. -

Known callers include RenderServerProxy.post_job_to_server(), add_job.py, src/ui/add_job_window.py, src/distributed_job_manager.py, and integration tests.

+

Known callers include RenderServerProxy.create_job(), add_job.py, src/ui/add_job_window.py, src/distributed_job_manager.py, and integration tests.

@@ -414,7 +414,7 @@
GET/api/full_status
-

Returns a multi-server shaped status payload with the local server populated. Used by RenderServerProxy.get_data() and dashboard.py.

+

Returns a multi-server shaped status payload with the local server populated. Used by RenderServerProxy.get_full_status() and dashboard.py.

The response shape suggests an intended future aggregation point, but it currently reports only the local server.
diff --git a/src/api/server_proxy.py b/src/api/server_proxy.py index 50c3edd..5993f54 100644 --- a/src/api/server_proxy.py +++ b/src/api/server_proxy.py @@ -158,12 +158,12 @@ class RenderServerProxy: # 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: self.__update_job_cache(timeout, ignore_token) 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) def get_status(self): @@ -180,17 +180,17 @@ class RenderServerProxy: # 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) - def get_job_files_list(self, job_id): + def get_job_files(self, job_id): return self.request_data(f'jobs/{job_id}/files') # -------------------------------------------- # 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. diff --git a/src/distributed_job_manager.py b/src/distributed_job_manager.py index 98aa1c0..b7fd82f 100644 --- a/src/distributed_job_manager.py +++ b/src/distributed_job_manager.py @@ -172,7 +172,7 @@ class DistributedJobManager: subjob_id = child_key.split('@')[0] 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: logger.warning(f"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 logger.debug(f"Posting subjob with frames {subjob['start_frame']}-" 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) return post_results diff --git a/src/ui/add_job_window.py b/src/ui/add_job_window.py index 0ba4d75..8bd7310 100644 --- a/src/ui/add_job_window.py +++ b/src/ui/add_job_window.py @@ -608,8 +608,8 @@ class SubmitWorker(QThread): input_path = Path(latest_engine.perform_presubmission_tasks(input_path)) # submit err_msg = "" - result = self.window.server_proxy.post_job_to_server(file_path=input_path, job_data=job_json, - callback=create_callback) + result = self.window.server_proxy.create_job(file_path=input_path, job_data=job_json, + callback=create_callback) if not (result and result.ok): err_msg = f"Error posting job to server: {result.text}" diff --git a/src/ui/main_window.py b/src/ui/main_window.py index ca5803b..c1a6423 100644 --- a/src/ui/main_window.py +++ b/src/ui/main_window.py @@ -563,7 +563,7 @@ class MainWindow(QMainWindow): return 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: display_name = job.get('name', os.path.basename(job.get('input_path', ''))) message = f"Are you sure you want to stop job: {display_name}?" @@ -592,7 +592,7 @@ class MainWindow(QMainWindow): return 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: 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}?" @@ -627,7 +627,7 @@ class MainWindow(QMainWindow): return 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']) launch_url(path) @@ -666,7 +666,7 @@ class BackgroundUpdater(QThread): ZeroconfServer.get_hostname_properties(x)['api_version'] == API_VERSION] if self.window.current_server_proxy: 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.updated_signal.emit() time.sleep(0.05) diff --git a/src/utilities/server_helper.py b/src/utilities/server_helper.py index 1040b7a..e417ead 100644 --- a/src/utilities/server_helper.py +++ b/src/utilities/server_helper.py @@ -17,7 +17,7 @@ def download_missing_frames_from_subjob(local_job, subjob_id, subjob_hostname): try: local_files = [os.path.basename(x) for x in local_job.file_list()] 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: if subjob_filename not in local_files: diff --git a/tests/job_creation_tests.py b/tests/job_creation_tests.py index d0dfc79..008d84d 100644 --- a/tests/job_creation_tests.py +++ b/tests/job_creation_tests.py @@ -52,8 +52,8 @@ class SubmissionTestCase(unittest.TestCase): 'enable_split_jobs': False, } - response = self.render_server.post_job_to_server( - file_path=sample_file_path, job_list=[sample_job]) + response = self.render_server.create_job( + file_path=sample_file_path, job_data=sample_job) self.assertIsNotNone(response, msg='No response from server') self.assertTrue(response.ok, msg=f'Server returned {response.status_code}') @@ -68,7 +68,7 @@ class SubmissionTestCase(unittest.TestCase): file_count = 0 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: print(f"Status: {update_response['status']}")