Exemple #1
0
def create_list():
    try:
        parsed = ListSchema().load(request.json)
        result = client.create_list(g.profile["email"], parsed["name"])
        return jsonify(result), 201
    except ValidationError as e:
        return jsonify(e.messages), 400
    except Exception as e:
        print(f"error creating a wishlist: {str(e)}")
        return jsonify({"error": str(e)}), 500
def runapp():
     
    output = "<html><body><div style='font-family: Arial '>"
    output += "<h2>Generating Series Live Demonstration</h2>"
    output += "<br>"
    output += "<b>Plan, Source Code and Documentation: <a href='https://github.com/hyunwookshin/generating_series'>github/hyunwookshin/generating_series</b></a><br>"
    output += "Last edited: May 21, 2014<br>"
    output += "<br>"
    output += "In this example, Let weight function W(I) = |I| (size of I), where I is a set of some integers and I is a subset of S" + "<br>"
    output += "<img src='https://raw.githubusercontent.com/hyunwookshin/generating_series/master/equation/equation.png' width='500px'><br>"
    for n in 2,4,8:
        output += "<h3><b><i>n</i></b> = " + str(n) + "</h3><br>"
        output += "Automatically entered a number <i>n</i> = " + str(n) + " such that <b>S</b> is a set of all subsets of  <b>{1,..," + str(n) + "}</b><br>"
        output += "S = {" + ", ".join(str(i) for i in create_list(n))+ "} <br>"
        start_time = time.time() 
        output += "Sum: " + str(compute(create_list(n),n,'not_fixed')) + "<br>"
        output += "Compute Time " + str(time.time() - start_time) + " seconds<br>" 
        output += "<br>"
    output += "</div></body></html>" + "<br>"
    return output
        manager_2 = Manager() 
        result_lst = manager_2.list()  
        
        # REDUCE --------------------------------------------------------
        for combined_list in combined_lists:
                r = Process(target=reduce, args=(key,combined_list,result_lst))
                jobs.append(r)
                r.start()

        print ("Wait for Catch Up\n")
        for r in jobs:
            r.join()     
            
        print ("Up to Reducing Stage:", str(time.time() - start_time ) + " seconds"  )
        print("Length of List of List: ", len_lst )
        return sum(result_lst)
        
    except NameError as e:
        print('Usage Error:', e)
        
if __name__ == "__main__":
    with open("output.txt", "a") as myfile:
        
    #   compute(create_list(n),,'fixed') # run test for fixed number of map nodes    
    
       for n in [4,11,12,13,14,15,16,17]: # run test for list of all subsets of {1...n}
           start_time = time.time()
           computed = str(compute(create_list(n), n))
           myfile.write(str(n) + " "+ computed + " "+ str(time.time() - start_time) +"\n")  
           myfile.flush()
    pass
    #---------------------------------------------------
    # Shuffle/Reduce
    
    jobs = []   
    manager_2 = Manager()    
    result_lst = manager_2.list()    


    for key in range(emissions[-1][1],emissions[-1][2]+5):
        key_list = [1 for x in emissions if x[0] == key]
        q = Process(target=reduce, args=(key,key_list,result_lst))
        jobs.append(q)
        q.start()

    print ("Wait for Catch Up\n")
    for q in jobs:
        q.join()     
        
    print ("Up to Reducing Stage:", str(time.time() - start_time ) + " seconds"  )
    print("Input Size: ", len_list_of_list )
    return sum(result_lst)

# list_generator returns a list [1...n]

def list_generator (n):
    return list(range(1,n+1))

if __name__ == "__main__":
    print(compute(create_list()))