ProtoLife / daptics-api

API documentation and clients for the daptics.ai design of experiments engine
https://daptics.ai
GNU General Public License v3.0
1 stars 1 forks source link

`daptics.wait_for_current_task()` should wait for all tasks in queue? #16

Closed nhpackard closed 4 years ago

nhpackard commented 5 years ago

Inside a loop I have following code. It worked fine for gen 3, but failed on gen 4.

Maybe I should follow task = daptics.export_csv(fname,myexps) with a daptics.wait_for_current_task()?? Maybe for gen 3 it finished fast enough to not get tripped up?

Could it be that daptics.wait_for_current_task() should wait for all tasks in queue?

    print('time for gen',daptics.gen,':  ',time.time()-start)

    # put in the responses
    myexps = design['table']
    for i in range(len(myexps['data'])):
        myexps['data'][i][-1]= str(resp[i])

    # e.g. fname = 'Experiments/gen1_experiments.csv'
    task = daptics.export_csv(fname,myexps)

    # save responses and generate next design
    start = time.time()
 task=daptics.put_experiments_csv(DapticsExperimentsType.DESIGNED_WITH_OPTIONAL_EXTRAS,fname) # gen next design
    daptics.wait_for_current_task()
    task = daptics.generate_design()
    daptics.wait_for_current_task()
    print('Done with design.')
    print('time for daptics = ',time.time()-start,"   seconds.")
    print("Now gen = ",daptics.gen)
    fname = 'gen'+str(daptics.gen)+'_experiments.csv'
    # e.g. fname = 'gen1_design.csv'
    print("Saving design to: ",fname)
    design = daptics.export_generated_design_csv(fname) # the new design with blank responses.

I got

time for gen 4 :   1177.0454638004303

Task status = running after 1806 retries...
No current task was found!Done with design.
time for daptics =  2369.008800983429    seconds.
Now gen =  4
Saving design to:  gen4_experiments.csv
---------------------------------------------------------------------------
Exception                                 Traceback (most recent call last)
<ipython-input-30-3bb54a625a83> in <module>
     51     # e.g. fname = 'gen1_design.csv'
     52     print("Saving design to: ",fname)
---> 53     design = daptics.export_generated_design_csv(fname) # the new design with blank responses.
     54 
     55     pool.close()

~/Projects/genelife/fastgenegol/genelifepy/daptics-api/python_client/daptics_client.py in export_generated_design_csv(self, fname, gen)

...

         if result.errors:
---> 52             raise Exception(str(result.errors[0]))
     53 
     54         return result.data

Exception: {'path': ['experiments'], 'message': 'timeout', 'locations': [{'line': 2, 'column': 0}]}
pzingg commented 4 years ago

The rscript-1.9 API should prevent users from starting more than one active task at a time.