-
Notifications
You must be signed in to change notification settings - Fork 3
feat(JobWrapper): Report the status of the job to DiracX #111
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
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
2fca114
feat: report job status
Loxeris 06f9fde
fix: fix tests
Loxeris c881093
feat: add JobReport class and apply pr suggestions
Loxeris 140b8bc
feat: add job parameters to job report
Loxeris e506f62
refactor: use dicts to store job reports
Loxeris f278eb3
refactor: remove initialize method
Loxeris 00d283e
style: prettier local job report
Loxeris d12076a
fix: fix store_output not being awaited in test
Loxeris 7e19467
refactor: add job report commits along job wrapper
Loxeris ae4abc4
fix: fix deserialization error
Loxeris c7b7188
test: test reports of job status and parameters
Loxeris 3514ed1
fix(JobWrapper): setup DiracX
Loxeris 0b1d44b
refactor: async sandbox mocks
Loxeris 415e8f9
fix: use Paths when creating sandboxes
Loxeris 88af6ca
fix: set logging level for the JobWrapper
Loxeris 5522595
feat: assign output sandbox to job
Loxeris fa06848
fix: async download sandbox in parallel test
Loxeris 726cd8f
refactor: apply PR suggestions
Loxeris 76fb6f7
refactor: no None type for diracx_client
Loxeris File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| """All classes related to job reports.""" | ||
|
|
||
| from datetime import datetime, timezone | ||
| from enum import StrEnum | ||
|
|
||
| from diracx.client.aio import AsyncDiracClient | ||
| from diracx.core.models.job import JobStatus, JobStatusUpdate | ||
|
|
||
|
|
||
| class JobMinorStatus(StrEnum): | ||
| """List of all available job minor statuses.""" | ||
|
|
||
| APPLICATION = "Executing Payload" | ||
| APP_ERRORS = "Application Finished With Errors" | ||
| # APP_NOT_FOUND = "Application not found" | ||
| APP_SUCCESS = "Application Finished Successfully" | ||
| # APP_THREAD_FAILED = "Application thread failed" | ||
| # APP_THREAD_NOT_COMPLETE = "Application thread did not complete" | ||
| DOWNLOADING_INPUT_SANDBOX = "Downloading InputSandbox" | ||
| # DOWNLOADING_INPUT_SANDBOX_LFN = "Downloading InputSandbox LFN(s)" | ||
| # EXCEPTION_DURING_EXEC = "Exception During Execution" | ||
| EXEC_COMPLETE = "Execution Complete" | ||
| FAILED_DOWNLOADING_INPUT_SANDBOX = "Failed Downloading InputSandbox" | ||
| # FAILED_DOWNLOADING_INPUT_SANDBOX_LFN = "Failed Downloading InputSandbox LFN(s)" | ||
| # FAILED_SENDING_REQUESTS = "Failed sending requests" | ||
| # GOING_RESCHEDULE = "Going to reschedule job" | ||
| # ILLEGAL_JOB_JDL = "Illegal Job JDL" | ||
| INPUT_DATA_RESOLUTION = "Resolving Input Data" | ||
| # INPUT_NOT_AVAILABLE = "Input Data Not Available" | ||
| # JOB_EXCEEDED_CPU = "Job has reached the CPU limit of the queue" | ||
| # JOB_EXCEEDED_WALL_CLOCK = "Job has exceeded maximum wall clock time" | ||
| JOB_INITIALIZATION = "Initializing Job" | ||
| # JOB_INSUFFICIENT_DISK = "Job has insufficient disk space to continue" | ||
| # JOB_WRAPPER_EXECUTION = "JobWrapper execution" | ||
| # JOB_WRAPPER_INITIALIZATION = "Job Wrapper Initialization" | ||
| # MARKED_FOR_TERMINATION = "Marked for termination" | ||
| # NO_CANDIDATE_SITE_FOUND = "No candidate sites available" | ||
| OUTPUT_DATA_UPLOADED = "Output Data Uploaded" | ||
| OUTPUT_SANDBOX_UPLOADED = "Output Sandbox Uploaded" | ||
| # PENDING_REQUESTS = "Pending Requests" | ||
| # PILOT_AGENT_SUBMISSION = "Pilot Agent Submission" | ||
| # RECEIVED_KILL_SIGNAL = "Received Kill signal" | ||
| # REQUESTS_DONE = "Requests done" | ||
| # RESCHEDULED = "Job Rescheduled" | ||
| RESOLVING_OUTPUT_SANDBOX = "Resolving Output Sandbox" | ||
| # STALLED_PILOT_NOT_RUNNING = "Job stalled: pilot not running" | ||
| # UPLOADING_JOB_OUTPUTS = "Uploading Outputs" | ||
| UPLOADING_OUTPUT_DATA = "Uploading Output Data" | ||
| UPLOADING_OUTPUT_SANDBOX = "Uploading Output Sandbox" | ||
| # WATCHDOG_STALLED = "Watchdog identified this job as stalled" | ||
|
|
||
|
|
||
| class JobReport: | ||
| """JobReport.""" | ||
|
|
||
| def __init__(self, job_id: int, source: str, client: AsyncDiracClient) -> None: | ||
| """ | ||
| Initialize Job Report. | ||
|
|
||
| :param job_id: the job ID | ||
| :param source: source for the reports | ||
| :param client: DiracX client instance | ||
| """ | ||
| self.job_status_info: dict[str, dict[str, str]] = {} # where job status updates are cumulated | ||
| self.job_id = job_id | ||
| self.source = source | ||
| self._client = client | ||
|
|
||
| def set_job_status( | ||
| self, | ||
| status: JobStatus | None = None, | ||
| minor_status: JobMinorStatus | None = None, | ||
| application_status: str | None = None, | ||
| ) -> None: | ||
| """ | ||
| Add a new job status to the job report. | ||
|
|
||
| :param status: job status | ||
| :param minor_status: job minor status | ||
| :param application_status: application status | ||
| """ | ||
| timestamp = str(datetime.now(timezone.utc)) | ||
| # add job status record | ||
| self.job_status_info.update( | ||
| { | ||
| timestamp: JobStatusUpdate( | ||
| Status=status, | ||
| MinorStatus=minor_status, | ||
| ApplicationStatus=application_status, | ||
| Source=self.source, | ||
| ).model_dump() | ||
| } | ||
| ) | ||
|
|
||
| async def send_stored_status_info(self): | ||
| """Send all the accumulated job status information.""" | ||
| if not self.job_status_info: | ||
| return | ||
| body = {self.job_id: self.job_status_info} | ||
| ret = await self._client.jobs.set_job_statuses(body) | ||
| if ret.success: | ||
| self.job_status_info = {} | ||
| else: | ||
| raise RuntimeError(f"Could not set job statuses: {ret}") | ||
|
|
||
| async def commit(self): | ||
| """Send all the accumulated information.""" | ||
| await self.send_stored_status_info() | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.