CHEESE
Once you have a pipeline, data, and a frontend set up, running CHEESE (and adding or removing clients) is simple! You just launch CHEESE and add as many clients as you wish.
- class cheese.CHEESE(pipeline_cls=None, client_cls=None, model_cls=None, pipeline_kwargs: Dict[str, Any] = {}, model_kwargs: Dict[str, Any] = {}, gradio: bool = True, draw_always: bool = False, host: str = 'localhost', port: int = 5672, debug: bool = False, no_login: bool = False)[source]
Main object to use for running tasks with CHEESE
- Parameters
pipeline_cls (Callable[, Pipeline]) – Class for pipeline
client_cls (Callable[,GradioFront] if gradio) – Class for client
model_cls (Callable[,BaseModel]) – Class for model
pipeline_kwargs (Dict[str, Any]) – Additional keyword arguments to pass to pipeline constructor
gradio (bool) – Whether to use gradio or custom frontend
draw_always (bool) – If true, doesn’t check for free clients before drawing a task. This is useful if you are trying to feed data directly to model and don’t need to worry about having free clients.
host (str) – Host for rabbitmq server. Normally just locahost if you are running locally
port (int) – Port to run rabbitmq server on
debug (bool) – Print debug messages for rabbitmq
no_login (bool) – If true, users don’t need password, only their ID, to log in
- create_client(id: int) → Tuple[int, int][source]
Create a client instance with given id.
- Parameters
id (int) – A unique identifying number for the client.
- Returns
Username and password user can use to log in to CHEESE
- draw()[source]
Draws a sample from data pipeline and creates a task to send to clients. Does nothing if no free clients. This check if overriden if draw_always is set to True.
- get_stats() → Dict[source]
Get various statistics in the form of a dictionary.
- Returns
Dictionary containing following statistics and values - url: URL for accessing CHEESE frontend - finished: Whether pipeline is exhausted - num_clients: Number of clients connected to CHEESE - num_busy_clients: Number of clients currently working on a task - num_tasks: Number of tasks completed overall - client_stats: Dictionary of client statistics - model_stats: Dictionary of model statistics - pipeline_stats: Dictionary of pipeline statistics
- progress_bar(max_tasks: int, access_stat: Callable, call_every: Optional[Callable] = None, check_every: float = 1.0)[source]
This function shows a progress bar via tqdm some given stat. Blocks execution. Not recommended for interactive use.
- Parameters
max_tasks (int) – The maximum number of tasks to show progress to before returning
access_stat (Callable[, int]) – Some callable that returns a stat we want to see progress for (i.e. as an integer).
call_every (Callable[, None]) – Some callable that we want to call every time stat is updated.
check_every (float) – How often to check for updates to the stat in seconds.