Beispiel #1
0
def sidebar_area():
    
    st.sidebar.subheader('Search the Most Similar Product')
    toplist = [i for i in range(1, 21)]
    top = st.sidebar.selectbox('The Number of Most Similar Product', toplist)
    
    selectlist = ['Based on 10 Similar Product Name', 'Based on Product ID']
    options = list(range(len(selectlist)))
    selectval = st.sidebar.selectbox('Input Selection Method', options,
                                  format_func=lambda x: selectlist[x])
    
    urlParams.set_field('top', top)
    urlParams.set_field('selval', selectval)
    
    if(selectval == 1):
        st.sidebar.subheader('Using Product ID as Input')
        selstr = st.sidebar.text_input('Product ID', '32366')
        selstr = selstr.lower()
        
    elif(selectval == 0):
        st.sidebar.subheader('Using Similar Name as Input')
        selstr = st.sidebar.text_input('Food Name', 'indomie')
        selstr = selstr.lower()
    
    urlParams.set_field('selstr', selstr)
    
    conn = tg_helper.connect_to_tigergraph()
    
    return {'top': top, 'selval': selectval, 'selstr': selstr, 'conn': conn}
Beispiel #2
0
def sidebar_area():
    
    st.sidebar.subheader('Select the Number of Cluster')
    clusnumlist = [2, 4]
    clusnum = st.sidebar.selectbox('Number of Cluster', clusnumlist)
    
    conn = tg_helper.connect_to_tigergraph()
    return {'clusnum': clusnum, 'conn': conn}
Beispiel #3
0
def sidebar_area():

    st.sidebar.subheader('Enter the Name of the Product')
    fdnm = st.sidebar.text_input('Food Name', 'nissin')
    fdnm = fdnm.lower()

    urlParams.set_field('fdnm', fdnm)

    conn = tg_helper.connect_to_tigergraph()

    return {'fdnm': fdnm, 'conn': conn}
Beispiel #4
0
def sidebar_area():

    st.sidebar.subheader('Select the Number of Top Halal Ingredients')
    ingnumlist = [i for i in range(1, 50)]
    ingnum = st.sidebar.selectbox('Number of Top Ingredients', ingnumlist)
    
    st.sidebar.subheader('Select the Number of Top Halal Manufacturers')
    mannumlist = [i for i in range(1, 50)]
    mannum = st.sidebar.selectbox('Number of Top Manufacturers', mannumlist)
    
    urlParams.set_field('ingnum', ingnum)
    urlParams.set_field('mannum', mannum)
    
    conn = tg_helper.connect_to_tigergraph()
    
    return {'ingnum': ingnum, 'mannum': mannum, 'conn': conn}
def sidebar_area():

    logger.info('sidebar_area')

    st.sidebar.subheader('Select account for 360 view')
    idList = [i for i in range(1, 500)]
    user_id = st.sidebar.selectbox('User ID ', idList)
    urlParams.set_field('user_id', user_id)

    # Optional, can replace with: conn = tg_helper.connect_to_tigergraph()
    conn = None
    st.sidebar.subheader('Optional: Override tigergraph.env')
    tg_host = st.sidebar.text_input('TigerGraph Host')
    tg_username = st.sidebar.text_input('TigerGraph Username')
    tg_password = st.sidebar.text_input('TigerGraph Password', type='password')
    tg_secret = st.sidebar.text_input('TigerGraph Secret', type='password')
    tg_graphname = st.sidebar.text_input('TigerGraph Graphname')
    if st.sidebar.button("Connect"):
        try:
            conn = tg.TigerGraphConnection(
                host=tg_host,
                graphname=tg_graphname,
                username=tg_username,
                password=tg_password,
                version=tg_helper.TIGERGRAPH_CONNECTION_VERSION)
            if tg_secret:
                conn.getToken(tg_secret)
            else:
                conn.getToken(conn.createSecret())
        # FIXME: What is the expected exn?
        except Exception as e:  # noqa: E722
            logger.error('Failed dynamic tg connection: %s', e, exc_info=True)
            st.sidebar.error("Failed to Connect")
            st.sidebar.error(e)
            return None
    else:
        conn = tg_helper.connect_to_tigergraph()
    if conn is None:
        logger.error('Cannot run tg demo without creds')
        st.write(
            RuntimeError(
                'Demo requires a TigerGraph connection. Put creds into left sidebar, or fill in envs/tigergraph.env & restart'
            ))
        return None

    st.sidebar.success("Connnected Successfully")
    return {'user_id': user_id, 'conn': conn}
Beispiel #6
0
def sidebar_area():

    conn = tg_helper.connect_to_tigergraph()
    return {'conn': conn}
Beispiel #7
0
node_id_col = 'id'
src_id_col = 'from_id'
dst_id_col = 'to_id'
node_label_col = 'Source_Type'
edge_label_col = 'Destination_Type'

# Setup a structure to hold metrics
metrics = {
    'tigergraph_time': 0,
    'graphistry_time': 0,
    'node_cnt': 0,
    'edge_cnt': 0,
    'prop_cnt': 0
}

conn = tg_helper.connect_to_tigergraph()


# Define the name of the view
def info():
    return {
        'id': app_id,
        'name': 'TigerGraph: Fraud Filter circle',
        'tags': ['demo', 'tigergraph_demo_circle']
    }


def run():
    run_all()