Exemple #1
0
def main():
    # file name will start with "als_prefix", which looks like "als3_"
    file_name_suffix = "eval_results.bin"

    # keep track of average and number of data points for each test
    average_agreement = []
    num_data_points = []

    factor_list = [3, 5, 7, 9, 11]

    for factor in factor_list:
        als_prefix = "als" + str(factor) + "_"

        # issue "als_eval" test for the current factor and print results
        length = movie_lens_data.get_als_obj(als_prefix +
                                             "user_ratings_test_length")

        # sends an "als_eval" command to cluster nodes.
        if cluster.cluster_info is None:
            print("Cannot connect to cluster.")
            return

        cluster.send_command({
            "op": "distribute",
            "worker_op": "als_eval",
            "setup_param": factor,
            "length": length
        })

        cluster.wait_for_completion()
        cluster.print_status()
        print()

        results = cluster.merge_list_results(als_prefix + file_name_suffix)
        user_ids, agreements = zip(*results)

        my_util.print_rank_agreement_results(agreements, "ALS " + str(factor))
        print()

        # update "average_agreement" and "num_data_points"
        average_agreement.append(sum(agreements) / len(agreements))
        num_data_points.append(len(agreements))

    # print a summary table for all factors
    print("factor".center(10), "average agreement".center(25),
          "number of values".center(20))

    for i in range(0, len(factor_list)):
        print(
            str(factor_list[i]).center(10),
            str(average_agreement[i]).center(25),
            str(num_data_points[i]).center(20))

    print('\a')
    def _register_with_cluster(self):
        """Register with cluster server. Return True for success."""
        try:
            reply = cluster.send_command(
                {
                    "op": "register",
                    "address": self.address,
                    "port_number": port_number,
                    "cpu_count": multiprocessing.cpu_count()
                },
                wait_for_reply=True)

            if reply["op"] == "reply":
                # print cluster information
                cluster_info = cluster.cluster_info
                print("Worker server at", self.address, "port number",
                      port_number)
                print("Joined cluster at", cluster_info[0]["address"],
                      "port number", cluster_info[0]["port_number"])
                return True

            else:
                return False

        except Exception as ex:
            print("Error:", ex)
            return False
def build_with_cluster(buff_point, buff_limit, length, output_file_name):

    setup_param = {"buff_point": buff_point, "buff_limit": buff_limit}

    cluster.send_command({
        "op": "distribute",
        "worker_op": "build_similar_movies_db",
        "setup_param": setup_param,
        "length": length
    })

    cluster.wait_for_completion()
    cluster.print_status()
    print()

    cluster.merge_list_results_into_dict(output_file_name)
    print("similar_movies.bin has been built")
    print('\a')
Exemple #4
0
def main():
    print("Creating input.bin")
    x1, x2 = _setup_problem(10000)

    # Trigger an add operation by sending a distributed
    # add command to cluster server.
    if cluster.cluster_info is None:
        print("Cannot connect to cluster.")
        return

    cluster.send_command({
        "op": "distribute",
        "worker_op": "add",
        "length": len(x1)
    })

    cluster.wait_for_completion()
    cluster.print_status()
    cluster.merge_list_results("output.bin")

    _check_output_bin()
def main():
    length = movie_lens_data.get_input_obj("user_ratings_test_length")

    # Sends a "tag_ls_eval" command to cluster nodes.
    if cluster.cluster_info is None:
        print("Cannot connect to cluster.")
        return

    cluster.send_command({
        "op": "distribute",
        "worker_op": "tag_ls_eval",
        "length": length
    })

    cluster.wait_for_completion()
    cluster.print_status()
    print()

    file_name = "tag_ls_eval_results.bin"
    results = cluster.merge_list_results(file_name)
    user_ids, agreements = zip(*results)

    my_util.print_rank_agreement_results(agreements, "tag least squares")
    print('\a')
 def _send_done_reply(self):
     cluster.send_command({
         "op": "done",
         "address": self.address,
         "port_number": port_number
     })