How to use invocation_done method in localstack

Best Python code snippet using localstack_python

multiwren.py

Source:multiwren.py Github

copy

Full Screen

1import wren2import time3import boto3 4import uuid5import numpy as np6import time7from multiprocessing.pool import ThreadPool8MAT_N = 40969def compute_flops(loopcount):10 11 A = np.arange(MAT_N**2, dtype=np.float64).reshape(MAT_N, MAT_N)12 B = np.arange(MAT_N**2, dtype=np.float64).reshape(MAT_N, MAT_N)13 t1 = time.time()14 for i in range(loopcount):15 c = np.sum(np.dot(A, B))16 FLOPS = 2 * MAT_N**3 * loopcount17 t2 = time.time()18 return FLOPS / (t2-t1)19if __name__ == "__main__":20 t1 = time.time()21 sdbclient = boto3.client('sdb', region_name='us-west-2')22 job_id = str(uuid.uuid1())23 print "job_id=", job_id24 N = 1025 LOOPCOUNT = 526 extra_env = {"OMP_NUM_THREADS" : "1"} 27 pool = ThreadPool(64)28 29 call_result_objs = []30 for i in range(N):31 def f():32 wren.call_async(compute_flops, LOOPCOUNT, job_id = job_id, 33 extra_env=extra_env)34 cb = pool.apply_async(f)35 call_result_objs.append(cb)36 invocation_done = False37 while not invocation_done:38 invocation_done = True39 for result_obj in call_result_objs:40 if not result_obj.ready() :41 invocation_done = False42 time.sleep(1)43 44 print "invocation done, dur=", time.time() - t145 result_count = 046 while result_count < N:47 r = sdbclient.select(SelectExpression="select count(*) from test_two where job_id='{}'".format(job_id))48 result_count = int(r['Items'][0]['Attributes'][0]['Value'])49 est_flop = 2 * result_count * LOOPCOUNT * MAT_N**350 51 est_gflops = est_flop / 1e9/(time.time() - t1)52 print "jobs done: {:5d} runtime: {:5.1f}s {:8.1f} GFLOPS ".format(result_count, 53 time.time()-t1, 54 est_gflops)55 if result_count == N:56 break57 58 time.sleep(1)59 all_done = time.time()60 total_time = all_done - t161 print "total time", total_time62 est_flop = result_count * 2 * LOOPCOUNT * MAT_N**363 ...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful