Skip to content

Commit

Permalink
Update to dynamic image and namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
JMGaljaard committed Mar 28, 2022
1 parent fa818cf commit f8b6adf
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 9 deletions.
8 changes: 1 addition & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ MAINTAINER Jeroen Galjaard <[email protected]>
# Run build without interactive dialogue
ARG DEBIAN_FRONTEND=noninteractive

# Set environment variables for GLOO and TP (needed for RPC calls)
ENV GLOO_SOCKET_IFNAME=eth0
ENV TP_SOCKET_IFNAME=eth0

# Define the working directory of the current Docker container
WORKDIR /opt/federation-lab

Expand All @@ -27,9 +23,7 @@ RUN --mount=type=cache,target=/root/.cache/pip python3 -m pip install -r require
# Add FLTK and configurations
ADD fltk fltk
ADD configs configs

# Expose default port 5000 to the host OS.
EXPOSE 5000
ADD charts charts

# Update relevant runtime configuration for experiment
COPY configs/ configs/
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ before running into trouble later.

```bash
cd charts
helm install flearner ./federator --namespace test -f fltk-values.yaml
helm install flearner ./orchestrator --namespace test -f fltk-values.yaml
```

This will spawn an `fl-server` Pod in the `test` Namespace, which will spawn Pods (using `V1PyTorchJobs`), that
Expand Down
4 changes: 4 additions & 0 deletions fltk/launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ def launch_orchestrator(args: Namespace = None, conf: BareConfig = None):
logging.info("Loading in cluster configuration file")
config.load_incluster_config()

logging.info("Pointing configuration to in cluster configuration.")
conf.cluster_config.load_incluster_namespace()
conf.cluster_config.load_incluster_image()

arrival_generator = ExperimentGenerator()
cluster_manager = ClusterManager()

Expand Down
29 changes: 28 additions & 1 deletion fltk/util/config/base_config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from dataclasses import dataclass, field
from pathlib import Path

import yaml
from dataclasses_json import config, dataclass_json


Expand Down Expand Up @@ -85,8 +86,34 @@ class ClusterConfig:
orchestrator: OrchestratorConfig
client: ClientConfig
wait_for_clients: bool = True
# TODO: Pull info from the environment (Helm chart also).
namespace: str = 'test'
image: str = 'gcr.io/test-bed-distml/fltk:latest'
image: str = 'fltk:latest'

def load_incluster_namespace(self):
with open("/var/run/secrets/kubernetes.io/serviceaccount/namespace") as f:
current_namespace = f.read()
self.namespace = current_namespace

def load_incluster_image(self):
"""
Function to load the in-cluster image. The fltk-values.yaml file in charts is expected to have (atleast) the
following contents.
provider:
domain: gcr.io
projectName: <your-project-name>
imageName: fltk:latest
@return: None
@rtype: None
"""
with open("charts/fltk-values.yaml") as f:
loaded = yaml.safe_load(f)
provider = loaded['provider']
domain, p_name, im_name = provider['domain'], provider['projectName'], provider['imageName']
current_image_name = f"{domain}/{p_name}/{im_name}"
self.image = current_image_name

@dataclass_json
@dataclass
Expand Down

0 comments on commit f8b6adf

Please sign in to comment.