예제 #1
0
def invoke(ctx, func, native=False, iface=None, np=8):
    """
    Invoke one of the ParRes Kernels functions
    """
    if func not in PRK_CMDLINE:
        print("Invalid PRK function {}".format(func))
        return 1

    cmdline = PRK_CMDLINE[func]

    if func == "random" and not is_power_of_two(np):
        print("Must have a power of two number of processes for random")
        exit(1)
    elif func == "sparse" and not (SPARSE_GRID_SIZE % np == 0):
        print(
            "To run sparse, grid size must be a multiple of --np (currently grid_size={} and np={})"
            .format(SPARSE_GRID_SIZE, np))
        exit(1)

    if native:
        executable = PRK_NATIVE_EXECUTABLES[func]
        cmd_out = mpi_run(executable, iface=iface, cmdline=cmdline, np=np)
        cmd_out = cmd_out.decode()
        print(cmd_out)
    else:
        host, port = get_invoke_host_port()
        cmd_out = invoke_impl(FAASM_USER,
                              func,
                              cmdline=cmdline,
                              host=host,
                              port=port,
                              mpi_world_size=np)

    _parse_prk_out(func, cmd_out)
예제 #2
0
def mapping(ctx):
    """
    Run genomics mapping
    """
    read_idxs, _ = get_reads_from_dir()

    # Iterate through and make the calls to the worker
    call_ids = list()
    for read_idx in read_idxs:
        print("Invoking worker for read chunk {}".format(read_idx))
        call_id = invoke_impl("gene",
                              "mapper",
                              input="{}".format(read_idx),
                              async=True,
                              poll=False)
        call_ids.append(call_id)

    # Poll for completion of each read
    completed_read_idxs = list()
    host, port = get_invoke_host_port()
    print("Polling workers...")

    while len(completed_read_idxs) < len(read_idxs):
        for i, read_idx in enumerate(read_idxs):
            sleep(0.5)

            # See whether this call is still running
            call_id = call_ids[i]
            result, output = status_call_impl(call_id, host, port)
            if result == STATUS_RUNNING:
                continue

            # Check for success or failure
            if result == STATUS_SUCCESS:
                # Download the results of this read
                print("Read chunk {} completed. Downloading output".format(
                    read_idx))
                state_key = "output_read_{}".format(read_idx)

                output_dir = join(FAASM_DATA_DIR, "genomics_output")
                if not exists(output_dir):
                    makedirs(output_dir)

                output_file = join(output_dir, state_key)
                host, port = get_upload_host_port(None, None)
                download_binary_state("gene",
                                      state_key,
                                      output_file,
                                      host=host,
                                      port=port)

            elif result == STATUS_FAILED:
                print("Read chunk {} failed: {}", read_idx, output)

            # Check if we're done
            completed_read_idxs.append(read_idx)

    print("All read chunks finished")
예제 #3
0
def flush(ctx):
    """
    Flush workers
    """
    host, port = get_invoke_host_port()
    host = host if host else "127.0.0.1"
    port = port if port else 8080

    flush_call_impl(host, port)
예제 #4
0
def status(ctx, call_id, host=None, port=None):
    """
    Get the status of an async function call
    """
    k8s_host, k8s_port = get_invoke_host_port()
    host = host if host else k8s_host
    port = port if port else k8s_port

    status_call_impl(call_id, host, port)
예제 #5
0
    def __init__(self,
                 threads=4,
                 total_connections=20,
                 delay_ms=0,
                 duration_secs=10):
        super().__init__(None)

        self.wrk_bin = join(FAASM_HOME, "tools", "wrk")
        self.threads = threads
        self.total_connections = total_connections
        self.delay_ms = delay_ms

        self.host, self.port = get_invoke_host_port()
        self.url = "http://{}:{}".format(self.host, self.port)

        self.duration_secs = duration_secs
        self.wrk_output = "/tmp/wrk_results.txt"
예제 #6
0
def _do_deploy_knative_native(func_name, image_name, replicas):
    faasm_config = get_faasm_config()
    if not faasm_config.has_section("Faasm"):
        print("Must have faasm config set up with Faasm section")
        return 1

    # Host and port required for chaining native functions
    invoke_host, invoke_port = get_invoke_host_port()

    _deploy_knative_fn(
        func_name,
        image_name,
        replicas,
        1,
        NATIVE_WORKER_ANNOTATIONS,
        extra_env={
            "COLD_START_DELAY_MS": "1000",
            "FAASM_INVOKE_HOST": invoke_host,
            "FAASM_INVOKE_PORT": invoke_port,
        },
    )
예제 #7
0
                async=False,
                knative=True,
                native=False,
                ibm=False,
                poll=False,
                cmdline=None,
                mpi_world_size=None,
                poll_interval_ms=1000):
    faasm_config = get_faasm_config()

    # Provider-specific stuff
    if ibm:
        host = faasm_config["IBM"]["k8s_subdomain"]
        port = 8080
    elif knative:
        host, port = get_invoke_host_port()

    # Defaults
    host = host if host else "127.0.0.1"
    port = port if port else 8080

    # Polling always requires async
    if poll:
        async = True

        # Create URL and message
    url = "http://{}".format(host)
    if not port == "80":
        url += ":{}".format(port)

    if py: