How to use the mlpm.app.aidserver.solver.train function in mlpm

To help you get started, we’ve selected a few mlpm examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github autoai-org / AID / components / mlserve / aid / handler.py View on Github external
data = config.to_dict()
    results = {}
    if 'file' in request.files:
        file = request.files['file']
        filename = secure_filename(file.filename)
        # make sure the UPLOAD_FOLDER exsits
        if not os.path.isdir(upload_folder):
            os.makedirs(upload_folder)
        file_abs_path = os.path.join(upload_folder, filename)
        file.save(file_abs_path)
        data['input_file_path'] = file_abs_path
    try:
        if request_type == "infer":
            results = aidserver.solver.infer(data)
        elif request_type == "train":
            results = aidserver.solver.train(data)
        else:
            raise NotImplementedError
        if 'delete_after_process' in data:
            if str2bool(data['delete_after_process']):
                os.remove(file_abs_path)
        print(results)
        return response.json(results, status=200)
    except Exception as e:
        traceback.print_exc()
        return response.json({"error": str(e), "code": "500"}, status=500)