By the following code, I want to get the status of training, just if it is started and when it is finished.
app = FastAPI()
@app.post("/train")
async def train_on_background():
background_tasks.add_task(train, input_data, output_data)
def train(input_data, output_data):
dataset = prepare_dataset(input_data, output_data)
model = Trainer(dataset)
model.auto_train()
filename = "Model"
filename = filename + ".pkl"
dump(model, open(filename, 'wb'))
The train() function should train the model by doing several steps. train_on_background() should run the train function on the background.
I want to add a separate command to check the training status. the command should respond started when the training starts (train() function is called), & finished when it train() function is ended.