Esempio n. 1
0
File: call.py Progetto: faasm/faasm
def _do_single_call(host, port, msg, quiet):
    url = "http://{}".format(host)
    if port != 80:
        url += ":{}/".format(port)

    headers = get_knative_headers()
    return do_post(url, msg, headers=headers, quiet=quiet, json=True)
Esempio n. 2
0
def _do_single_call(host, port, msg, quiet):
    url = "http://{}".format(host)
    if port != 80:
        url += ":{}/".format(port)

    # If wasm, can always use the faasm worker for getting status
    headers = get_knative_headers()

    return do_post(url, msg, headers=headers, quiet=quiet, json=True)
Esempio n. 3
0
def all(ctx):
    """
    Flush functions, state and shared files from all workers
    """
    host, port = get_invoke_host_port()
    msg = {
        "type": FAABRIC_MSG_TYPE_FLUSH,
    }

    url = "http://{}:{}".format(host, port)
    headers = get_knative_headers()
    return do_post(url, msg, headers=headers, quiet=False, json=True)
Esempio n. 4
0
def invoke_impl(
    user,
    func,
    input=None,
    py=False,
    asynch=False,
    knative=True,
    poll=False,
    cmdline=None,
    mpi_world_size=None,
    debug=False,
    sgx=False,
):
    host, port = get_invoke_host_port()

    # Polling always requires asynch
    if poll:
        asynch = True

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

    if py:
        msg = {
            "user": PYTHON_USER,
            "function": PYTHON_FUNC,
            "async": asynch,
            "py_user": user,
            "py_func": func,
            "python": True,
        }
    else:
        msg = {
            "user": user,
            "function": func,
            "async": asynch,
        }

    if sgx:
        msg["sgx"] = sgx

    if input:
        msg["input_data"] = input

    if cmdline:
        msg["cmdline"] = cmdline

    if mpi_world_size:
        msg["mpi_world_size"] = mpi_world_size

    # Knative must pass custom headers
    if knative:
        headers = get_knative_headers()
    else:
        headers = {}

    if asynch:
        return _async_invoke(url,
                             msg,
                             headers=headers,
                             poll=poll,
                             host=host,
                             port=port)
    else:
        return do_post(url, msg, headers=headers, json=True, debug=debug)