Skip to content

Commit

Permalink
bug fix in unit-test
Browse files Browse the repository at this point in the history
  • Loading branch information
cheneydon committed Nov 7, 2022
1 parent af8b4b5 commit 88128f2
Show file tree
Hide file tree
Showing 20 changed files with 65 additions and 67 deletions.
9 changes: 0 additions & 9 deletions scripts/nlp_exp_scripts/fednlp/run.sh

This file was deleted.

9 changes: 0 additions & 9 deletions scripts/nlp_exp_scripts/isolated/run.sh

This file was deleted.

11 changes: 0 additions & 11 deletions scripts/nlp_exp_scripts/pcfednlp/run.sh

This file was deleted.

8 changes: 0 additions & 8 deletions scripts/nlp_exp_scripts/pfednlp/pretrain/run.sh

This file was deleted.

11 changes: 0 additions & 11 deletions scripts/nlp_exp_scripts/pfednlp/train/run.sh

This file was deleted.

10 changes: 10 additions & 0 deletions scripts/nlp_exp_scripts/run_fednlp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
set -e

cd ..

echo "Run fednlp."

python federatedscope/main.py \
--cfg federatedscope/nlp/baseline/config_fednlp.yaml \
--client_cfg federatedscope/nlp/baseline/config_client_fednlp.yaml \
outdir exp/fednlp/train/ \
10 changes: 10 additions & 0 deletions scripts/nlp_exp_scripts/run_isolated.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
set -e

cd ..

echo "Run isolated."

python federatedscope/main.py \
--cfg federatedscope/nlp/baseline/config_isolated.yaml \
--client_cfg federatedscope/nlp/baseline/config_client_isolated.yaml \
outdir exp/isolated/train/ \
11 changes: 11 additions & 0 deletions scripts/nlp_exp_scripts/run_pcfednlp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
set -e

cd ..

echo "Run pcfednlp."

python federatedscope/main.py \
--cfg federatedscope/nlp/baseline/config_pcfednlp.yaml \
--client_cfg federatedscope/nlp/baseline/config_client_pcfednlp.yaml \
federate.hfl_load_from exp/pfednlp/pretrain/ckpt/ \
outdir exp/pcfednlp/train/ \
11 changes: 11 additions & 0 deletions scripts/nlp_exp_scripts/run_pfednlp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
set -e

cd ..

echo "Run pfednlp."

python federatedscope/main.py \
--cfg federatedscope/nlp/baseline/config_pfednlp.yaml \
--client_cfg federatedscope/nlp/baseline/config_client_pfednlp.yaml \
federate.hfl_load_from exp/pfednlp/pretrain/ckpt/ \
outdir exp/pfednlp/train/ \
9 changes: 9 additions & 0 deletions scripts/nlp_exp_scripts/run_pfednlp_pretrain.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
set -e

cd ..

echo "Run pfednlp pretrain."

python federatedscope/main.py \
--cfg federatedscope/nlp/baseline/config_pfednlp_pretrain.yaml \
outdir exp/pfednlp/pretrain/ \
33 changes: 14 additions & 19 deletions tests/test_nlp.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,50 +17,44 @@ def setUp(self):

def test_isolated(self):
cfg_alg = CfgNode.load_cfg(
open('scripts/nlp_exp_scripts/isolated/config_isolated.yaml', 'r'))
open('federatedscope/nlp/baseline/config_isolated.yaml', 'r'))
cfg_client = CfgNode.load_cfg(
open(
'scripts/nlp_exp_scripts/isolated/config_client_isolated.yaml',
'r'))
open('federatedscope/nlp/baseline/config_client_isolated.yaml',
'r'))
cfg_alg.outdir = 'exp/fedavg/'
self.fed_runner(cfg_alg, cfg_client)

def test_fednlp(self):
cfg_alg = CfgNode.load_cfg(
open('scripts/nlp_exp_scripts/fednlp/config_fednlp.yaml', 'r'))
open('federatedscope/nlp/baseline/config_fednlp.yaml', 'r'))
cfg_client = CfgNode.load_cfg(
open('scripts/nlp_exp_scripts/fednlp/config_client_fednlp.yaml',
'r'))
open('federatedscope/nlp/baseline/config_client_fednlp.yaml', 'r'))
cfg_alg.outdir = 'exp/fednlp/'
self.fed_runner(cfg_alg, cfg_client)

def test_pfednlp(self):
# pretrain
cfg_alg = CfgNode.load_cfg(
open(
'scripts/nlp_exp_scripts/pfednlp/pretrain/config_pretrain.yaml',
'r'))
open('federatedscope/nlp/baseline/config_pfednlp_pretrain.yaml',
'r'))
cfg_alg.outdir = 'exp/pfednlp/pretrain/'
self.fed_runner(cfg_alg)

# train
cfg_alg = CfgNode.load_cfg(
open('scripts/nlp_exp_scripts/pfednlp/train/config_pfednlp.yaml',
'r'))
open('federatedscope/nlp/baseline/config_pfednlp.yaml', 'r'))
cfg_client = CfgNode.load_cfg(
open(
'scripts/nlp_exp_scripts/pfednlp/train/config_client_pfednlp'
'.yaml', 'r'))
open('federatedscope/nlp/baseline/config_client_pfednlp.yaml',
'r'))
cfg_alg.outdir = 'exp/pfednlp/train/'
self.fed_runner(cfg_alg, cfg_client)

def test_pcfednlp(self):
cfg_alg = CfgNode.load_cfg(
open('scripts/nlp_exp_scripts/pcfednlp/config_pcfednlp.yaml', 'r'))
open('federatedscope/nlp/baseline/config_pcfednlp.yaml', 'r'))
cfg_client = CfgNode.load_cfg(
open(
'scripts/nlp_exp_scripts/pcfednlp/config_client_pcfednlp.yaml',
'r'))
open('federatedscope/nlp/baseline/config_client_pcfednlp.yaml',
'r'))
cfg_alg.outdir = 'exp/pcfednlp/'
self.fed_runner(cfg_alg, cfg_client)

Expand All @@ -69,6 +63,7 @@ def fed_runner(self, cfg_alg, cfg_client=None):
init_cfg.merge_from_other_cfg(cfg_alg)
init_cfg.data.debug = True
init_cfg.data.batch_size = 1
init_cfg.data.root = 'test_data/'
init_cfg.data.datasets = ['imdb', 'agnews', 'squad', 'newsqa']
init_cfg.data.num_grouped_clients = [1, 3, 3, 2]
init_cfg.federate.client_num = 9
Expand Down

0 comments on commit 88128f2

Please sign in to comment.