-
Notifications
You must be signed in to change notification settings - Fork 172
fix(localprocess): ensure __get_job_status returns Complete correctly #408
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -265,6 +265,36 @@ def wait_for_job_status( | |||
| polling_interval=polling_interval, | ||||
| callbacks=callbacks, | ||||
| ) | ||||
| def get_job_progress(self, name: str) -> dict: | ||||
| """Get progress of a TrainJob. | ||||
|
|
||||
| Args: | ||||
| name: Name of the TrainJob. | ||||
|
|
||||
| Returns: | ||||
| Dictionary containing job status and progress. | ||||
| """ | ||||
|
|
||||
| # Get job details | ||||
| job = self.get_job(name=name) | ||||
|
|
||||
| status = job.status if hasattr(job, "status") else "Unknown" | ||||
|
|
||||
| if status == "Running": | ||||
| progress = "In Progress" | ||||
| elif status in ["Complete", "Succeeded"]: | ||||
| progress = "100%" | ||||
| elif status == "Failed": | ||||
| progress = "Error" | ||||
| else: | ||||
| progress = "Unknown" | ||||
|
|
||||
| return { | ||||
| "job_id": name, | ||||
| "status": status, | ||||
| "progress": progress, | ||||
| } | ||||
|
Comment on lines
+268
to
+296
|
||||
|
|
||||
|
|
||||
|
Comment on lines
+297
to
298
|
||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -264,17 +264,22 @@ def __get_job_status(self, job: LocalBackendJobs) -> str: | |
| if not job.steps: | ||
| return constants.TRAINJOB_CREATED | ||
| statuses = [_step.job.status for _step in job.steps] | ||
| # if status is running or failed will take precedence over completed | ||
|
|
||
| # Priority: Failed > Running > Created > Complete | ||
| if constants.TRAINJOB_FAILED in statuses: | ||
| status = constants.TRAINJOB_FAILED | ||
| elif constants.TRAINJOB_RUNNING in statuses: | ||
| status = constants.TRAINJOB_RUNNING | ||
| elif constants.TRAINJOB_CREATED in statuses: | ||
| status = constants.TRAINJOB_CREATED | ||
| else: | ||
| status = constants.TRAINJOB_COMPLETE | ||
| return constants.TRAINJOB_FAILED | ||
|
|
||
| if constants.TRAINJOB_RUNNING in statuses: | ||
| return constants.TRAINJOB_RUNNING | ||
| if constants.TRAINJOB_CREATED in statuses: | ||
| return constants.TRAINJOB_CREATED | ||
|
|
||
| # ✅ NEW FIX: Ensure all steps are actually complete | ||
| if all(status == constants.TRAINJOB_COMPLETE for status in statuses): | ||
| return constants.TRAINJOB_COMPLETE | ||
|
|
||
| return status | ||
| # fallback (safety) | ||
| return constants.TRAINJOB_RUNNING | ||
|
Comment on lines
+268
to
+282
|
||
|
|
||
| def __register_job( | ||
| self, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line 285 checks for status "Succeeded", but the TrainJob status constants only define "Created", "Running", "Complete", and "Failed". This check will never match. Use "Complete" instead if checking for successful completion.