Exemplo n.º 1
0
def start_train(project_id):
    if not current_user.is_authenticated:
        print('not logged in')
        return redirect(url_for('login'))

    content = None
    data = None
    data = Project.from_user(current_user.user_id)

    project_specific_data = []
    html = None
    titles = None

    if Project.check_auth(current_user.user_id, int(project_id)):
        project_specific_data = Project.get_one(current_user.user_id,
                                                int(project_id))
        if project_specific_data[0]['model_available']:
            return jsonify(result='trained')
        q.enqueue(DLModel.train_model,
                  project_specific_data[0]['dataset'][0]['name'],
                  int(project_id), app.config['UPLOAD_FOLDER'])
        Database.update_one(collection='projects',
                            query=[{
                                'project_id': int(project_id)
                            }, {
                                "$set": {
                                    "in_training": True
                                }
                            }])
        return jsonify(result='done')
    else:
        return jsonify(result='error')
Exemplo n.º 2
0
def predictions_dashboard(project_id):
    if not current_user.is_authenticated:
        print('not logged in')
        return redirect(url_for('login'))

    content = None
    data = None

    model_info = None

    data = Project.from_user(current_user.user_id)
    if Project.check_auth(current_user.user_id, int(project_id)):
        project_specific_data = Project.get_one(current_user.user_id,
                                                int(project_id))

    if project_specific_data[0]['model_available']:
        model_info = Database.find_one(
            collection="models",
            query={"project_id": project_specific_data[0]['project_id']})

    print(model_info)

    try:
        # try to match the pages defined in -> pages/<input file>
        return render_template('pages/prediction_dashboard.html',
                               data=data,
                               project_specific_data=project_specific_data,
                               model_info=model_info)

    except:

        return render_template('pages/error-404.html')
Exemplo n.º 3
0
def explore_data(project_id, dataset_id):
    if not current_user.is_authenticated:
        print('not logged in')
        return redirect(url_for('login'))

    content = None
    data = None
    data = Project.from_user(current_user.user_id)
    if Project.check_auth(current_user.user_id, int(project_id)):
        project_specific_data = Project.get_one(current_user.user_id,
                                                int(project_id))

    table_data, titles, numerical_vals = Analysis.get_coloums_stat(
        app.config['UPLOAD_FOLDER'] + 'dataset/' + dataset_id)

    try:
        # try to match the pages defined in -> pages/<input file>
        return render_template('pages/explore_data.html',
                               data=data,
                               project_specific_data=project_specific_data,
                               numerical_vals=numerical_vals,
                               table_data=table_data,
                               titles=titles,
                               active_dataset=dataset_id)

    except:

        return render_template('pages/error-404.html')
Exemplo n.º 4
0
def start_train(project_id):
    """
    STRICT API To allow ADMIN user to force sart training for the Deep Leanring Model
    Allows an ADMIN user to start traning the user Deep LEarning model
    customer's activities. \n\n

    API/URL must be accessed with GET request and supply project_id the URL\n

    method: GET\n

    Args:
        project_id (str): ID of the poject/Customer need to be sent in url. It is made to do so via Front end href
    
    Returns:
        response: JSON object
    
    On Success \n
    response = {
        'result': 'done'
    }
    \n
    On Fail:\n
    response = {
        'result': 'error'
    }
    \n
    
    """
    if not current_user.is_authenticated:
        print('not logged in')
        return redirect(url_for('login'))

    content = None
    data = None
    data = Project.from_user(current_user.user_id)

    project_specific_data = []
    html = None
    titles = None

    if Project.check_auth(current_user.user_id, int(project_id)):
        project_specific_data = Project.get_one(current_user.user_id,
                                                int(project_id))
        if project_specific_data[0]['model_available']:
            return jsonify(result='trained')
        q.enqueue(DLModel.train_model,
                  project_specific_data[0]['dataset'][0]['name'],
                  int(project_id), app.config['UPLOAD_FOLDER'])
        Database.update_one(collection='projects',
                            query=[{
                                'project_id': int(project_id)
                            }, {
                                "$set": {
                                    "in_training": True
                                }
                            }])
        return jsonify(result='done')
    else:
        return jsonify(result='error')
Exemplo n.º 5
0
def project_dashboard(project_id):
    """
    Admin Dashboard \n
    ALlows ADMIN to access project/CUSTOMER user
    ALlows ADMIN to access project/CUSTOMER user dashboard
    with all the admin tools to vefiy user pipeline
    this allows admin to oversee if the user data is present or not
    Allow to see the status of user Deep Learning model.\n\n

    method: GET\n

    API/URL must be accessed with GET request and supply project_id in the URL\n

    Args:
        project_id (str): ID of the poject need to be sent in url. It is made to do so via Front end href
    
    Returns:
        view: a url VIEW the project's/CUSTOMER's required params such as
        Dataset, dataset voliation if present, Deep leanring model status, 
        Deep learning model metrics, predication metreics. OR if the user is
        not logged in or CUSTOMER user does not exists then 404 redirect
    """
    if not current_user.is_authenticated:
        print('not logged in')
        return redirect(url_for('login'))

    content = None
    data = None
    data = Project.from_user(current_user.user_id)

    project_specific_data = []
    html = None
    titles = None

    model_info = None
    if Project.check_auth(current_user.user_id, int(project_id)):
        project_specific_data = Project.get_one(current_user.user_id,
                                                int(project_id))
        print(project_specific_data)

    if project_specific_data[0]['model_available']:
        model_info = Database.find_one(
            collection="models",
            query={"project_id": project_specific_data[0]['project_id']})

    print(model_info)

    try:
        # try to match the pages defined in -> pages/<input file>
        return render_template('pages/project_dashboard.html',
                               data=data,
                               project_specific_data=project_specific_data,
                               model_info=model_info)

    except:

        return render_template('pages/error-404.html')
Exemplo n.º 6
0
def predictions_dashboard(project_id):
    """
    Predictions Dashboard \n
    To allow ADMIN user see all necessary metrics for the project/CUSTOMER user
    Allows an ADMIN user visualize the Deep Learning model's performance, along side
    customer's activities.\n\n

    method: GET\n

    API/URL must be accessed with GET request and supply project_id in the URL\n

    Args:
        project_id (str): ID of the poject need to be sent in url. It is made to do so via Front end href
    
    Returns:
        view: a url VIEW the project's/CUSTOMER's all required prediction values and visulization data 
          give user login status. If project CUSTOMER not found then redirect 404.
    """
    if not current_user.is_authenticated:
        print('not logged in')
        return redirect(url_for('login'))

    content = None
    data = None

    model_info = None

    data = Project.from_user(current_user.user_id)
    if Project.check_auth(current_user.user_id, int(project_id)):
        project_specific_data = Project.get_one(current_user.user_id,
                                                int(project_id))

    if project_specific_data[0]['model_available']:
        model_info = Database.find_one(
            collection="models",
            query={"project_id": project_specific_data[0]['project_id']})

    print(model_info)

    try:
        # try to match the pages defined in -> pages/<input file>
        return render_template('pages/prediction_dashboard.html',
                               data=data,
                               project_specific_data=project_specific_data,
                               model_info=model_info)

    except:

        return render_template('pages/error-404.html')
Exemplo n.º 7
0
def dataset_raw_data(project_id, dataset_id):
    """
    RAW Data exploaration\n
    Allows an ADMIN user to explore user dataset
    through its dashboard and see all the raw not pruned data
    user login status. If dataset not found then redirect 404.\n\n

    method: GET\n

    API/URL must be accessed with GET request and supply project_id and dataset_id in the URL\n

    Args:
        project_id (str): ID of the poject need to be sent in url. It is made to do so via Front end href
        dataset_id (str): ID of the dataset need to be sent in url. It is made to do so via Frontend href

    Returns:
        view: A flask view for the raw data html

    """
    if not current_user.is_authenticated:
        print('not logged in')
        return redirect(url_for('login'))

    content = None
    data = None
    data = Project.from_user(current_user.user_id)
    if Project.check_auth(current_user.user_id, int(project_id)):
        project_specific_data = Project.get_one(current_user.user_id,
                                                int(project_id))
        print(project_specific_data)

    table_html, titles = Analysis.get_data_head(app.config['UPLOAD_FOLDER'] +
                                                'dataset/' + dataset_id)

    try:
        # try to match the pages defined in -> pages/<input file>
        return render_template('pages/raw_data.html',
                               data=data,
                               project_specific_data=project_specific_data,
                               tables=table_html,
                               titles=titles,
                               active_dataset=dataset_id)

    except:

        return render_template('pages/error-404.html')
Exemplo n.º 8
0
def dataset_schema(project_id):
    if not current_user.is_authenticated:
        print('not logged in')
        return redirect(url_for('login'))

    content = None
    data = None
    data = Project.from_user(current_user.user_id)
    if Project.check_auth(current_user.user_id, int(project_id)):
        project_specific_data = Project.get_one(current_user.user_id, int(project_id))
        print(project_specific_data)


    try:
        # try to match the pages defined in -> pages/<input file>
        return render_template( 'pages/dataset_schema.html', data=data, project_specific_data=project_specific_data)
    
    except:
        
        return render_template( 'pages/error-404.html' )
Exemplo n.º 9
0
def customer_dashboard(project_id):
    if not current_user.is_authenticated:
        print('not logged in')
        return redirect(url_for('login'))

    content = None
    data = None
    data = Project.from_user(current_user.user_id)

    project_specific_data = []
    html = None
    titles = None

    model_info = None
    if Project.check_auth(current_user.user_id, int(project_id)):
        project_specific_data = Project.get_one(current_user.user_id,
                                                int(project_id))
        print(project_specific_data)

    if project_specific_data[0]['model_available']:
        model_info = Database.find_one(
            collection="models",
            query={"project_id": project_specific_data[0]['project_id']})

    print(model_info)

    try:
        # try to match the pages defined in -> pages/<input file>
        responseObject = {
            "data": data,
            "project_specific_data": project_specific_data,
            "model_info": model_info
        }
        return make_response(jsonify(responseObject)), 201

    except:
        responseObject = {
            'status': 'fail',
            'message': 'Some error occurred with database. Please try again.'
        }
        return make_response(jsonify(responseObject)), 201
Exemplo n.º 10
0
def dataset_schema(project_id):
    """
    Data Schema mapping\n
    To allow ADMIN user to set data schema for AUTOML
    Allows an ADMIN user to change/set data schema for AUTOML\n\n

    method: GET\n

    API/URL must be accessed with GET request and supply project_id in the URL\n

    Args:
        project_id (str): ID of the poject need to be sent in url. It is made to do so via Front end href
    
    Returns:
        view: a url VIEW the project's data schema mapping after verfying 
          user login status. If project not found then redirect 404.
    """
    if not current_user.is_authenticated:
        print('not logged in')
        return redirect(url_for('login'))

    content = None
    data = None
    data = Project.from_user(current_user.user_id)
    if Project.check_auth(current_user.user_id, int(project_id)):
        project_specific_data = Project.get_one(current_user.user_id,
                                                int(project_id))
        print(project_specific_data)

    try:
        # try to match the pages defined in -> pages/<input file>
        return render_template('pages/dataset_schema.html',
                               data=data,
                               project_specific_data=project_specific_data)

    except:

        return render_template('pages/error-404.html')
Exemplo n.º 11
0
def customer_dashboard(project_id):
    """
    STRICT api for mobile team and customer web Ui team to use
    Retunrs all CUSTOEMR deeplearning model satas. Data set for the CUSTOMER USER
    if any error occurs then JSON will contain error message. \n\n

    API/URL must be accessed with GET request and supply project_id the URL\n

    method: GET\n
    Args:
        project_id (str): ID of the poject/Customer need to be sent in url. It is made to do so via Front end href
    
    Returns:
        response: JSON object
    
    On Success \n
    response = {
        "data":data, 
        "project_specific_data":project_specific_data, 
        "model_info":model_info
    }
    \n
    On Fail:\n
    response = {
        'status': 'fail',
        'message': 'Some error occurred with database. Please try again.'
    }
    \n
    
    """
    if not current_user.is_authenticated:
        print('not logged in')
        return redirect(url_for('login'))

    content = None
    data = None
    data = Project.from_user(current_user.user_id)

    project_specific_data = []
    html = None
    titles = None

    model_info = None
    if Project.check_auth(current_user.user_id, int(project_id)):
        project_specific_data = Project.get_one(current_user.user_id,
                                                int(project_id))
        print(project_specific_data)

    if project_specific_data[0]['model_available']:
        model_info = Database.find_one(
            collection="models",
            query={"project_id": project_specific_data[0]['project_id']})

    print(model_info)

    try:
        # try to match the pages defined in -> pages/<input file>
        responseObject = {
            "data": data,
            "project_specific_data": project_specific_data,
            "model_info": model_info
        }
        return make_response(jsonify(responseObject)), 201

    except:
        responseObject = {
            'status': 'fail',
            'message': 'Some error occurred with database. Please try again.'
        }
        return make_response(jsonify(responseObject)), 201