Port the KNN classification workflow to Modal using the class_state pattern, where the model is fitted once during initialization and then reused for multiple prediction queries.
Original workflow
The workspace contains workflow.py which implements a stateful classifier:
A WarmKNNClassifier class fits a KNeighborsClassifier and StandardScaler on the iris training set during __init__. The fitted objects are stored as instance attributes.
A predict_queries method accepts a list of raw feature vectors, scales them, and returns class predictions and class probabilities for each query without refitting.
run_workflow(case) instantiates the class once and calls the prediction method with all queries from case['queries'].
Your task
Create /app/solution/modal_app.py that:
Defines a module-level app
Defines a Modal Cls with a method named run_case that accepts a case dict and returns the same dict as run_workflow(case) in workflow.py
Capability contract
Expose the workflow as a single Modal remote function: define run_case as an @app.function so the harness can invoke it with run_case.remote(case).
The solution must also use:
Stateful class.
Interface
run_case is called remotely by the verifier. The case dict contains keys: n_neighbors, queries (list of 4-element feature vectors), metric, random_state. Return a dict with keys: predictions, probabilities, fit_samples.