Beispiel #1
0
def trainRouteClient():

    try:
        if request.json['folderPath'] is not None:
            path = request.json['folderPath']

            train_valObj = train_validation(path)

            train_valObj.train_validation()

            trainModelObj = trainModel()

            trainModelObj.trainingModel()

    except ValueError:

        return Response("Error Occurred! %s" % ValueError)

    except KeyError:

        return Response("Error Occurred! %s" % KeyError)

    except Exception as e:

        return Response("Error Occurred! %s" % e)
    return Response("Training successfull!!")
Beispiel #2
0
def trainRouteClient():

    try:

        a = Azure_Functions(
            connection_string=
            "DefaultEndpointsProtocol=https;AccountName=trainingbatchfiles;AccountKey=JPHQiUP+0kPN4UlfW+jXZm9EaPg0nsSUd9MZMLnhpjmJZnO7OXiemYqM+vosRjXA8MLOTqV2fsDEAmz6tIjGFw==;EndpointSuffix=core.windows.net"
        )
        b = a.gettingcsvfile("predictionbatchfiles")
        print(b)

        trainobj = train_validation(b)
        trainobj.train_validation()

        trainModelObj = trainModel()
        trainModelObj.trainingModel()

    except ValueError:

        return Response("Error Occurred! %s" % ValueError)

    except KeyError:

        return Response("Error Occurred! %s" % KeyError)

    except Exception as e:

        return Response("Error Occurred! %s" % e)
    return Response("Training successfull!!")
Beispiel #3
0
def trainRouteClient():

    try:
        #if request.json['folderPath'] is not None:
            #path = request.json['C:/Machine learning project/Visibility/visibility/code/7visibility_climate/Training_Batch_Files/visibility_08012008_120010.csv']
            path='Training_Batch_Files'
            train_valObj = train_validation(path) #object initialization

            train_valObj.train_validation()#calling the training_validation function


            trainModelObj = trainModel() #object initialization
            trainModelObj.trainingModel() #training the model for the files in the table


    except ValueError:

        return Response("Error Occurred! %s" % ValueError)

    except KeyError:

        return Response("Error Occurred! %s" % KeyError)

    except Exception as e:

        return Response("Error Occurred! %s" % e)
    return Response("Training successfull!!")
Beispiel #4
0
def trainRouteClient():

    try:
        if request.json['folderPath'] is not None:
            path = request.json['folderPath']
            train_valObj = train_validation(path) #object initialization

            train_valObj.train_validation()#calling the training_validation function


            trainModelObj = trainModel() #object initialization
            trainModelObj.trainingModel() #training the model for the files in the table


    except ValueError:

        return Response("Error Occurred! %s" % ValueError)

    except KeyError:

        return Response("Error Occurred! %s" % KeyError)

    except Exception as e:

        return Response("Error Occurred! %s" % e)
    return Response("Training successfull!!")
Beispiel #5
0
def trainRouteClient():

    try:
        path = 'Training_Batch_Files'
        train_valObj = train_validation(path)  #object initialization

        train_valObj.train_validation(
        )  #calling the training_validation function

        trainModelObj = trainModel()  #object initialization
        trainModelObj.trainingModel(
        )  #training the model for the files in the table

    except ValueError:

        return Response("Error Occurred! %s" % ValueError)

    except KeyError:

        return Response("Error Occurred! %s" % KeyError)

    except Exception as e:

        return Response("Error Occurred! %s" % e)
    return Response("Training successfull!!")
Beispiel #6
0
def trainingTest():
    try:
        az_blb_mgt = AzureBlobManagement()
        execution_id = str(uuid.uuid4())
        path = 'training-batch-files'
        train_valObj = train_validation(path,
                                        execution_id)  # object initialization
        train_valObj.train_validation(
        )  # calling the training_validation function
        trainModelObj = trainModel(execution_id)  # object initialization
        trainModelObj.trainingModel(
        )  # training the model for the files in the table
        bad_data_archived = "lat-" + execution_id
        directory = [
            container_name.name for container_name in
            az_blb_mgt.blob_service_client.list_containers()
        ]
        for dir in directory:
            if re.search('^' + bad_data_archived, dir):
                bad_data_archived = dir

        file_names = az_blb_mgt.getAllFileNameFromDirectory(bad_data_archived)

        message = "Hi Team,\n\n We have listed file name which was failed to process due to validation"
        i = 0
        for file in file_names:
            i = i + 1
            message = message + "\n" + str(i) + ") " + file
        message = message + "\n Thanks & regards\n Avnish Yadav"
        emailSender = EmailSender()
        emailSender.sendEmail(message, "Trainning failed file")
        print("Traing Completed")
    except Exception as e:
        print(str(e))
Beispiel #7
0
def trainRouteClient():

    try:
        # if request.json['folderPath'] is not None:
            # path = request.json['folderPath']
            # s3_client = boto3.client("s3", aws_access_key_id=Access_keys.access_key, aws_secret_access_key=Access_keys.secret_key)

            # path = 'Training_Batch_Files'
            path = Buckets.GetFilesFromBuckte("waferproject20210427")
            train_valObj = train_validation(path) #object initialization

            train_valObj.train_validation()#calling the training_validation function


            trainModelObj = trainModel() #object initialization
            trainModelObj.trainingModel() #training the model for the files in the table


    except ValueError:

        return Response("Error Occurred! %s" % ValueError)

    except KeyError:

        return Response("Error Occurred! %s" % KeyError)

    except Exception as e:

        return Response("Error Occurred! %s" % e)
    return Response("Training successfull!!")
Beispiel #8
0
def trainRouteClient():
    try:
        if request.json is not None:  # 'folderPath' is nothing but path of folder we provide where trainign data set file is placed
            path = request.json['filepath']
            train_valObj = train_validation(
                path
            )  # object initialization for class train_Validation(we r creating a instance of class train_validation
            # as train_valObj

            train_valObj.train_validation(
            )  # calling the training_validation function(from hat object calling taining_Validation function)

            trainModelObj = trainModel()  # object initialization
            summary_of_training = trainModelObj.trainingModel(
            )  # training the model for the files in the table
            print(summary_of_training)
            return Response("result of training  %s!!!" %
                            summary_of_training.to_html())

        elif request.form is not None:
            path = request.form['filepath']
            train_valObj = train_validation(
                path
            )  # object initialization for class train_Validation(we r creating a instance of class train_validation
            # as train_valObj

            train_valObj.train_validation(
            )  # calling the training_validation function(from hat object calling taining_Validation function)

            trainModelObj = trainModel()  # object initialization
            summary_of_training = trainModelObj.trainingModel(
            )  # training the model for the files in the table
            print(summary_of_training)
            return Response("result of training  %s!!!" %
                            summary_of_training.to_html())

    except ValueError:

        return Response("Error Occurred! %s" % ValueError)

    except KeyError:

        return Response("Error Occurred! %s" % KeyError)

    except Exception as e:

        return Response("Error Occurred! %s" % e)
Beispiel #9
0
def trainRouteClient():

    try:
        path = "Training_Batch_Files1"
        #path = request.form['folderPath']
        print(type(path))
        if request.method == 'POST':
            path = request.form['folderPath']

            train_valObj = train_validation(path)  #object initialization

            train_valObj.train_validation(
            )  #calling the training_validation function

            trainModelObj = trainModel()  #object initialization
            trainModelObj.trainingModel(
            )  #training the model for the files in the table
        elif type(path) is str:
            path = "Training_Batch_Files1"
            print(path)
            train_valObj = train_validation(path)  # object initialization

            train_valObj.train_validation(
            )  # calling the training_validation function

            trainModelObj = trainModel()  # object initialization
            trainModelObj.trainingModel(
            )  # training the model for the files in the table
        else:
            print("Nothing")

    except ValueError as v:

        return Response("Error Occurred1! %s" % v)

    except KeyError as k:

        return Response("Error Occurred2! %s" % k)

    except Exception as e:

        return Response("Error Occurred3! %s" % e)
    return Response("Training successfull!!")
Beispiel #10
0
def trainRouteClient():
    try:
        if request.json is not None:
            path = request.json['filepath']
            train_valObj = train_validation(path)
            train_valObj.train_validation()
            trainModelObj = trainModel()
            trainModelObj.trainingModel()
            return Response('Successful End of Training')
        else:
            return Response("Invalid filepath")
    except ValueError:
        return Response("Error occured {}".format(ValueError))
    except KeyError:
        return Response("Error occured {}".format(KeyError))
    except Exception as e:
        return Response("Error occured {}".format(e))
Beispiel #11
0
def trainRouteClient():
    try:

        user_input = st.text_input("Enter the name of folder containing files for training", "default")
        if user_input!="default":
            path=user_input
            # print(path)
            train_valObj = train_validation(path)
            df=train_valObj.train_validation()
            if len(df)>0:
                st.write("The processed data used for training")
                st.write(df)
            trainModelObj = trainModel()  # object initialization
            training_msg=trainModelObj.trainingModel()  # training the model for the files in the table
            if len(training_msg)>0:
                st.write(training_msg)

    except Exception as e:
        st.write("Error Occurred!:",e)
def trainRouteClient():
    try:
        execution_id = str(uuid.uuid4())
        #if request.json['folderPath'] is not None:
        #path = request.json['folderPath']

        path = 'training-batch-files'
        execution_id = str(uuid.uuid4())
        train_valObj = train_validation(
            path, execution_id)  #object initialization of class

        train_valObj.train_validation(
        )  #calling the training_validation function

        trainModelObj = trainModel(execution_id)  #object initialization
        trainModelObj.trainingModel(
        )  #training the model for the files in the table

    except Exception as e:

        return Response("Error Occurred! %s" % e)
    return Response("Training successfull!!")
Beispiel #13
0
def retrain():
    file_object = open("log_file/FlaskApi_log.txt", 'a+')
    try:
        logger.log(file_object,
                   '============= Retraining Model Started =============')
        if request.method == "POST":
            file = request.files['retrain_file']
            if file:
                file.save(secure_filename(file.filename))
                a = trainModel()
                a.trainingModel(file.filename, file_object)
                logger.log(
                    file_object,
                    '============= Model Retraining Done =============')
                os.remove(file.filename)
                file_object.close()
                return render_template(
                    'home.html', text=".... Model Retrained Successfully ....")
    except Exception as e:
        logger.log(file_object,
                   'Model Retraining Failed . ERROR message :  ' + str(e))
        file_object.close()
        return 'Something went wrong , check your file extension .(should be .csv )'
Beispiel #14
0
def trainRouteClient():
    try:
        if request.json[
                'filepath'] is not None:  # prection file access from Postman server (Main folder file:- RawData)

            path = request.json['filepath']  # Obtained file path

            train_valObj = train_validation(path)  # object initialization

            train_valObj.train_validation(
            )  # calling the training_validation function

            trainModelObj = trainModel()  # object initialization

            trainModelObj.trainingModel(
            )  # training the model for the files in the table

    except ValueError:
        return Response("Error Occurred! %s" % ValueError)
    except KeyError:
        return Response("Error Occurred! %s" % KeyError)
    except Exception as e:
        return Response("Error Occurred! %s" % e)
    return Response("Training successfull!!")
Beispiel #15
0
# Run in order to generate default pickle file ..

from trainingModel import trainModel

start_model_training = trainModel()
start_model_training.trainingModel()
Beispiel #16
0
# except ValueError:
#     print("Error Occurred! %s" %ValueError)
# except KeyError:
#     print("Error Occurred! %s" %KeyError)
# except Exception as e:
#     print("Error Occurred! %s" %e)
#

try:

    path = 'Training_Batch_Files'
    train_valObj = train_validation(path)  #object initialization

    train_valObj.train_validation()  #calling the training_validation function

    trainModelObj = trainModel()  #object initialization
    trainModelObj.trainingModel(
    )  #training the model for the files in the table

except ValueError:

    print("Error Occurred! %s" % ValueError)

except KeyError:

    print("Error Occurred! %s" % KeyError)

except Exception as e:

    print("Error Occurred! %s" % e)
#print("Training successfull!!")
from wsgiref import simple_server