Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FedEator
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sepia-pub
DELIGHT
FedEator
Commits
1528a598
Commit
1528a598
authored
3 months ago
by
huongdm1896
Browse files
Options
Downloads
Patches
Plain Diff
fix bug log dir
parent
057b13d7
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
README.md
+4
-2
4 additions, 2 deletions
README.md
Run/config_instances.json
+12
-10
12 additions, 10 deletions
Run/config_instances.json
Run/measure_instance.py
+5
-3
5 additions, 3 deletions
Run/measure_instance.py
Run/run_flwr.py
+6
-8
6 additions, 8 deletions
Run/run_flwr.py
with
27 additions
and
23 deletions
README.md
+
4
−
2
View file @
1528a598
...
...
@@ -39,7 +39,7 @@ This framework requires:
```
bash
pip
install
-r
requirements.txt
```
*Note:*
You also need to install
`tensorflow`
,
`tensorflow-datasets`
`scikit-learn`
and
`numpy`
if you want to run
the provided Flower example.
*Note:*
`requirements.txt`
includes
`tensorflow`
,
`tensorflow-datasets`
`scikit-learn`
and
`numpy`
using for
the provided Flower example.
Navigate to
`Run`
directory:
...
...
@@ -91,6 +91,7 @@ Configure instances of experiment in a json format, structure is shown below.
"args"
:
[
],
"ip"
:
""
,
"modules"
:
[
"logger"
],
"port"
:
8080
},
"clients"
:
[
...
...
@@ -205,7 +206,7 @@ python3 measure_instance.py -c config_instances.json -i 1 -x SingleTest -r 2
Run a campaign with all instances (
`1`
and
`2`
), and 2 repetitions:
```
bash
python3 measure_
instance
.py
-x
CampaignTest
-r
2
python3 measure_
campaign
.py
-x
CampaignTest
-c
config_instances.json
-r
2
```
### Step 5. Output
...
...
@@ -225,6 +226,7 @@ Output dir structure:
│ ├── Flwr_<timestamp>: Flower log
│ │ ├── Client_<ip>
│ │ ├── Server_<ip>
│ │ ├── training_results_<instance_name>_<time>.csv
│ ├── Flwr_<timestamp>
│ │ ├── Client_<ip>
│ │ ├── Server_<ip>
...
...
This diff is collapsed.
Click to expand it.
Run/config_instances.json
+
12
−
10
View file @
1528a598
...
...
@@ -2,7 +2,7 @@
"instances"
:
{
"1"
:
{
"instance"
:
"fedAvg_cifar10"
,
"output_dir"
:
"./
eflwr/
Log"
,
"output_dir"
:
"./Log"
,
"dvfs_cpu"
:
{
"dummy"
:
true
,
"baseline"
:
false
,
...
...
@@ -11,11 +11,12 @@
"server"
:
{
"command"
:
"python3"
,
"args"
:
[
"./
eflwr/
Flower_v1/server_1.py"
,
"./Flower_v1/server_1.py"
,
"-r 1"
,
"-s fedAvg"
],
"ip"
:
"172.16.66.76"
,
"modules"
:
[
"logger"
],
"port"
:
8080
},
"clients"
:
[
...
...
@@ -23,7 +24,7 @@
"name"
:
"client1"
,
"command"
:
"python3"
,
"args"
:
[
"./
eflwr/
Flower_v1/client_1.py"
,
"./Flower_v1/client_1.py"
,
"cifar10"
,
"1"
,
"3"
...
...
@@ -34,7 +35,7 @@
"name"
:
"client2"
,
"command"
:
"python3"
,
"args"
:
[
"./
eflwr/
Flower_v1/client_1.py"
,
"./Flower_v1/client_1.py"
,
"cifar10"
,
"2"
,
"3"
...
...
@@ -45,7 +46,7 @@
"name"
:
"client3"
,
"command"
:
"python3"
,
"args"
:
[
"./
eflwr/
Flower_v1/client_1.py"
,
"./Flower_v1/client_1.py"
,
"cifar10"
,
"3"
,
"3"
...
...
@@ -56,7 +57,7 @@
},
"2"
:
{
"instance"
:
"fedAvg2Clients_cifar10"
,
"output_dir"
:
"./
eflwr/
Log"
,
"output_dir"
:
"./Log"
,
"dvfs_cpu"
:
{
"dummy"
:
true
,
"baseline"
:
false
,
...
...
@@ -65,11 +66,12 @@
"server"
:
{
"command"
:
"python3"
,
"args"
:
[
"./
eflwr/
Flower_v1/server_1.py"
,
"./Flower_v1/server_1.py"
,
"-r 1"
,
"-s fedAvg2Clients"
],
"ip"
:
"172.16.66.76"
,
"modules"
:
[
"logger"
],
"port"
:
8080
},
"clients"
:
[
...
...
@@ -77,7 +79,7 @@
"name"
:
"client1"
,
"command"
:
"python3"
,
"args"
:
[
"./
eflwr/
Flower_v1/client_1.py"
,
"./Flower_v1/client_1.py"
,
"cifar10"
,
"1"
,
"3"
...
...
@@ -88,7 +90,7 @@
"name"
:
"client2"
,
"command"
:
"python3"
,
"args"
:
[
"./
eflwr/
Flower_v1/client_1.py"
,
"./Flower_v1/client_1.py"
,
"cifar10"
,
"2"
,
"3"
...
...
@@ -99,7 +101,7 @@
"name"
:
"client3"
,
"command"
:
"python3"
,
"args"
:
[
"./
eflwr/
Flower_v1/client_1.py"
,
"./Flower_v1/client_1.py"
,
"cifar10"
,
"3"
,
"3"
...
...
This diff is collapsed.
Click to expand it.
Run/measure_instance.py
+
5
−
3
View file @
1528a598
...
...
@@ -20,8 +20,8 @@ parser.add_argument("-r", "--repeat", type=int, default=1, required=True, help="
args
=
parser
.
parse_args
()
config_path
=
os
.
path
.
abspath
(
args
.
config
)
config
_dir
=
os
.
path
.
dirname
(
config_path
)
root
_dir
=
os
.
path
.
abspath
(
os
.
path
.
join
(
os
.
path
.
dirname
(
config_path
),
"
..
"
))
# Get root eflwr directory
print
(
root_dir
)
try
:
with
open
(
args
.
config
,
"
r
"
)
as
file
:
config_data
=
json
.
load
(
file
)
...
...
@@ -64,11 +64,13 @@ else:
# Log directory
# log_dir = config["output_dir"]
log_dir
=
os
.
path
.
abspath
(
config
[
"
output_dir
"
]
)
log_dir
=
os
.
path
.
abspath
(
os
.
path
.
join
(
root_dir
,
config
[
"
output_dir
"
]))
if
config
[
"
output_dir
"
].
startswith
(
"
./
"
)
else
config
[
"
output_dir
"
]
instance_name
=
config
.
get
(
"
instance
"
,
"
default_instance
"
)
flower_log_dir
=
os
.
path
.
join
(
log_dir
,
f
"
Flower_
{
args
.
suffix
}
"
,
f
"
Flower_instance_
{
instance_name
}
"
,
"
Expetator
"
)
os
.
makedirs
(
flower_log_dir
,
exist_ok
=
True
)
print
(
flower_log_dir
)
# Add the configure file to log directory
config_instance_path
=
os
.
path
.
join
(
flower_log_dir
,
f
"
config_instance_
{
instance_key
}
.json
"
)
with
open
(
config_instance_path
,
"
w
"
,
encoding
=
"
utf-8
"
)
as
file
:
...
...
This diff is collapsed.
Click to expand it.
Run/run_flwr.py
+
6
−
8
View file @
1528a598
# python3 run_flwr
_1
.py -c config_instances.json -i 1 -x 1
# python3 run_flwr.py -c config_instances.json -i 1 -x 1
import
os
import
sys
...
...
@@ -13,7 +13,7 @@ def main(config_path, instance, suffix):
print
(
f
"
Running Flower instance with instance:
{
instance
}
and suffix:
{
suffix
}
"
)
config_path
=
os
.
path
.
abspath
(
config_path
)
config
_dir
=
os
.
path
.
dirname
(
config_path
)
root
_dir
=
os
.
path
.
abspath
(
os
.
path
.
join
(
os
.
path
.
dirname
(
config_path
),
"
..
"
))
# Get root eflwr directory
# read json
try
:
...
...
@@ -33,14 +33,14 @@ def main(config_path, instance, suffix):
sys
.
exit
(
1
)
# get server/client info
output_dir
=
os
.
path
.
abspath
(
os
.
path
.
join
(
config
_dir
,
instance_config
[
"
output_dir
"
]))
if
instance_config
[
"
output_dir
"
].
startswith
(
"
./
"
)
else
instance_config
[
"
output_dir
"
]
output_dir
=
os
.
path
.
abspath
(
os
.
path
.
join
(
root
_dir
,
instance_config
[
"
output_dir
"
]))
if
instance_config
[
"
output_dir
"
].
startswith
(
"
./
"
)
else
instance_config
[
"
output_dir
"
]
instance_name
=
instance_config
.
get
(
"
instance
"
,
f
"
default_instance_
{
instance
}
"
)
server_ip
=
instance_config
[
"
server
"
][
"
ip
"
]
server_port
=
instance_config
[
"
server
"
][
"
port
"
]
# Convert server args to absolute paths if needed
server_args
=
[
os
.
path
.
abspath
(
os
.
path
.
join
(
config
_dir
,
arg
))
if
arg
.
startswith
(
"
./
"
)
else
arg
os
.
path
.
abspath
(
os
.
path
.
join
(
root
_dir
,
arg
))
if
arg
.
startswith
(
"
./
"
)
else
arg
for
arg
in
instance_config
[
"
server
"
][
"
args
"
]
]
server_command
=
[
instance_config
[
"
server
"
][
"
command
"
],
*
server_args
]
...
...
@@ -51,15 +51,13 @@ def main(config_path, instance, suffix):
for
client
in
clients
:
client_ip
=
client
[
"
ip
"
]
client_args
=
[
os
.
path
.
abspath
(
os
.
path
.
join
(
config
_dir
,
arg
))
if
arg
.
startswith
(
"
./
"
)
else
arg
os
.
path
.
abspath
(
os
.
path
.
join
(
root
_dir
,
arg
))
if
arg
.
startswith
(
"
./
"
)
else
arg
for
arg
in
client
[
"
args
"
]
]
client_command
=
[
client
[
"
command
"
],
*
client_args
,
f
'"
{
server_ip
}
:
{
server_port
}
"'
]
client_commands
.
append
({
"
ip
"
:
client_ip
,
"
command
"
:
client_command
})
# print(server_command, client_commands)
# print(output_dir)
# return
# Create log for experiment Flower
current_time
=
datetime
.
now
().
strftime
(
"
%Y%m%d_%H%M%S
"
)
flower_dir
=
os
.
path
.
join
(
output_dir
,
f
"
Flower_
{
suffix
}
"
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment