diff --git a/README.md b/README.md index 114f6ad..dc2746a 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ running [Faasm](https://github.com/faasm/faasm) cluster. To install `faasmctl` you need a working `pip` (virtual-)environment. Then: ```bash -pip install faasmctl==0.39.0 +pip install faasmctl==0.40.0 ``` ## Usage diff --git a/faasmctl/tasks/monitor.py b/faasmctl/tasks/monitor.py index 05720a5..0265666 100644 --- a/faasmctl/tasks/monitor.py +++ b/faasmctl/tasks/monitor.py @@ -4,11 +4,8 @@ get_faasm_planner_host_port, ) from faasmctl.util.faasm import FAASM_CLI_IMAGE -from faasmctl.util.gen_proto.planner_pb2 import GetInFlightAppsResponse -from faasmctl.util.planner import get_available_hosts, prepare_planner_msg -from google.protobuf.json_format import Parse +from faasmctl.util.planner import get_available_hosts, get_in_fligh_apps from invoke import task -from requests import post from signal import SIGINT, signal from subprocess import run from sys import exit as sys_exit @@ -48,26 +45,6 @@ def stop_container(): ) -def get_in_fligh_apps(): - host, port = get_faasm_planner_host_port(get_faasm_ini_file()) - url = "http://{}:{}".format(host, port) - planner_msg = prepare_planner_msg("GET_IN_FLIGHT_APPS") - - response = post(url, data=planner_msg, timeout=None) - - if response.status_code != 200: - print( - "Error getting in flight apps (code: {}): {}".format( - response.status_code, response.text - ) - ) - raise RuntimeError("Error getting in flight apps") - - in_flight_apps = Parse(response.text, GetInFlightAppsResponse()) - - return in_flight_apps - - def get_apps_to_be_migrated(registered_workers, in_flight_apps, worker_occupation): """ Helper method that, given the current worker occupation, works out all the diff --git a/faasmctl/util/planner.py b/faasmctl/util/planner.py index 7200264..346ee46 100644 --- a/faasmctl/util/planner.py +++ b/faasmctl/util/planner.py @@ -1,5 +1,9 @@ from faasmctl.util.config import get_faasm_ini_file, get_faasm_planner_host_port -from faasmctl.util.gen_proto.planner_pb2 import AvailableHostsResponse, HttpMessage +from faasmctl.util.gen_proto.planner_pb2 import ( + AvailableHostsResponse, + GetInFlightAppsResponse, + HttpMessage, +) from google.protobuf.json_format import MessageToJson, Parse from requests import post from time import sleep @@ -133,3 +137,23 @@ def wait_for_workers(expected_num_workers, verbose=False): # ---------- # Scheduling State Getters/Setters # ---------- + + +def get_in_fligh_apps(): + host, port = get_faasm_planner_host_port(get_faasm_ini_file()) + url = "http://{}:{}".format(host, port) + planner_msg = prepare_planner_msg("GET_IN_FLIGHT_APPS") + + response = post(url, data=planner_msg, timeout=None) + + if response.status_code != 200: + print( + "Error getting in flight apps (code: {}): {}".format( + response.status_code, response.text + ) + ) + raise RuntimeError("Error getting in flight apps") + + in_flight_apps = Parse(response.text, GetInFlightAppsResponse()) + + return in_flight_apps diff --git a/faasmctl/util/version.py b/faasmctl/util/version.py index 0de495e..ced6b98 100644 --- a/faasmctl/util/version.py +++ b/faasmctl/util/version.py @@ -1,4 +1,4 @@ -FAASMCTL_VERSION = "0.39.0" +FAASMCTL_VERSION = "0.40.0" def get_version(): diff --git a/pyproject.toml b/pyproject.toml index b6bf012..c226309 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "faasmctl" -version = "0.39.0" +version = "0.40.0" authors = [ { name="Faasm Team", email="foo@bar.com" }, ]