Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

util(planner): move get in-flight-apps to util #80

Merged
merged 1 commit into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 1 addition & 24 deletions faasmctl/tasks/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
26 changes: 25 additions & 1 deletion faasmctl/util/planner.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion faasmctl/util/version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FAASMCTL_VERSION = "0.39.0"
FAASMCTL_VERSION = "0.40.0"


def get_version():
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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="[email protected]" },
]
Expand Down