remote¶
remote
¶
JobStatusDisplay
¶
RemoteException
¶
Bases: Exception
RemoteBackend
¶
RemoteBackend(model_key: str, host: str = None, blocking: bool = True, job_id: str = None, api_key: str = '', callback: str = '', verbose: bool = False)
Bases: Backend
Backend to execute a context object via a remote service.
Context object must inherit from RemoteMixin and implement its methods.
Attributes:
url (str): Remote host url. Defaults to that set in CONFIG.API.HOST.
status_display
instance-attribute
¶
status_display = JobStatusDisplay(enabled=REMOTE_LOGGING, verbose=verbose)
handle_response
¶
handle_response(response: ResponseModel, tracer: Optional[Tracer] = None) -> Optional[RESULT]
Handles incoming response data.
Logs the response object.
If the job is completed, retrieve and stream the result from the remote endpoint.
Use torch.load to decode and load the ResultModel into memory.
Use the backend object's .handle_result method to handle the decoded result.
| PARAMETER | DESCRIPTION |
|---|---|
response
|
Json data to concert to
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
Exception
|
If the job's status is |
| RETURNS | DESCRIPTION |
|---|---|
ResponseModel
|
ResponseModel.
TYPE:
|
submit_request
¶
submit_request(data: bytes, headers: Dict[str, Any]) -> Optional[ResponseModel]
Sends request to the remote endpoint and handles the response object.
| RAISES | DESCRIPTION |
|---|---|
Exception
|
If there was a status code other than 200 for the response. |
| RETURNS | DESCRIPTION |
|---|---|
ResponseModel
|
Response. |
get_response
¶
get_response() -> Optional[RESULT]
Retrieves and handles the response object from the remote endpoint.
| RAISES | DESCRIPTION |
|---|---|
Exception
|
If there was a status code other than 200 for the response. |
| RETURNS | DESCRIPTION |
|---|---|
ResponseModel
|
Response. |
blocking_request
¶
Send intervention request to the remote service while waiting for updates via websocket.
| PARAMETER | DESCRIPTION |
|---|---|
request
|
Request.
TYPE:
|
async_request
async
¶
Send intervention request to the remote service while waiting for updates via websocket.
| PARAMETER | DESCRIPTION |
|---|---|
request
|
Request.
TYPE:
|
stream_send
¶
Upload some value to the remote service for some job id.
| PARAMETER | DESCRIPTION |
|---|---|
value
|
Value to upload
TYPE:
|
job_id
|
Job id.
TYPE:
|
sio
|
Connected websocket client.
TYPE:
|
non_blocking_request
¶
non_blocking_request(tracer: Tracer)
Send intervention request to the remote service if request provided. Otherwise get job status.
Sets CONFIG.API.JOB_ID on initial request as to later get the status of said job.
When job is completed, clear CONFIG.API.JOB_ID to request a new job.
| PARAMETER | DESCRIPTION |
|---|---|
request
|
Request if submitting a new request. Defaults to None
TYPE:
|