Ejemplo n.º 1
0
    def test_6_scale_up_and_notify(self):
        # Request resources
        num_resources = 1
        group_name = "increase"
        with TaskGroup(group_name):
            waiter_task()
            time.sleep(1)
            compss_request_resources(num_resources, group_name)

        # The implicit barrier of the group will wait until my_task is cancelled by the resources notification

        # Resource mechanisms are already checked by other methods (the runtime here can destroy machines
        # because a core element is created so we don't really know how many resources there will be.

        # Result script must check that task was cancelled
        print("Result script must check that task was cancelled")
Ejemplo n.º 2
0
    def _scale_up(self, num_resources):
        print("- Scaling up " + str(num_resources))

        # Retrieve number of resources
        cn1 = compss_get_number_of_resources()

        # Request resources
        compss_request_resources(num_resources, None)

        # Wait for completion
        time.sleep(TIME_PETITION)

        # Retrieve number of resources and check the increase
        cn2 = compss_get_number_of_resources()
        print("CN before = " + str(cn1) + " , CN after = " + str(cn2))
        self.assertEquals(cn1 + num_resources, cn2)
Ejemplo n.º 3
0
def test_dummy_api():
    from pycompss.api.dummy.api import compss_start
    from pycompss.api.dummy.api import compss_stop
    from pycompss.api.dummy.api import compss_file_exists
    from pycompss.api.dummy.api import compss_open
    from pycompss.api.dummy.api import compss_delete_file
    from pycompss.api.dummy.api import compss_wait_on_file
    from pycompss.api.dummy.api import compss_wait_on_directory
    from pycompss.api.dummy.api import compss_delete_object
    from pycompss.api.dummy.api import compss_barrier
    from pycompss.api.dummy.api import compss_barrier_group
    from pycompss.api.dummy.api import compss_wait_on
    from pycompss.api.dummy.api import compss_get_number_of_resources
    from pycompss.api.dummy.api import compss_request_resources
    from pycompss.api.dummy.api import compss_free_resources
    from pycompss.api.dummy.api import TaskGroup

    file_name = "simulated_file.txt"
    file_names = ["simulated_file1.txt", "simulated_file2.txt"]
    directory_name = "simulated_directory"
    directory_names = ["simulated_directory1", "simulated_directory2"]
    group_name = "simulated_group"
    obj = [1, 2, 3]
    num_resources = 1

    with open(file_name, "w") as f:
        f.write("some content")
    os.mkdir(directory_name)

    for f_name in file_names:
        with open(f_name, "w") as f:
            f.write("some content")
    for d_name in directory_names:
        os.mkdir(d_name)

    compss_start(log_level="off", interactive=False)
    compss_stop(code=0)
    compss_file_exists(file_name)
    compss_file_exists(*file_names)
    compss_open(file_name, mode="r")
    compss_delete_file(file_name)
    compss_delete_file(*file_names)
    compss_wait_on_file(file_name)
    compss_wait_on_file(*file_names)
    compss_wait_on_directory(directory_name)
    compss_wait_on_directory(*directory_names)
    compss_delete_object(obj)
    compss_delete_object(*obj)
    compss_barrier(no_more_tasks=False)
    compss_barrier_group(group_name)
    compss_wait_on(obj)
    compss_wait_on(*obj)
    compss_get_number_of_resources()
    compss_request_resources(num_resources, group_name)
    compss_free_resources(num_resources, group_name)

    with TaskGroup(group_name, implicit_barrier=True):
        # Empty task group check
        pass

    os.remove(file_name)
    os.rmdir(directory_name)

    for f_name in file_names:
        os.remove(f_name)
    for d_name in directory_names:
        os.rmdir(d_name)