diff --git a/doc/source/core.rst b/doc/source/core.rst index 9c7c3fae8..365963623 100644 --- a/doc/source/core.rst +++ b/doc/source/core.rst @@ -50,3 +50,10 @@ federatedscope.core.monitors .. automodule:: federatedscope.core.monitors :members: :private-members: + +federatedscope.core.auxiliaries +----------------------- + +.. automodule:: federatedscope.core.auxiliaries + :members: + :private-members: diff --git a/federatedscope/attack/auxiliary/poisoning_data.py b/federatedscope/attack/auxiliary/poisoning_data.py index acab87cae..17df11402 100644 --- a/federatedscope/attack/auxiliary/poisoning_data.py +++ b/federatedscope/attack/auxiliary/poisoning_data.py @@ -2,7 +2,7 @@ from PIL import Image import numpy as np from torchvision import transforms -from federatedscope.core.auxiliaries.transform_builder import get_transform +from federatedscope.core.auxiliaries import get_transform from federatedscope.attack.auxiliary.backdoor_utils import selectTrigger from torch.utils.data import DataLoader from federatedscope.attack.auxiliary.backdoor_utils import normalize diff --git a/federatedscope/attack/privacy_attacks/passive_PIA.py b/federatedscope/attack/privacy_attacks/passive_PIA.py index 8d7ecef5f..5a0065bd0 100644 --- a/federatedscope/attack/privacy_attacks/passive_PIA.py +++ b/federatedscope/attack/privacy_attacks/passive_PIA.py @@ -3,7 +3,7 @@ import torch import numpy as np import copy -from federatedscope.core.auxiliaries.optimizer_builder import get_optimizer +from federatedscope.core.auxiliaries import get_optimizer import logging diff --git a/federatedscope/attack/worker_as_attacker/server_attacker.py b/federatedscope/attack/worker_as_attacker/server_attacker.py index 226568242..90d806824 100644 --- a/federatedscope/attack/worker_as_attacker/server_attacker.py +++ b/federatedscope/attack/worker_as_attacker/server_attacker.py @@ -1,7 +1,7 @@ from federatedscope.core.workers import Server from federatedscope.core.message import Message -from federatedscope.core.auxiliaries.criterion_builder import get_criterion +from federatedscope.core.auxiliaries import get_criterion import copy from federatedscope.attack.auxiliary.utils import get_data_sav_fn, \ get_reconstructor diff --git a/federatedscope/autotune/algos.py b/federatedscope/autotune/algos.py index 27469d136..16f13f29e 100644 --- a/federatedscope/autotune/algos.py +++ b/federatedscope/autotune/algos.py @@ -10,10 +10,8 @@ import numpy as np from federatedscope.core.auxiliaries.utils import setup_seed -from federatedscope.core.auxiliaries.data_builder import get_data -from federatedscope.core.auxiliaries.worker_builder import get_client_cls, \ - get_server_cls -from federatedscope.core.fed_runner import get_runner +from federatedscope.core.auxiliaries import get_data, get_client_cls, \ + get_server_cls, get_runner from federatedscope.autotune.utils import parse_search_space, \ config2cmdargs, config2str, summarize_hpo_results diff --git a/federatedscope/autotune/utils.py b/federatedscope/autotune/utils.py index 959d9112e..9638f3973 100644 --- a/federatedscope/autotune/utils.py +++ b/federatedscope/autotune/utils.py @@ -37,12 +37,12 @@ def parse_search_space(config_path): def config2cmdargs(config): - ''' + """ Arguments: config (dict): key is cfg node name, value is the specified value. Returns: results (list): cmd args - ''' + """ results = [] for k, v in config.items(): @@ -52,13 +52,13 @@ def config2cmdargs(config): def config2str(config): - ''' + """ Arguments: config (dict): key is cfg node name, value is the choice of hyper-parameter. Returns: name (str): the string representation of this config - ''' + """ vals = [] for k in config: @@ -136,10 +136,9 @@ def process(file): def eval_in_fs(cfg, config, budget): import ConfigSpace as CS from federatedscope.core.auxiliaries.utils import setup_seed - from federatedscope.core.auxiliaries.data_builder import get_data from federatedscope.core.auxiliaries.worker_builder import \ get_client_cls, get_server_cls - from federatedscope.core.fed_runner import get_runner + from federatedscope.core.auxiliaries import get_runner, get_data from federatedscope.autotune.utils import config2cmdargs from os.path import join as osp diff --git a/federatedscope/core/aggregators/fedopt_aggregator.py b/federatedscope/core/aggregators/fedopt_aggregator.py index 47e1725a3..8b734f98e 100644 --- a/federatedscope/core/aggregators/fedopt_aggregator.py +++ b/federatedscope/core/aggregators/fedopt_aggregator.py @@ -1,7 +1,7 @@ import torch from federatedscope.core.aggregators import ClientsAvgAggregator -from federatedscope.core.auxiliaries.optimizer_builder import get_optimizer +from federatedscope.core.auxiliaries import get_optimizer class FedOptAggregator(ClientsAvgAggregator): diff --git a/federatedscope/core/auxiliaries/__init__.py b/federatedscope/core/auxiliaries/__init__.py index e69de29bb..84090ce35 100644 --- a/federatedscope/core/auxiliaries/__init__.py +++ b/federatedscope/core/auxiliaries/__init__.py @@ -0,0 +1,22 @@ +from federatedscope.core.auxiliaries.aggregator_builder import get_aggregator +from federatedscope.core.auxiliaries.criterion_builder import get_criterion +from federatedscope.core.auxiliaries.data_builder import get_data +from federatedscope.core.auxiliaries.dataloader_builder import get_dataloader +from federatedscope.core.auxiliaries.metric_builder import get_metric +from federatedscope.core.auxiliaries.model_builder import get_model +from federatedscope.core.auxiliaries.optimizer_builder import get_optimizer +from federatedscope.core.auxiliaries.sampler_builder import get_sampler +from federatedscope.core.auxiliaries.scheduler_builder import get_scheduler +from federatedscope.core.auxiliaries.splitter_builder import get_splitter +from federatedscope.core.auxiliaries.trainer_builder import get_trainer +from federatedscope.core.auxiliaries.transform_builder import get_transform +from federatedscope.core.auxiliaries.runner_builder import get_runner +from federatedscope.core.auxiliaries.worker_builder import get_client_cls, \ + get_server_cls + +__all__ = [ + 'get_aggregator', 'get_criterion', 'get_data', 'get_dataloader', + 'get_metric', 'get_model', 'get_optimizer', 'get_sampler', 'get_scheduler', + 'get_splitter', 'get_trainer', 'get_transform', 'get_client_cls', + 'get_server_cls', 'get_runner' +] diff --git a/federatedscope/core/auxiliaries/runner_builder.py b/federatedscope/core/auxiliaries/runner_builder.py new file mode 100644 index 000000000..678892e50 --- /dev/null +++ b/federatedscope/core/auxiliaries/runner_builder.py @@ -0,0 +1,15 @@ +from federatedscope.core.fed_runner import StandaloneRunner, DistributedRunner + + +def get_runner(data, server_class, client_class, config, client_configs=None): + # Instantiate a Runner based on a configuration file + mode = config.federate.mode.lower() + runner_dict = { + 'standalone': StandaloneRunner, + 'distributed': DistributedRunner + } + return runner_dict[mode](data=data, + server_class=server_class, + client_class=client_class, + config=config, + client_configs=client_configs) diff --git a/federatedscope/core/auxiliaries/trainer_builder.py b/federatedscope/core/auxiliaries/trainer_builder.py index 6f773fc45..d0b358fdf 100644 --- a/federatedscope/core/auxiliaries/trainer_builder.py +++ b/federatedscope/core/auxiliaries/trainer_builder.py @@ -44,7 +44,7 @@ def get_trainer(model=None, data: data used in FL course device: where to train model (``cpu`` or ``gpu``) config: configurations for FL, see ``federatedscope.core.configs`` - only_for_eval: ``True`` or ``False``, if ``True``, ``train`` \ + only_for_eval: ``True`` or ``False``, if ``True``, train \ routine will be removed in this trainer is_attacker: ``True`` or ``False`` to determine whether this client \ is an attacker diff --git a/federatedscope/core/data/base_data.py b/federatedscope/core/data/base_data.py index ec5d67e87..e8d40dd36 100644 --- a/federatedscope/core/data/base_data.py +++ b/federatedscope/core/data/base_data.py @@ -1,6 +1,6 @@ import logging from federatedscope.core.data.utils import merge_data -from federatedscope.core.auxiliaries.dataloader_builder import get_dataloader +from federatedscope.core.auxiliaries import get_dataloader logger = logging.getLogger(__name__) diff --git a/federatedscope/core/data/base_translator.py b/federatedscope/core/data/base_translator.py index 8dd71f0c9..cb97b3089 100644 --- a/federatedscope/core/data/base_translator.py +++ b/federatedscope/core/data/base_translator.py @@ -1,7 +1,7 @@ import logging import numpy as np -from federatedscope.core.auxiliaries.splitter_builder import get_splitter +from federatedscope.core.auxiliaries import get_splitter from federatedscope.core.data import ClientData, StandaloneDataDict logger = logging.getLogger(__name__) diff --git a/federatedscope/core/data/utils.py b/federatedscope/core/data/utils.py index 763279db4..2466f2bda 100644 --- a/federatedscope/core/data/utils.py +++ b/federatedscope/core/data/utils.py @@ -111,7 +111,7 @@ def load_external_data(config=None): import torch from importlib import import_module from torch.utils.data import DataLoader - from federatedscope.core.auxiliaries.transform_builder import get_transform + from federatedscope.core.auxiliaries import get_transform def load_torchvision_data(name, splits=None, config=None): dataset_func = getattr(import_module('torchvision.datasets'), name) diff --git a/federatedscope/core/fed_runner.py b/federatedscope/core/fed_runner.py index aadf6e7be..bc989fa5e 100644 --- a/federatedscope/core/fed_runner.py +++ b/federatedscope/core/fed_runner.py @@ -8,27 +8,12 @@ from federatedscope.core.workers import Server, Client from federatedscope.core.gpu_manager import GPUManager -from federatedscope.core.auxiliaries.model_builder import get_model +from federatedscope.core.auxiliaries import get_model from federatedscope.core.auxiliaries.utils import get_resource_info -from federatedscope.core.data.utils import merge_data logger = logging.getLogger(__name__) -def get_runner(data, server_class, client_class, config, client_configs=None): - # Instantiate a Runner based on a configuration file - mode = config.federate.mode.lower() - runner_dict = { - 'standalone': StandaloneRunner, - 'distributed': DistributedRunner - } - return runner_dict[mode](data=data, - server_class=server_class, - client_class=client_class, - config=config, - client_configs=client_configs) - - class BaseRunner(object): """ This class is used to construct an FL course, which includes `_set_up` diff --git a/federatedscope/core/monitors/metric_calculator.py b/federatedscope/core/monitors/metric_calculator.py index ed3ec4b3b..76c73a018 100644 --- a/federatedscope/core/monitors/metric_calculator.py +++ b/federatedscope/core/monitors/metric_calculator.py @@ -5,7 +5,7 @@ from scipy.special import softmax from sklearn.metrics import roc_auc_score, average_precision_score, f1_score -from federatedscope.core.auxiliaries.metric_builder import get_metric +from federatedscope.core.auxiliaries import get_metric # Blind torch try: diff --git a/federatedscope/core/trainers/context.py b/federatedscope/core/trainers/context.py index 06dffea82..73ca790f8 100644 --- a/federatedscope/core/trainers/context.py +++ b/federatedscope/core/trainers/context.py @@ -1,7 +1,7 @@ import logging import collections -from federatedscope.core.auxiliaries.criterion_builder import get_criterion +from federatedscope.core.auxiliaries import get_criterion from federatedscope.core.auxiliaries.model_builder import \ get_trainable_para_names from federatedscope.core.auxiliaries.regularizer_builder import get_regularizer diff --git a/federatedscope/core/trainers/torch_trainer.py b/federatedscope/core/trainers/torch_trainer.py index c343cbabf..a1602f09d 100644 --- a/federatedscope/core/trainers/torch_trainer.py +++ b/federatedscope/core/trainers/torch_trainer.py @@ -13,11 +13,10 @@ from federatedscope.core.trainers.enums import MODE, LIFECYCLE from federatedscope.core.trainers.trainer import Trainer from federatedscope.core.trainers.context import CtxVar -from federatedscope.core.auxiliaries.optimizer_builder import get_optimizer -from federatedscope.core.auxiliaries.scheduler_builder import get_scheduler +from federatedscope.core.auxiliaries import get_optimizer, get_dataloader, \ + get_scheduler from federatedscope.core.data import ClientData from federatedscope.core.data.wrap_dataset import WrapDataset -from federatedscope.core.auxiliaries.dataloader_builder import get_dataloader from federatedscope.core.auxiliaries.ReIterator import ReIterator from federatedscope.core.auxiliaries.utils import param2tensor, \ merge_param_dict diff --git a/federatedscope/core/trainers/trainer_Ditto.py b/federatedscope/core/trainers/trainer_Ditto.py index f30b50f46..b27980578 100644 --- a/federatedscope/core/trainers/trainer_Ditto.py +++ b/federatedscope/core/trainers/trainer_Ditto.py @@ -3,7 +3,7 @@ import torch -from federatedscope.core.auxiliaries.optimizer_builder import get_optimizer +from federatedscope.core.auxiliaries import get_optimizer from federatedscope.core.trainers.torch_trainer import GeneralTorchTrainer from federatedscope.core.optimizer import wrap_regularized_optimizer from federatedscope.core.trainers.utils import calculate_batch_epoch_num diff --git a/federatedscope/core/trainers/trainer_multi_model.py b/federatedscope/core/trainers/trainer_multi_model.py index d230070ed..a0c1a3b02 100644 --- a/federatedscope/core/trainers/trainer_multi_model.py +++ b/federatedscope/core/trainers/trainer_multi_model.py @@ -2,7 +2,7 @@ from types import FunctionType from typing import Type -from federatedscope.core.auxiliaries.optimizer_builder import get_optimizer +from federatedscope.core.auxiliaries import get_optimizer from federatedscope.core.trainers.torch_trainer import GeneralTorchTrainer import numpy as np diff --git a/federatedscope/core/workers/client.py b/federatedscope/core/workers/client.py index e08fff908..603557275 100644 --- a/federatedscope/core/workers/client.py +++ b/federatedscope/core/workers/client.py @@ -7,8 +7,7 @@ from federatedscope.core.communication import StandaloneCommManager, \ gRPCCommManager from federatedscope.core.monitors.early_stopper import EarlyStopper -from federatedscope.core.workers import Worker -from federatedscope.core.auxiliaries.trainer_builder import get_trainer +from federatedscope.core.auxiliaries import get_trainer from federatedscope.core.secret_sharing import AdditiveSecretSharing from federatedscope.core.auxiliaries.utils import merge_dict_of_results, \ calculate_time_cost diff --git a/federatedscope/core/workers/server.py b/federatedscope/core/workers/server.py index 33e9c09a6..6bf01d55e 100644 --- a/federatedscope/core/workers/server.py +++ b/federatedscope/core/workers/server.py @@ -10,11 +10,11 @@ from federatedscope.core.message import Message from federatedscope.core.communication import StandaloneCommManager, \ gRPCCommManager -from federatedscope.core.auxiliaries.aggregator_builder import get_aggregator -from federatedscope.core.auxiliaries.sampler_builder import get_sampler +from federatedscope.core.auxiliaries import get_aggregator +from federatedscope.core.auxiliaries import get_sampler from federatedscope.core.auxiliaries.utils import merge_dict_of_results, \ Timeout, merge_param_dict -from federatedscope.core.auxiliaries.trainer_builder import get_trainer +from federatedscope.core.auxiliaries import get_trainer from federatedscope.core.secret_sharing import AdditiveSecretSharing from federatedscope.core.workers.base_server import BaseServer diff --git a/federatedscope/cv/dataloader/dataloader.py b/federatedscope/cv/dataloader/dataloader.py index 9ea27e492..c169f3b76 100644 --- a/federatedscope/cv/dataloader/dataloader.py +++ b/federatedscope/cv/dataloader/dataloader.py @@ -1,5 +1,5 @@ from federatedscope.cv.dataset.leaf_cv import LEAF_CV -from federatedscope.core.auxiliaries.transform_builder import get_transform +from federatedscope.core.auxiliaries import get_transform def load_cv_dataset(config=None): diff --git a/federatedscope/gfl/dataloader/dataloader_graph.py b/federatedscope/gfl/dataloader/dataloader_graph.py index 5be531918..fb7a94352 100644 --- a/federatedscope/gfl/dataloader/dataloader_graph.py +++ b/federatedscope/gfl/dataloader/dataloader_graph.py @@ -1,7 +1,7 @@ from torch_geometric import transforms from torch_geometric.datasets import TUDataset, MoleculeNet -from federatedscope.core.auxiliaries.transform_builder import get_transform +from federatedscope.core.auxiliaries import get_transform from federatedscope.gfl.dataset.cikm_cup import CIKMCUPDataset diff --git a/federatedscope/gfl/dataloader/dataloader_link.py b/federatedscope/gfl/dataloader/dataloader_link.py index 989dbbe35..a8ad3cce8 100644 --- a/federatedscope/gfl/dataloader/dataloader_link.py +++ b/federatedscope/gfl/dataloader/dataloader_link.py @@ -3,8 +3,7 @@ from torch_geometric.utils import add_self_loops, remove_self_loops, \ to_undirected -from federatedscope.core.auxiliaries.splitter_builder import get_splitter -from federatedscope.core.auxiliaries.transform_builder import get_transform +from federatedscope.core.auxiliaries import get_splitter, get_transform def load_linklevel_dataset(config=None): diff --git a/federatedscope/gfl/dataloader/dataloader_node.py b/federatedscope/gfl/dataloader/dataloader_node.py index feef8d5d5..56b656151 100644 --- a/federatedscope/gfl/dataloader/dataloader_node.py +++ b/federatedscope/gfl/dataloader/dataloader_node.py @@ -6,8 +6,7 @@ to_undirected from torch_geometric.data import Data -from federatedscope.core.auxiliaries.splitter_builder import get_splitter -from federatedscope.core.auxiliaries.transform_builder import get_transform +from federatedscope.core.auxiliaries import get_splitter, get_transform INF = np.iinfo(np.int64).max diff --git a/federatedscope/main.py b/federatedscope/main.py index f7dabc993..57492f087 100644 --- a/federatedscope/main.py +++ b/federatedscope/main.py @@ -8,13 +8,11 @@ sys.path.append(file_dir) from federatedscope.core.cmd_args import parse_args -from federatedscope.core.auxiliaries.data_builder import get_data +from federatedscope.core.auxiliaries import get_runner, get_server_cls, \ + get_client_cls, get_data from federatedscope.core.auxiliaries.utils import setup_seed from federatedscope.core.auxiliaries.logging import update_logger -from federatedscope.core.auxiliaries.worker_builder import get_client_cls, \ - get_server_cls from federatedscope.core.configs.config import global_cfg, CfgNode -from federatedscope.core.fed_runner import get_runner if os.environ.get('https_proxy'): del os.environ['https_proxy'] diff --git a/federatedscope/nlp/dataloader/dataloader.py b/federatedscope/nlp/dataloader/dataloader.py index d950a2a63..c731540dd 100644 --- a/federatedscope/nlp/dataloader/dataloader.py +++ b/federatedscope/nlp/dataloader/dataloader.py @@ -1,7 +1,7 @@ from federatedscope.nlp.dataset.leaf_nlp import LEAF_NLP from federatedscope.nlp.dataset.leaf_twitter import LEAF_TWITTER from federatedscope.nlp.dataset.leaf_synthetic import LEAF_SYNTHETIC -from federatedscope.core.auxiliaries.transform_builder import get_transform +from federatedscope.core.auxiliaries import get_transform def load_nlp_dataset(config=None): diff --git a/federatedscope/organizer/utils.py b/federatedscope/organizer/utils.py index 715f26dc8..3a26d52d1 100644 --- a/federatedscope/organizer/utils.py +++ b/federatedscope/organizer/utils.py @@ -7,7 +7,7 @@ from federatedscope.core.cmd_args import parse_args from federatedscope.core.configs.config import global_cfg -from federatedscope.core.auxiliaries.data_builder import get_data +from federatedscope.core.auxiliaries import get_data from federatedscope.organizer.cfg_client import env_name, root_path, fs_version logger = logging.getLogger('federatedscope') diff --git a/tests/test_CRA_gan_attack.py b/tests/test_CRA_gan_attack.py index 5a1bb72dd..27e9e5079 100644 --- a/tests/test_CRA_gan_attack.py +++ b/tests/test_CRA_gan_attack.py @@ -1,12 +1,11 @@ # Copyright (c) Alibaba, Inc. and its affiliates. import unittest -from federatedscope.core.auxiliaries.data_builder import get_data from federatedscope.core.auxiliaries.utils import setup_seed from federatedscope.core.auxiliaries.logging import update_logger from federatedscope.core.configs.config import global_cfg -from federatedscope.core.fed_runner import get_runner -from federatedscope.core.auxiliaries.worker_builder import get_server_cls, get_client_cls +from federatedscope.core.auxiliaries import get_runner, get_server_cls, \ + get_client_cls, get_data class CRATest(unittest.TestCase): diff --git a/tests/test_MIA_gradient_ascent.py b/tests/test_MIA_gradient_ascent.py index b4c3dd750..aad8fab8e 100644 --- a/tests/test_MIA_gradient_ascent.py +++ b/tests/test_MIA_gradient_ascent.py @@ -1,12 +1,11 @@ # Copyright (c) Alibaba, Inc. and its affiliates. import unittest -from federatedscope.core.auxiliaries.data_builder import get_data from federatedscope.core.auxiliaries.utils import setup_seed from federatedscope.core.auxiliaries.logging import update_logger from federatedscope.core.configs.config import global_cfg -from federatedscope.core.fed_runner import get_runner -from federatedscope.core.auxiliaries.worker_builder import get_server_cls, get_client_cls +from federatedscope.core.auxiliaries import get_runner, get_server_cls, \ + get_client_cls class GradAscentTest(unittest.TestCase): diff --git a/tests/test_PIA_toy.py b/tests/test_PIA_toy.py index e25555926..2bd5c5a89 100644 --- a/tests/test_PIA_toy.py +++ b/tests/test_PIA_toy.py @@ -1,12 +1,11 @@ # Copyright (c) Alibaba, Inc. and its affiliates. import unittest -from federatedscope.core.auxiliaries.data_builder import get_data from federatedscope.core.auxiliaries.utils import setup_seed from federatedscope.core.auxiliaries.logging import update_logger from federatedscope.core.configs.config import global_cfg -from federatedscope.core.fed_runner import get_runner -from federatedscope.core.auxiliaries.worker_builder import get_server_cls, get_client_cls +from federatedscope.core.auxiliaries import get_runner, get_server_cls, \ + get_client_cls, get_data class PIA_ToyLRTest(unittest.TestCase): diff --git a/tests/test_asyn_cifar10.py b/tests/test_asyn_cifar10.py index 530b2ad01..f97d2041d 100644 --- a/tests/test_asyn_cifar10.py +++ b/tests/test_asyn_cifar10.py @@ -1,12 +1,11 @@ # Copyright (c) Alibaba, Inc. and its affiliates. import unittest -from federatedscope.core.auxiliaries.data_builder import get_data from federatedscope.core.auxiliaries.utils import setup_seed from federatedscope.core.auxiliaries.logging import update_logger from federatedscope.core.configs.config import global_cfg -from federatedscope.core.fed_runner import get_runner -from federatedscope.core.auxiliaries.worker_builder import get_server_cls, get_client_cls +from federatedscope.core.auxiliaries import get_runner, get_server_cls, \ + get_client_cls, get_data class AsynCIFAR10Test(unittest.TestCase): diff --git a/tests/test_backdoor_attack.py b/tests/test_backdoor_attack.py index f0683c812..3f51dac69 100644 --- a/tests/test_backdoor_attack.py +++ b/tests/test_backdoor_attack.py @@ -1,12 +1,11 @@ # Copyright (c) Alibaba, Inc. and its affiliates. import unittest -from federatedscope.core.auxiliaries.data_builder import get_data from federatedscope.core.auxiliaries.utils import setup_seed from federatedscope.core.auxiliaries.logging import update_logger from federatedscope.core.configs.config import global_cfg -from federatedscope.core.fed_runner import get_runner -from federatedscope.core.auxiliaries.worker_builder import get_server_cls, get_client_cls +from federatedscope.core.auxiliaries import get_runner, get_server_cls, \ + get_client_cls, get_data class Backdoor_Attack(unittest.TestCase): diff --git a/tests/test_ditto.py b/tests/test_ditto.py index 77f23e445..8bb87307a 100644 --- a/tests/test_ditto.py +++ b/tests/test_ditto.py @@ -1,12 +1,11 @@ # Copyright (c) Alibaba, Inc. and its affiliates. import unittest -from federatedscope.core.auxiliaries.data_builder import get_data from federatedscope.core.auxiliaries.utils import setup_seed from federatedscope.core.auxiliaries.logging import update_logger from federatedscope.core.configs.config import global_cfg -from federatedscope.core.fed_runner import get_runner -from federatedscope.core.auxiliaries.worker_builder import get_server_cls, get_client_cls +from federatedscope.core.auxiliaries import get_runner, get_server_cls, \ + get_client_cls, get_data class FEMNISTTest(unittest.TestCase): diff --git a/tests/test_efficient_simulation.py b/tests/test_efficient_simulation.py index aa16cdf9a..6eedce86d 100644 --- a/tests/test_efficient_simulation.py +++ b/tests/test_efficient_simulation.py @@ -1,12 +1,11 @@ # Copyright (c) Alibaba, Inc. and its affiliates. import unittest -from federatedscope.core.auxiliaries.data_builder import get_data from federatedscope.core.auxiliaries.utils import setup_seed from federatedscope.core.auxiliaries.logging import update_logger from federatedscope.core.configs.config import global_cfg -from federatedscope.core.fed_runner import get_runner -from federatedscope.core.auxiliaries.worker_builder import get_server_cls, get_client_cls +from federatedscope.core.auxiliaries import get_runner, get_server_cls, \ + get_client_cls, get_data class EfficientSimulationTest(unittest.TestCase): diff --git a/tests/test_external_dataset.py b/tests/test_external_dataset.py index 806efe603..1a35684e6 100644 --- a/tests/test_external_dataset.py +++ b/tests/test_external_dataset.py @@ -1,12 +1,11 @@ # Copyright (c) Alibaba, Inc. and its affiliates. import unittest -from federatedscope.core.auxiliaries.data_builder import get_data from federatedscope.core.auxiliaries.utils import setup_seed from federatedscope.core.auxiliaries.logging import update_logger from federatedscope.core.configs.config import global_cfg -from federatedscope.core.fed_runner import get_runner -from federatedscope.core.auxiliaries.worker_builder import get_server_cls, get_client_cls +from federatedscope.core.auxiliaries import get_runner, get_server_cls, \ + get_client_cls, get_data class ExternalDatasetTest(unittest.TestCase): diff --git a/tests/test_fedem.py b/tests/test_fedem.py index 28a7dec23..a6414dcd0 100644 --- a/tests/test_fedem.py +++ b/tests/test_fedem.py @@ -1,12 +1,11 @@ # Copyright (c) Alibaba, Inc. and its affiliates. import unittest -from federatedscope.core.auxiliaries.data_builder import get_data from federatedscope.core.auxiliaries.utils import setup_seed from federatedscope.core.auxiliaries.logging import update_logger from federatedscope.core.configs.config import global_cfg -from federatedscope.core.fed_runner import get_runner -from federatedscope.core.auxiliaries.worker_builder import get_server_cls, get_client_cls +from federatedscope.core.auxiliaries import get_runner, get_server_cls, \ + get_client_cls, get_data class FEMNISTTest(unittest.TestCase): diff --git a/tests/test_fedopt.py b/tests/test_fedopt.py index 30d9a53aa..edef23ffa 100644 --- a/tests/test_fedopt.py +++ b/tests/test_fedopt.py @@ -1,12 +1,11 @@ # Copyright (c) Alibaba, Inc. and its affiliates. import unittest -from federatedscope.core.auxiliaries.data_builder import get_data from federatedscope.core.auxiliaries.utils import setup_seed from federatedscope.core.auxiliaries.logging import update_logger from federatedscope.core.configs.config import global_cfg -from federatedscope.core.fed_runner import get_runner -from federatedscope.core.auxiliaries.worker_builder import get_server_cls, get_client_cls +from federatedscope.core.auxiliaries import get_runner, get_server_cls, \ + get_client_cls, get_data class FedOptTest(unittest.TestCase): diff --git a/tests/test_fedprox.py b/tests/test_fedprox.py index 2f7efb049..5f24928f1 100644 --- a/tests/test_fedprox.py +++ b/tests/test_fedprox.py @@ -1,12 +1,11 @@ # Copyright (c) Alibaba, Inc. and its affiliates. import unittest -from federatedscope.core.auxiliaries.data_builder import get_data from federatedscope.core.auxiliaries.utils import setup_seed from federatedscope.core.auxiliaries.logging import update_logger from federatedscope.core.configs.config import global_cfg -from federatedscope.core.fed_runner import get_runner -from federatedscope.core.auxiliaries.worker_builder import get_server_cls, get_client_cls +from federatedscope.core.auxiliaries import get_runner, get_server_cls, \ + get_client_cls, get_data class FedProxTest(unittest.TestCase): diff --git a/tests/test_fedsageplus.py b/tests/test_fedsageplus.py index 85173664f..ea06b263b 100644 --- a/tests/test_fedsageplus.py +++ b/tests/test_fedsageplus.py @@ -1,12 +1,11 @@ # Copyright (c) Alibaba, Inc. and its affiliates. import unittest -from federatedscope.core.auxiliaries.data_builder import get_data from federatedscope.core.auxiliaries.utils import setup_seed from federatedscope.core.auxiliaries.logging import update_logger from federatedscope.core.configs.config import global_cfg -from federatedscope.core.fed_runner import get_runner -from federatedscope.core.auxiliaries.worker_builder import get_server_cls, get_client_cls +from federatedscope.core.auxiliaries import get_runner, get_server_cls, \ + get_client_cls, get_data class FedSagePlusTest(unittest.TestCase): diff --git a/tests/test_femnist.py b/tests/test_femnist.py index 31141b2bc..8c652add9 100644 --- a/tests/test_femnist.py +++ b/tests/test_femnist.py @@ -1,12 +1,11 @@ # Copyright (c) Alibaba, Inc. and its affiliates. import unittest -from federatedscope.core.auxiliaries.data_builder import get_data from federatedscope.core.auxiliaries.utils import setup_seed from federatedscope.core.auxiliaries.logging import update_logger from federatedscope.core.configs.config import global_cfg -from federatedscope.core.fed_runner import get_runner -from federatedscope.core.auxiliaries.worker_builder import get_server_cls, get_client_cls +from federatedscope.core.auxiliaries import get_runner, get_server_cls, \ + get_client_cls, get_data SAMPLE_CLIENT_NUM = 5 diff --git a/tests/test_finetune_lr.py b/tests/test_finetune_lr.py index ef137d59b..0cb7796a5 100644 --- a/tests/test_finetune_lr.py +++ b/tests/test_finetune_lr.py @@ -1,12 +1,11 @@ # Copyright (c) Alibaba, Inc. and its affiliates. import unittest -from federatedscope.core.auxiliaries.data_builder import get_data from federatedscope.core.auxiliaries.utils import setup_seed from federatedscope.core.auxiliaries.logging import update_logger from federatedscope.core.configs.config import global_cfg -from federatedscope.core.fed_runner import get_runner -from federatedscope.core.auxiliaries.worker_builder import get_server_cls, get_client_cls +from federatedscope.core.auxiliaries import get_runner, get_server_cls, \ + get_client_cls, get_data class ToyLRTest(unittest.TestCase): diff --git a/tests/test_global_train_lr.py b/tests/test_global_train_lr.py index f2ed6632a..666978dda 100644 --- a/tests/test_global_train_lr.py +++ b/tests/test_global_train_lr.py @@ -1,12 +1,11 @@ # Copyright (c) Alibaba, Inc. and its affiliates. import unittest -from federatedscope.core.auxiliaries.data_builder import get_data from federatedscope.core.auxiliaries.utils import setup_seed from federatedscope.core.auxiliaries.logging import update_logger from federatedscope.core.configs.config import global_cfg -from federatedscope.core.fed_runner import get_runner -from federatedscope.core.auxiliaries.worker_builder import get_server_cls, get_client_cls +from federatedscope.core.auxiliaries import get_runner, get_server_cls, \ + get_client_cls, get_data class ToyLRTest(unittest.TestCase): diff --git a/tests/test_graph_node_trainer.py b/tests/test_graph_node_trainer.py index 8f74ac660..c6d00a28e 100644 --- a/tests/test_graph_node_trainer.py +++ b/tests/test_graph_node_trainer.py @@ -1,12 +1,11 @@ # Copyright (c) Alibaba, Inc. and its affiliates. import unittest -from federatedscope.core.auxiliaries.data_builder import get_data from federatedscope.core.auxiliaries.utils import setup_seed from federatedscope.core.auxiliaries.logging import update_logger from federatedscope.core.configs.config import global_cfg -from federatedscope.core.fed_runner import get_runner -from federatedscope.core.auxiliaries.worker_builder import get_server_cls, get_client_cls +from federatedscope.core.auxiliaries import get_runner, get_server_cls, \ + get_client_cls, get_data class NodeTrainerTest(unittest.TestCase): diff --git a/tests/test_local_train_lr.py b/tests/test_local_train_lr.py index 9d06c9968..6ccf07f3a 100644 --- a/tests/test_local_train_lr.py +++ b/tests/test_local_train_lr.py @@ -1,13 +1,11 @@ # Copyright (c) Alibaba, Inc. and its affiliates. import unittest -from federatedscope.core.auxiliaries.data_builder import get_data from federatedscope.core.auxiliaries.utils import setup_seed from federatedscope.core.auxiliaries.logging import update_logger from federatedscope.core.configs.config import global_cfg -from federatedscope.core.fed_runner import get_runner -from federatedscope.core.auxiliaries.worker_builder import get_server_cls, \ - get_client_cls +from federatedscope.core.auxiliaries import get_runner, get_server_cls, \ + get_client_cls, get_data class ToyLRTest(unittest.TestCase): diff --git a/tests/test_mf.py b/tests/test_mf.py index 8ff641a65..72d17362d 100644 --- a/tests/test_mf.py +++ b/tests/test_mf.py @@ -1,12 +1,11 @@ # Copyright (c) Alibaba, Inc. and its affiliates. import unittest -from federatedscope.core.auxiliaries.data_builder import get_data from federatedscope.core.auxiliaries.utils import setup_seed from federatedscope.core.auxiliaries.logging import update_logger from federatedscope.core.configs.config import global_cfg -from federatedscope.core.fed_runner import get_runner -from federatedscope.core.auxiliaries.worker_builder import get_server_cls, get_client_cls +from federatedscope.core.auxiliaries import get_runner, get_server_cls, \ + get_client_cls, get_data class MFTest(unittest.TestCase): diff --git a/tests/test_nbafl.py b/tests/test_nbafl.py index c61036bb7..e2163dd2a 100644 --- a/tests/test_nbafl.py +++ b/tests/test_nbafl.py @@ -1,12 +1,11 @@ # Copyright (c) Alibaba, Inc. and its affiliates. import unittest -from federatedscope.core.auxiliaries.data_builder import get_data from federatedscope.core.auxiliaries.utils import setup_seed from federatedscope.core.auxiliaries.logging import update_logger from federatedscope.core.configs.config import global_cfg -from federatedscope.core.fed_runner import get_runner -from federatedscope.core.auxiliaries.worker_builder import get_server_cls, get_client_cls +from federatedscope.core.auxiliaries import get_runner, get_server_cls, \ + get_client_cls, get_data class NbAFLTest(unittest.TestCase): diff --git a/tests/test_optimizer.py b/tests/test_optimizer.py index ba2733053..7c69a4c02 100644 --- a/tests/test_optimizer.py +++ b/tests/test_optimizer.py @@ -1,12 +1,11 @@ # Copyright (c) Alibaba, Inc. and its affiliates. import unittest -from federatedscope.core.auxiliaries.data_builder import get_data from federatedscope.core.auxiliaries.utils import setup_seed from federatedscope.core.auxiliaries.logging import update_logger from federatedscope.core.configs.config import global_cfg -from federatedscope.core.fed_runner import get_runner -from federatedscope.core.auxiliaries.worker_builder import get_server_cls, get_client_cls +from federatedscope.core.auxiliaries import get_runner, get_server_cls, \ + get_client_cls, get_data class FEMNISTTest(unittest.TestCase): diff --git a/tests/test_pfedme.py b/tests/test_pfedme.py index 48e793083..823ce7ef0 100644 --- a/tests/test_pfedme.py +++ b/tests/test_pfedme.py @@ -1,12 +1,11 @@ # Copyright (c) Alibaba, Inc. and its affiliates. import unittest -from federatedscope.core.auxiliaries.data_builder import get_data from federatedscope.core.auxiliaries.utils import setup_seed from federatedscope.core.auxiliaries.logging import update_logger from federatedscope.core.configs.config import global_cfg -from federatedscope.core.fed_runner import get_runner -from federatedscope.core.auxiliaries.worker_builder import get_server_cls, get_client_cls +from federatedscope.core.auxiliaries import get_runner, get_server_cls, \ + get_client_cls, get_data class FEMNISTTest(unittest.TestCase): diff --git a/tests/test_rec_IG_opt_attack.py b/tests/test_rec_IG_opt_attack.py index 25fc840d4..796190ef7 100644 --- a/tests/test_rec_IG_opt_attack.py +++ b/tests/test_rec_IG_opt_attack.py @@ -1,12 +1,11 @@ # Copyright (c) Alibaba, Inc. and its affiliates. import unittest -from federatedscope.core.auxiliaries.data_builder import get_data from federatedscope.core.auxiliaries.utils import setup_seed from federatedscope.core.auxiliaries.logging import update_logger from federatedscope.core.configs.config import global_cfg -from federatedscope.core.fed_runner import get_runner -from federatedscope.core.auxiliaries.worker_builder import get_server_cls, get_client_cls +from federatedscope.core.auxiliaries import get_runner, get_server_cls, \ + get_client_cls, get_data class RECTest(unittest.TestCase): diff --git a/tests/test_rec_opt_attack.py b/tests/test_rec_opt_attack.py index be5ecfef2..9dbd305c0 100644 --- a/tests/test_rec_opt_attack.py +++ b/tests/test_rec_opt_attack.py @@ -1,12 +1,11 @@ # Copyright (c) Alibaba, Inc. and its affiliates. import unittest -from federatedscope.core.auxiliaries.data_builder import get_data from federatedscope.core.auxiliaries.utils import setup_seed from federatedscope.core.auxiliaries.logging import update_logger from federatedscope.core.configs.config import global_cfg -from federatedscope.core.fed_runner import get_runner -from federatedscope.core.auxiliaries.worker_builder import get_server_cls, get_client_cls +from federatedscope.core.auxiliaries import get_runner, get_server_cls, \ + get_client_cls, get_data class RECTest(unittest.TestCase): diff --git a/tests/test_toy_lr.py b/tests/test_toy_lr.py index 523a4bec4..b71527681 100644 --- a/tests/test_toy_lr.py +++ b/tests/test_toy_lr.py @@ -1,12 +1,11 @@ # Copyright (c) Alibaba, Inc. and its affiliates. import unittest -from federatedscope.core.auxiliaries.data_builder import get_data from federatedscope.core.auxiliaries.utils import setup_seed from federatedscope.core.auxiliaries.logging import update_logger from federatedscope.core.configs.config import global_cfg -from federatedscope.core.fed_runner import get_runner -from federatedscope.core.auxiliaries.worker_builder import get_server_cls, get_client_cls +from federatedscope.core.auxiliaries import get_runner, get_server_cls, \ + get_client_cls, get_data class ToyLRTest(unittest.TestCase): diff --git a/tests/test_unseen_clients_lr.py b/tests/test_unseen_clients_lr.py index 53e9d6ec0..8a51d2075 100644 --- a/tests/test_unseen_clients_lr.py +++ b/tests/test_unseen_clients_lr.py @@ -1,12 +1,11 @@ # Copyright (c) Alibaba, Inc. and its affiliates. import unittest -from federatedscope.core.auxiliaries.data_builder import get_data from federatedscope.core.auxiliaries.utils import setup_seed from federatedscope.core.auxiliaries.logging import update_logger from federatedscope.core.configs.config import global_cfg -from federatedscope.core.fed_runner import get_runner -from federatedscope.core.auxiliaries.worker_builder import get_server_cls, get_client_cls +from federatedscope.core.auxiliaries import get_runner, get_server_cls, \ + get_client_cls, get_data class ToyLRTest(unittest.TestCase): diff --git a/tests/test_vertical_fl.py b/tests/test_vertical_fl.py index b5394c0f9..9c27d88a7 100644 --- a/tests/test_vertical_fl.py +++ b/tests/test_vertical_fl.py @@ -1,12 +1,12 @@ # Copyright (c) Alibaba, Inc. and its affiliates. import unittest -from federatedscope.core.auxiliaries.data_builder import get_data -from federatedscope.core.auxiliaries.worker_builder import get_client_cls, get_server_cls +from federatedscope.core.auxiliaries import get_data, get_client_cls, \ + get_server_cls from federatedscope.core.auxiliaries.utils import setup_seed from federatedscope.core.auxiliaries.logging import update_logger from federatedscope.core.configs.config import global_cfg -from federatedscope.core.fed_runner import get_runner +from federatedscope.core.auxiliaries.runner_builder import get_runner class vFLTest(unittest.TestCase):