Clients and Frontends
The basic ClientManager can support any kind of frontend or client. However, writing your own frontend may not be the fastest path to running your experiment with CHEESE. It is reccomended to instead use the GradioClientManager and to create your frontend in Gradio. If you should choose to do this, the GradioFront object is all you will need for the frontend of your experiment.
- class cheese.client.ClientManager[source]
- add_client(id: int, client_cls, **kwargs) → str[source]
Add a client to the ClientManager and return a url to the frontend.
- init_connection(connection: b_rabbit.b_rabbit.BRabbit)[source]
Initialize message channel and consumption callbacks.
- class cheese.client.gradio_client.GradioClientManager(no_login: bool = False)[source]
ClientManager for frontends made in Gradio
- add_client(id: int)[source]
Add a new client. Creates a user/pass combo.
- Parameters
id – ID for the new client
- await_new_task(id: int) → cheese.tasks.Task[source]
GradioFront should call this with ID of client. It will return a new task if one is available. Otherwise, it will loop and wait for one.
- Parameters
id – ID of the client awaiting a task
- Returns
A task, as soon as it is available
- queue_task(id: int, task: cheese.tasks.Task)[source]
Given a client id, queues the task that was assigned to that client and marks client as free or active accordingly.
- remove_client(id: int)[source]
Remove a client from the ClientManager. Note: this drops any task that client is working on.
- submit_task(id: int, task: cheese.tasks.Task)[source]
GradioFront should call this to submit a finished task.
- Parameters
id – ID of the client submitting a task
task – The finished task
- class cheese.client.gradio_client.GradioFront(no_login: bool = False)[source]
Frontend for CHEESE using Gradio
- Parameters
no_login (bool) – If True, will not require login. Useful for testing
- handle_input_exception(*args) → Any[source]
Handle invalid input exceptions. Default behavior is to just present same data again.
- Parameters
*args –
List of arguments that caused the exception
- Returns
Outputs for gradio demo
- Return type
Iterable[Any] or Any
- abstract main() → List[gradio.components.Component][source]
Gradio interface for collecting data can be written here. Should call GradioFront.response() with self. Please read the documentation of GradioFront.response for information on which specific inputs and outputs must go to/come out of the function.
- Returns
List of all output components in the gradio demo
- abstract present(task: cheese.tasks.Task) → List[gradio.components.Component][source]
Present data in the task to user. Should take task and return outputs to gradio functions in list form
- abstract receive(*inp) → cheese.tasks.Task[source]
Receive input from user and modify the data in the task with it. Can enforce input validity by raising InvalidInputException. Assumes first two parameters in inp are ID and Task respectively.
- Returns
task modified to reflect user input
- response(*inp) → Any[source]
Submit input from user then stall until we have an output ready for them. Assumes first two parameters in inp are ID and Task respectively
- Parameters
inp – Inputs from gradio components
- Returns
New task, Outputs to give to gradio components
- set_manager(manager: cheese.client.gradio_client.GradioClientManager)[source]
Set the manager for the frontend. This is how it will communicate with cheese. Must be set before calling launch