Quantcast
Channel: 🎛️ Dash - Plotly Community Forum
Viewing all articles
Browse latest Browse all 6271

Dcc.interval not responding when running a function

$
0
0

I have to watch a directory over ftp and whenever a new file appears in the directory I want to copy the file over my local machine , do some data extraction and processing , append to a data frame and repeatedly plot the data frame with the new appended values , I am using Dash and plotly for this purpose and using dcc.interval to run the update function every interval, when I run the app I get no errors but the function doesn’t start

see code:

dbc.Row([

        dbc.Col(

            dcc.Graph(id='poa_s1'), width=6 ),

        dbc.Col(dcc.Graph(id='poa_s2'),  width=6 ),

        

        dbc.Col(dcc.Interval( 

        id = 'frame_update', 

        interval = 10*1000, 

        n_intervals = 0)

        )

                

    ]),

    

    dbc.Row([

        dbc.Col(html.H2(id='hidden-div', children='Shot Number' ))

        ])

                        

        ])

    

])

def uddate_attribute_frame(n):

    print("Function started")

    ftp = FTP()

    ftp.connect('10.199.44.240', 21)

    ftp.login('display')

    ftp.cwd('/home/display/test_qc')

    print("Connection Established {}".format(ftp.getwelcome()))

    direct = 'C:\\Users\\QC\\Desktop\\Gunlink_local\\'

    old_files = ['1']

    #print(old_files)

    new_files = ftp.nlst()

    #print(new_files)

    #print(new_files)

    if len(old_files) != 0 and new_files != old_files:

        changes = [i for i in new_files if i not in old_files]

        # print(changes)

        for x in changes:

            filename = str(direct + x)

            print(filename)

            localfile = open(filename, 'wb')

            ftp.retrbinary('RETR'+' ' + x , localfile.write, 1024)

            localfile.close()

            sensor_arr , nfh_arr, gcs, mask, chan  = extract_data(filename)

            i=0

            num_cluster = 18

            sequence = gcs[11:19]

            shot = gcs[25:29]

            while i < num_cluster:

                poa, pot, bp = bubble_attributes(apply_filter(nfh_arr[15:500, i]))

                values = [shot, chan, poa, pot, bp]

                zipped = zip(cols, values)

                a_dictionary = dict(zipped)

                data.append(a_dictionary)

            all_results = all_results.append(data, True)

    return str('Processed Shot number : {}'.format(shot))

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 6271

Trending Articles