Skip to content

remote

remote

JobStatusDisplay

JobStatusDisplay(enabled: bool = True, verbose: bool = False)

Manages single-line status display for remote job execution.

enabled instance-attribute

enabled = enabled

verbose instance-attribute

verbose = verbose

job_start_time instance-attribute

job_start_time: Optional[float] = None

status_start_time instance-attribute

status_start_time: Optional[float] = None

spinner_idx instance-attribute

spinner_idx = 0

last_response instance-attribute

last_response: Optional[Tuple[str, str, str]] = None

Colors

RESET class-attribute instance-attribute
RESET = '\x1b[0m' if _SUPPORTS_COLOR else ''
BOLD class-attribute instance-attribute
BOLD = '\x1b[1m' if _SUPPORTS_COLOR else ''
DIM class-attribute instance-attribute
DIM = '\x1b[2m' if _SUPPORTS_COLOR else ''
CYAN class-attribute instance-attribute
CYAN = '\x1b[36m' if _SUPPORTS_COLOR else ''
YELLOW class-attribute instance-attribute
YELLOW = '\x1b[33m' if _SUPPORTS_COLOR else ''
GREEN class-attribute instance-attribute
GREEN = '\x1b[32m' if _SUPPORTS_COLOR else ''
RED class-attribute instance-attribute
RED = '\x1b[31m' if _SUPPORTS_COLOR else ''
MAGENTA class-attribute instance-attribute
MAGENTA = '\x1b[35m' if _SUPPORTS_COLOR else ''
BLUE class-attribute instance-attribute
BLUE = '\x1b[34m' if _SUPPORTS_COLOR else ''
WHITE class-attribute instance-attribute
WHITE = '\x1b[37m' if _SUPPORTS_COLOR else ''

Icons

RECEIVED class-attribute instance-attribute
RECEIVED = '◉'
QUEUED class-attribute instance-attribute
QUEUED = '◎'
DISPATCHED class-attribute instance-attribute
DISPATCHED = '◈'
RUNNING class-attribute instance-attribute
RUNNING = '●'
COMPLETED class-attribute instance-attribute
COMPLETED = '✓'
ERROR class-attribute instance-attribute
ERROR = '✗'
LOG class-attribute instance-attribute
LOG = 'ℹ'
STREAM class-attribute instance-attribute
STREAM = '⇄'
SPINNER class-attribute instance-attribute
SPINNER = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏']

update

update(job_id: str = '', status_name: str = '', description: str = '')

Update the status display on a single line.

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.

model_key instance-attribute

model_key = model_key

address instance-attribute

address = host or HOST

api_key instance-attribute

api_key = api_key or get('NDIF_API_KEY', None) or APIKEY

job_id instance-attribute

job_id = job_id

zlib instance-attribute

zlib = ZLIB

blocking instance-attribute

blocking = blocking

callback instance-attribute

callback = callback

ws_address instance-attribute

ws_address = 'wss://' + address[8:]

job_status instance-attribute

job_status = None

status_display instance-attribute

status_display = JobStatusDisplay(enabled=REMOTE_LOGGING, verbose=verbose)

request

request(tracer: Tracer) -> Tuple[bytes, Dict[str, str]]

__call__

__call__(tracer=None)

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 ResponseModel

TYPE: Any

RAISES DESCRIPTION
Exception

If the job's status is ResponseModel.JobStatus.ERROR

RETURNS DESCRIPTION
ResponseModel

ResponseModel.

TYPE: Optional[RESULT]

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.

get_result

get_result(url: str, content_length: float = None) -> RESULT

async_get_result async

async_get_result(url: str, content_length: float = None) -> RESULT

blocking_request

blocking_request(tracer: Tracer) -> Optional[RESULT]

Send intervention request to the remote service while waiting for updates via websocket.

PARAMETER DESCRIPTION
request

Request.

TYPE: RequestModel

async_request async

async_request(tracer: Tracer) -> Optional[RESULT]

Send intervention request to the remote service while waiting for updates via websocket.

PARAMETER DESCRIPTION
request

Request.

TYPE: RequestModel

stream_send

stream_send(values: Dict[int, Any], sio: SimpleClient)

Upload some value to the remote service for some job id.

PARAMETER DESCRIPTION
value

Value to upload

TYPE: Any

job_id

Job id.

TYPE: str

sio

Connected websocket client.

TYPE: SimpleClient

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: RequestModel

LocalTracer

LocalTracer(*args, **kwargs)

Bases: Tracer

remotes instance-attribute

remotes = set()

register classmethod

register(send_fn: Callable)

deregister classmethod

deregister()

execute

execute(fn: Callable)

push

push()