Skip to content

Refinement of routes' Schemas #66

@matyson

Description

@matyson

Some routes of the api have unclear return Response Schema, and even wrong input Schemas; for instance, the simple GET /ping route should not accept an empty dict body argument. In this case, body is not even applicable for GET requests. With clearer Request/Response schemas one could also better infer how to use the api from the Swagger/Openapi JSON and avoid exhausting trials to infer the type returns.

@router.get("/")
@router.get("/ping")
async def ping_handler(payload: dict = {}, principal=Security(get_current_principal, scopes=["read:status"])):
    """
    May be called to get some response from the server. Currently returns status of RE Manager.
    """
    try:
        msg = await SR.RM.ping(**payload)
    except Exception:
        process_exception()
    return msg

image

It would be very useful to know the true json response from this request, which is of the form:

{
  "msg": "RE Manager vXYZ",
  "items_in_queue": number,
  "items_in_history": number,
  "running_item_uid": str|null,
  "manager_state": "str",
  "queue_stop_pending": bool,
  "queue_autostart_enabled": bool,
  "worker_environment_exists": bool,
  "worker_environment_state": "str",
  "worker_background_tasks": number,
  "re_state": "str",
  "ip_kernel_state": "str",
  "ip_kernel_captured": bool,
  "pause_pending": bool,
  "run_list_uid": "str",
  "plan_queue_uid": "str",
  "plan_history_uid": "str",
  "devices_existing_uid": "str",
  "plans_existing_uid": "str",
  "devices_allowed_uid": "str",
  "plans_allowed_uid": "str",
  "plan_queue_mode": {
    "loop": bool,
    "ignore_failures": bool
  },
  "task_results_uid": str",
  "lock_info_uid": "str",
  "lock": {
    "environment": bool,
    "queue": bool
  }
}

from some Pydantic model in the Response -> like:

class PingResponse(BaseModel):
    msg: str
    items_in_queue: int
    ...

I can help with some of these schema refinements for i've already made some type inferences myself. Just looking forward to a more friendly API that everyone can consume with typesafety 😄

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions