SolveJob
Bases: BaseModel
A model to represent a job for solving model problems.
set_evaluation_model(model: Model | None) -> None
Set the evaluation model for the solved job.
This will be done automatically. Normally there is no need to call this method.
Parameters:
-
model(Model | None) –
get_status(client: ILunaSolve | None = None, status_source: Literal['cached', 'remote'] = 'cached') -> StatusEnum
Retrieve the current status of the solve job.
Parameters:
-
status_source(Literal['cached', 'remote'], default:'cached') –If "cached", the status is retrieved from the cached status. If "remote", the status is retrieved from the remote service.
-
client(Optional[ILunaSolve], default:None) –The client to be used. If not provided, a new client is created using
Returns:
-
StatusEnum–The current status of the solve job, represented as a value from the
StatusEnumenumeration.
result(client: ILunaSolve | None = None, sleep_time_max: float = 30.0, backoff_factor: float = 2.0, sleep_time_initial: float = 0.5, call_style: CallStyle = CallStyle.ACTIVE_WAITING, sleep_time_increment: float | None = None) -> Solution | None
Get the result of the solve job.
This function uses the provided client or creates a new one to retrieve and the result of this solve job. Depending on the call style, it can actively wait for the result or return immediately.
While actively waiting, the job status is polled using capped exponential
backoff: the interval starts at sleep_time_initial and is multiplied
by backoff_factor after each poll, up to sleep_time_max.
Parameters:
-
client(Optional[ILunaSolve], default:None) –The client to be used. If not provided, a new client is created using ClientFactory.
-
sleep_time_max(float, default:30.0) –Maximum sleep time in seconds between consecutive active waiting checks.
-
backoff_factor(float, default:2.0) –Multiplier applied to the sleep time after each check during active waiting. Defaults to 2.0.
-
sleep_time_initial(float, default:0.5) –Initial sleep time in seconds for the active waiting process.
-
call_style(CallStyle, default:ACTIVE_WAITING) –Determines if this function will actively wait for the result or return immediately.
-
sleep_time_increment(float, default:None) –Deprecated. When provided, the sleep time grows linearly by this amount between checks instead of using
backoff_factor. Kept for backward compatibility; preferbackoff_factor.
Returns:
-
Optional[Solution]–The result of the solve job or None if not available.
Raises:
-
Any exceptions raised by the use case's solve job call will propagate.–
cancel(client: ILunaSolve | None = None) -> None
Cancel a solve job.
This method cancels an already initiated solve job using the provided client or a default one if no client is specified.
Parameters:
-
client(Optional[ILunaSolve], default:None) –The client instance used to perform the cancel operation. If None, the client is obtained via the ClientFactory.
Returns:
-
None–
delete(client: ILunaSolve | None = None) -> None
Delete a job using the specified or default client.
This method deletes this job and solution. A client can optionally be provided otherwise, a default client is obtained through the factory.
Parameters:
-
client(Optional[ILunaSolve], default:None) –The client to be used for job deletion. If not provided, a default client is retrieved using
ClientFactory.
get_by_id(solve_job_id: str, client: ILunaSolve | None = None) -> SolveJob
Retrieve a solve-job by its ID.
Para>meters
solve_job_id: str
Get the solve-job id for which a SolveJob should be retrieved.
client : Optional[ILunaSolve], optional
The client to be used for job deletion. If not provided, a default client
is retrieved using ClientFactory.
Returns:
-
SolveJob–The solve-job object.