Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Wrede committed Jul 10, 2024
1 parent 31ac7f4 commit 828aeea
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 35 deletions.
2 changes: 1 addition & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ services:
- mongo
entrypoint: [ "sh", "-c" ]
command:
- "/venv/bin/pip install --no-cache-dir -e . && /venv/bin/fedn fedn controller start"
- "/venv/bin/pip install --no-cache-dir -e . && /venv/bin/fedn controller start"
ports:
- 8092:8092

Expand Down
10 changes: 7 additions & 3 deletions fedn/cli/controller_cmd.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import click

from .main import main
from fedn.network.api.server import start_server_api


@main.group("controller")
@click.pass_context
def controller_cmd(ctx):
""":param ctx:
"""
""":param ctx:"""
pass


@controller_cmd.command("start")
@click.pass_context
def controller_cmd(ctx):
from fedn.network.api.server import start_server_api

start_server_api()
17 changes: 12 additions & 5 deletions fedn/common/config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import os

import yaml

from fedn.utils.dist import get_absolute_path
from fedn.utils.dist import get_package_path

SECRET_KEY = os.environ.get("FEDN_JWT_SECRET_KEY", False)
FEDN_JWT_CUSTOM_CLAIM_KEY = os.environ.get("FEDN_JWT_CUSTOM_CLAIM_KEY", False)
FEDN_JWT_CUSTOM_CLAIM_VALUE = os.environ.get("FEDN_JWT_CUSTOM_CLAIM_VALUE", False)
Expand All @@ -20,10 +22,15 @@ def get_environment_config():
"""Get the configuration from environment variables."""
global STATESTORE_CONFIG
global MODELSTORAGE_CONFIG
Statestore_absolute_path=get_absolute_path("STATESTORE_CONFIG")
modelstorage_absolute_path=get_absolute_path("MODELSTORAGE_CONFIG")
STATESTORE_CONFIG = os.environ.get("STATESTORE_CONFIG", Statestore_absolute_path)
MODELSTORAGE_CONFIG = os.environ.get("MODELSTORAGE_CONFIG", modelstorage_absolute_path)
if not os.environ.get("STATESTORE_CONFIG", False):
STATESTORE_CONFIG = get_package_path() + "/common/settings-controller.yaml.template"
else:
STATESTORE_CONFIG = os.environ.get("STATESTORE_CONFIG")

if not os.environ.get("MODELSTORAGE_CONFIG", False):
MODELSTORAGE_CONFIG = get_package_path() + "/common/settings-controller.yaml.template"
else:
MODELSTORAGE_CONFIG = os.environ.get("MODELSTORAGE_CONFIG")


def get_statestore_config(file=None):
Expand Down
24 changes: 24 additions & 0 deletions fedn/common/settings-controller.yaml.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
network_id: fedn-network
controller:
host: localhost
port: 8092
debug: True

statestore:
type: MongoDB
mongo_config:
username: fedn_admin
password: password
host: localhost
port: 6534

storage:
storage_type: S3
storage_config:
storage_hostname: localhost
storage_port: 9000
storage_access_key: fedn_admin
storage_secret_key: password
storage_bucket: fedn-models
context_bucket: fedn-context
storage_secure_mode: False
24 changes: 6 additions & 18 deletions fedn/network/api/shared.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,10 @@
from fedn.common.config import get_modelstorage_config, get_network_config, get_statestore_config
from fedn.network.controller.control import Control
from fedn.network.storage.statestore.mongostatestore import MongoStateStore
statestore=None
statestore_config=None
modelstorage_config=None
network_id=None
control=None
def set_statestore_config():
global statestore
global modelstorage_config
global network_id
global control
global statestore_config
statestore_config = get_statestore_config()
modelstorage_config = get_modelstorage_config()
network_id = get_network_config()
statestore = MongoStateStore(network_id, statestore_config["mongo_config"])
statestore.set_storage_backend(modelstorage_config)
control = Control(statestore=statestore)

set_statestore_config()
statestore_config = get_statestore_config()
modelstorage_config = get_modelstorage_config()
network_id = get_network_config()
statestore = MongoStateStore(network_id, statestore_config["mongo_config"])
statestore.set_storage_backend(modelstorage_config)
control = Control(statestore=statestore)
16 changes: 8 additions & 8 deletions fedn/utils/dist.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import importlib.metadata
import os
from pathlib import Path

import fedn


def get_version(pacakge):
# Dynamically get the version of the package
Expand All @@ -9,9 +10,8 @@ def get_version(pacakge):
except importlib.metadata.PackageNotFoundError:
version = "unknown"
return version
def get_absolute_path(env_var):
default_path = ".././fedn/config/settings-reducer.yaml.template"
file_path = os.environ.get(env_var, default_path)
# Resolve the absolute path
absolute_file_path = Path(file_path).resolve()
return absolute_file_path


def get_package_path():
# Get the path of the package
return fedn.__path__[0]

0 comments on commit 828aeea

Please sign in to comment.