Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Demand Response User
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
Open Science
Demand Response User
Commits
6f9e5e37
Commit
6f9e5e37
authored
3 years ago
by
Maël Madon
Browse files
Options
Downloads
Patches
Plain Diff
finish 1_one_instance expe script
parent
e81e2ae7
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
1_one_instance.py
+87
-55
87 additions, 55 deletions
1_one_instance.py
with
87 additions
and
55 deletions
1_one_instance.py
+
87
−
55
View file @
6f9e5e37
from
run_batsim_exp
import
*
import
swf_to_batsim_split_by_user
as
split_user
#!/usr/bin/env python3
import
time
import
sys
import
os
import
subprocess
import
argparse
sys
.
path
.
insert
(
0
,
'
/scripts
'
)
import
swf_to_batsim_split_by_user
as
split_user
from
run_batsim_exp
import
*
#import swf_moulinette
###### Prepare input data ######
# Cut the original trace to extract 72h starting from this start date
def
prepare_input_data
(
expe_num
,
start_date
):
"""
Cut the original trace to extract 72h starting from this start date
"""
end_date
=
start_date
+
72
*
3600
to_keep
=
f
"
submit_time >=
{
start_date
}
and submit_time <=
{
end_date
}
"
if
not
os
.
path
.
exists
(
f
'
workload/expe
{
expe_num
}
.swf
'
):
os
.
makedirs
(
f
'
workload/expe
{
expe_num
}
.swf
'
)
if
not
os
.
path
.
exists
(
f
'
workload/expe
{
expe_num
}
'
):
os
.
makedirs
(
f
'
workload/expe
{
expe_num
}
'
)
split_user
.
generate_workload
(
input_swf
=
'
workload/MC_selection_article.swf
'
,
output_folder
=
f
'
workload/expe
{
expe_num
}
'
,
...
...
@@ -25,52 +27,82 @@ def prepare_input_data(expe_num, start_date):
job_walltime_factor
=
8
)
###### Run the expe ######
# Run batmen with Rigid behavior
EXPE_FILE
=
f
"
out/expe
{
expe_num
}
"
wl_folder
=
f
'
workload/expe
{
expe_num
}
'
pf
=
"
platform/average_metacentrum.xml
"
wl
=
"
workload/empty_workload.json
"
uf
=
"
sched_input/user_description_file.json
"
def
user_description
(
user
):
return
{
"
name
"
:
user
,
"
category
"
:
"
dm_user_degrad
"
,
"
param
"
:
{
"
input_json
"
:
f
"
{
wl_folder
}
/
{
user
}
.json
"
}
}
user_names
=
[
user_file
.
split
(
'
.
'
)[
0
]
for
user_file
in
os
.
listdir
(
wl_folder
)]
data
=
{}
data
[
"
dm_window
"
]
=
dm_window
data
[
"
log_user_stats
"
]
=
True
data
[
"
log_folder
"
]
=
EXPE_FILE
data
[
"
users
"
]
=
[
user_description
(
user
)
for
user
in
user_names
]
uf
=
"
sched_input/user_description_file.json
"
with
open
(
uf
,
'
w
'
)
as
user_description_file
:
json
.
dump
(
data
,
user_description_file
)
batcmd
=
gen_batsim_cmd
(
pf
,
wl
,
EXPE_FILE
,
"
--energy --enable-compute-sharing --enable-dynamic-jobs --acknowledge-dynamic-jobs --enable-profile-reuse
"
)
schedcmd
=
f
"
batsched -v bin_packing_energy --queue_order=desc_size --variant_options_filepath=
{
uf
}
"
instance
=
RobinInstance
(
output_dir
=
EXPE_FILE
,
batcmd
=
batcmd
,
schedcmd
=
schedcmd
,
simulation_timeout
=
30
,
ready_timeout
=
5
,
success_timeout
=
10
,
failure_timeout
=
0
)
instance
.
to_file
(
robin_filename
)
ret
=
run_robin
(
robin_filename
)
# For each user behavior in {Renonce, Delay, Degrad, Reconfig}
# For each dm_window duration in {.5, 1, 2, 4}
# Run batmen
###### Output data treatment ######
# Produce the utilisation viz
def
run_expe
(
expe_num
,
user_category
,
window_size
):
"""
Run batmen with given behavior and demand response window
"""
# Useful vars and output folder
if
window_size
==
0.5
:
w_size
=
'
05
'
else
:
w_size
=
f
"
{
window_size
}
"
EXPE_FILE
=
f
"
out/expe
{
expe_num
}
/
{
user_category
}
_window
{
w_size
}
"
wl_folder
=
f
'
workload/expe
{
expe_num
}
'
pf
=
"
platform/average_metacentrum.xml
"
wl
=
"
workload/empty_workload.json
"
uf
=
"
sched_input/user_description_file.json
"
# Demand response window, from 12 to (12 + window_size) on day2
dm_window
=
[(
24
+
12
)
*
3600
,
(
24
+
12
+
window_size
)
*
3600
]
# User description file
def
user_description
(
user
):
return
{
"
name
"
:
user
,
"
category
"
:
user_category
,
"
param
"
:
{
"
input_json
"
:
f
"
{
wl_folder
}
/
{
user
}
.json
"
}
}
user_names
=
[
user_file
.
split
(
'
.
'
)[
0
]
for
user_file
in
os
.
listdir
(
wl_folder
)]
data
=
{}
data
[
"
dm_window
"
]
=
dm_window
data
[
"
log_user_stats
"
]
=
True
data
[
"
log_folder
"
]
=
EXPE_FILE
data
[
"
users
"
]
=
[
user_description
(
user
)
for
user
in
user_names
]
with
open
(
uf
,
'
w
'
)
as
user_description_file
:
json
.
dump
(
data
,
user_description_file
)
# Generate and run robin instance
batcmd
=
gen_batsim_cmd
(
pf
,
wl
,
EXPE_FILE
,
"
--energy --enable-compute-sharing --enable-dynamic-jobs --acknowledge-dynamic-jobs --enable-profile-reuse
"
)
schedcmd
=
f
"
batsched -v bin_packing_energy --queue_order=desc_size --variant_options_filepath=
{
uf
}
"
instance
=
RobinInstance
(
output_dir
=
EXPE_FILE
,
batcmd
=
batcmd
,
schedcmd
=
schedcmd
,
simulation_timeout
=
30
,
ready_timeout
=
5
,
success_timeout
=
10
,
failure_timeout
=
0
)
instance
.
to_file
(
robin_filename
)
ret
=
run_robin
(
robin_filename
)
def
main
():
parser
=
argparse
.
ArgumentParser
(
description
=
'
One expe instance. To launch for example with `oarsub -l walltime=2
"
./1_one_instance arg1 arg2 arg3
"
`
'
)
parser
.
add_argument
(
'
expe_num
'
,
type
=
int
,
help
=
'
The expe ID
'
)
parser
.
add_argument
(
'
start_date
'
,
type
=
int
,
help
=
'
Start of the 3-day window (in seconds since the start of the original trace
'
)
args
=
parser
.
parse_args
()
# Prepare workload
prepare_input_data
(
args
.
expe_num
,
args
.
start_date
)
# Create expe folder
if
not
os
.
path
.
exists
(
f
"
out/expe
{
expe_num
}
"
):
os
.
makedirs
(
f
"
out/expe
{
expe_num
}
"
)
# Run with Rigid behavior (the demand response window has no influence here)
run_expe
(
expe_num
=
args
.
expe_num
,
user_category
=
"
replay_user_rigid
"
,
window_size
=
1
)
# 4*4 = 16 expe
for
behavior
in
[
"
dm_user_reconfig
"
,
"
dm_user_degrad
"
,
"
dm_user_renonce
"
,
"
dm_user_delay
"
]:
for
window_size
in
[
0.5
,
1
,
2
,
4
]:
run_expe
(
expe_num
,
behavior
,
window_size
)
###### Output data treatment ######
# Produce the utilisation viz?
if
__name__
==
"
__main__
"
:
main
()
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