Skip to content

Commit

Permalink
Update core to differentiate between federated and distributed tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
JMGaljaard committed Sep 4, 2022
1 parent 2f33590 commit 4b3128b
Show file tree
Hide file tree
Showing 9 changed files with 176 additions and 91 deletions.
3 changes: 3 additions & 0 deletions fltk/core/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .client import Client
from .federator import Federator
from .node import Node
7 changes: 6 additions & 1 deletion fltk/core/client.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
from typing import Tuple, Any

import numpy as np
Expand All @@ -8,7 +9,11 @@
from fltk.core.node import Node
from fltk.schedulers import MinCapableStepLR
from fltk.strategy import get_optimizer
from fltk.util.config import FedLearningConfig


from typing import TYPE_CHECKING
if TYPE_CHECKING:
from fltk.util.config import FedLearningConfig


class Client(Node):
Expand Down
7 changes: 4 additions & 3 deletions fltk/core/distributed/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from .client import DistClient
from .dist_node import DistNode
from .orchestrator import Orchestrator
from fltk.core.distributed.client import DistClient
from fltk.core.distributed.dist_node import DistNode
from fltk.core.distributed.extractor import download_datasets
from fltk.core.distributed.orchestrator import Orchestrator, BatchOrchestrator, SimulatedOrchestrator
8 changes: 5 additions & 3 deletions fltk/core/distributed/client.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
from __future__ import annotations
import datetime
import logging
from pathlib import Path
from typing import List, Tuple, Type
from typing import List, Tuple, Type, TYPE_CHECKING

import numpy as np
import torch
from sklearn.metrics import confusion_matrix
from torch.utils.tensorboard import SummaryWriter

from fltk.core.distributed.dist_node import DistNode
from fltk.datasets.loader_util import get_dist_dataset
from fltk.datasets import get_dist_dataset
from fltk.nets import get_net
from fltk.nets.util import calculate_class_precision, calculate_class_recall, save_model, load_model_from_file
from fltk.schedulers import MinCapableStepLR, LearningScheduler
from fltk.strategy import get_optimizer
from fltk.util.config import DistributedConfig, DistLearningConfig
from fltk.util.results import EpochData

if TYPE_CHECKING:
from fltk.util.config import DistributedConfig, DistLearningConfig

class DistClient(DistNode):

Expand Down
2 changes: 1 addition & 1 deletion fltk/core/distributed/dist_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

class DistNode(abc.ABC):
"""
Distributed Learning Node abstract base classe.
Distributed Learning Node abstract base class.
"""
pass
6 changes: 5 additions & 1 deletion fltk/core/distributed/extractor.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
from __future__ import annotations
import os
from argparse import Namespace

from torchvision.datasets import FashionMNIST, CIFAR10, CIFAR100, MNIST

from fltk.util.config import DistributedConfig
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from fltk.util.config import DistributedConfig


def download_datasets(args: Namespace, config: DistributedConfig):
Expand Down
Loading

0 comments on commit 4b3128b

Please sign in to comment.