Skip to content

Commit

Permalink
Ak/fix addon mounts (#38)
Browse files Browse the repository at this point in the history
* mounts in HA aren't as clean as tests..

* add container envs for mapping
  • Loading branch information
akshaya-a authored Apr 5, 2024
1 parent cdcf870 commit d8ae8e0
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 12 deletions.
1 change: 1 addition & 0 deletions mindctrl-addon/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ discovery:
- mindctrl
map:
- share:rw # Used for artifacts storage, expects "tracking" share in HA.
- addon_config:rw # Used for replay server inputs and outputs
environment:
FORWARDED_ALLOW_IPS: "172.30.32.2" # Supervisor: https://developers.home-assistant.io/docs/add-ons/presentation#ingress
image: "ghcr.io/akshaya-a/{arch}-mindctrl"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
# Example init script, runs before any other service
# ==============================================================================

bashio::log.level "all"
bashio::log.info "Creating multiserver python env"


Expand Down
16 changes: 8 additions & 8 deletions mindctrl-addon/rootfs/usr/bin/run_gateway.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
echo "Starting MLflow Deployment Server in $PWD"
# TODO: add the replay env var to k8s spec
export MINDCTRL_CONFIG_REPLAY=${MINDCTRL_CONFIG_REPLAY:="false"}
export MINDCTRL_REPLAY_DIR=${MINDCTRL_REPLAY_DIR:="/replays"}
export MINDCTRL_RECORDING_DIR=${MINDCTRL_RECORDING_DIR:="/recordings"}
export MLFLOW_DEPLOYMENTS_CONFIG=${MLFLOW_DEPLOYMENTS_CONFIG:="/config/route-config.yaml"}
export MINDCTRL_REPLAY_DIR=${MINDCTRL_REPLAY_DIR:="/config"}
export MINDCTRL_RECORDING_DIR=${MINDCTRL_RECORDING_DIR:="/config"}
export MLFLOW_DEPLOYMENTS_CONFIG=${MLFLOW_DEPLOYMENTS_CONFIG:="/.context/services/deployments/route-config.yaml"}

if bashio::supervisor.ping; then
bashio::log.info "Supervisor is running, setting config from supervisor"
Expand All @@ -23,21 +23,21 @@ bashio::log.info "MINDCTRL_REPLAY_DIR: $MINDCTRL_REPLAY_DIR"
bashio::log.info "MINDCTRL_RECORDING_DIR: $MINDCTRL_RECORDING_DIR"
bashio::log.info "MLFLOW_DEPLOYMENTS_CONFIG: $MLFLOW_DEPLOYMENTS_CONFIG"
ls -la /
ls -la $MINDCTRL_REPLAY_DIR
ls -la $MINDCTRL_RECORDING_DIR
ls -la $MLFLOW_DEPLOYMENTS_CONFIG
ls -la $MINDCTRL_REPLAY_DIR || true
ls -la $MINDCTRL_RECORDING_DIR || true
ls -la $MLFLOW_DEPLOYMENTS_CONFIG || true
#TODO: convert --replay into an enum and pass it down like another config
bashio::log.info "Starting MLflow Deployment Server with Dapr..."
if [ "$MINDCTRL_CONFIG_REPLAY" == "true" ]; then
bashio::log.red "MINDCTRL_CONFIG_REPLAY is set to true. Running replay server in replay mode"
# https://github.com/dapr/dashboard/issues/195
s6-notifyoncheck dapr run --app-id deployments --app-port 5001 --app-protocol http \
--enable-api-logging --enable-app-health-check --log-level warn --app-health-check-path /health --dapr-http-port 5501 -- \
python3 /.context/services/deployments/replay_server.py --replay --config-path /.context/services/deployments/route-config.yaml --port 5001 --host 0.0.0.0
python3 /.context/services/deployments/replay_server.py --replay --port 5001 --host 0.0.0.0
else
bashio::log.red "MINDCTRL_CONFIG_REPLAY is not set to true. Running replay server in live mode"
# https://github.com/dapr/dashboard/issues/195
s6-notifyoncheck dapr run --app-id deployments --app-port 5001 --app-protocol http \
--enable-api-logging --enable-app-health-check --log-level warn --app-health-check-path /health --dapr-http-port 5501 -- \
python3 /.context/services/deployments/replay_server.py --config-path /.context/services/deployments/route-config.yaml --port 5001 --host 0.0.0.0
python3 /.context/services/deployments/replay_server.py --port 5001 --host 0.0.0.0
fi
18 changes: 15 additions & 3 deletions tests/utils/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,33 @@ def __init__(
_logger.info(
f"Mapping {self.replays_dir}, {self.recordings_dir}, {self.route_config.parent} as /replays, /recordings, /config"
)

container_replay_dir = "/replays"
self.with_volume_mapping(
str(self.replays_dir),
"/replays",
container_replay_dir,
mode="ro",
)
self.with_env("MINDCTRL_REPLAY_DIR", container_replay_dir)

container_recordings_dir = "/recordings"
self.with_volume_mapping(
str(self.recordings_dir),
"/recordings",
container_recordings_dir,
mode="rw",
)
self.with_env("MINDCTRL_RECORDING_DIR", container_recordings_dir)

container_config_dir = "/config"
self.with_volume_mapping(
str(self.replays_dir.parent),
"/config",
container_config_dir,
mode="ro",
)
self.with_env(
"MLFLOW_DEPLOYMENTS_CONFIG", f"{container_config_dir}/route-config.yaml"
)

if self.replay:
assert (self.replays_dir / "replay.json").exists()
self.with_env("MINDCTRL_CONFIG_REPLAY", "true")
Expand Down

0 comments on commit d8ae8e0

Please sign in to comment.