Skip to content
Snippets Groups Projects
Commit bdf3d75c authored by Maël Madon's avatar Maël Madon
Browse files

dev: change in CLI

parent bbcb53f8
No related branches found
No related tags found
No related merge requests found
# swf2sessions # swf2sessions
Python script to read a workload trace in the [Standard Workload Format](https://www.cs.huji.ac.il/labs/parallel/workload/swf.html) (SWF), decompose it into user sessions and store the results in the Session Annotated Batsim JSON format (SABjson). Python script to read a workload trace in the [Standard Workload Format](https://www.cs.huji.ac.il/labs/parallel/workload/swf.html) (SWF), decompose it into user sessions, analyse the dependencies between sessions and store the results in the Session Annotated Batsim JSON format (SABjson).
## What is a session? ## What is a session?
Analysing the workload trace of a parallel infrastructure to identify user sessions was started by Zackay and Feitelson ([Zackay and Feitelson 2013](https://www.cs.huji.ac.il/w~feit/parsched/jsspp12/p12-zakay.pdf)). Analysing the workload trace of a parallel infrastructure to identify user sessions and their dependencies was started by Zackay and Feitelson ([Zackay and Feitelson 2013](https://www.cs.huji.ac.il/w~feit/parsched/jsspp12/p12-zakay.pdf)).
The idea behind it is to keep the *logic* of user submissions rather than the exact submission times. For example, in the image below, the workload has been split into 4 sessions following the "Arrival" delimitation approach: The idea behind it is to keep the *logic* of user submissions rather than the exact submission times. For example, in the image below, the workload has been split into 4 sessions following the "Arrival" delimitation approach:
![diagram](example_4_sessions.png) ![diagram](example_4_sessions.png)
...@@ -23,7 +23,7 @@ Requirements: ...@@ -23,7 +23,7 @@ Requirements:
To run the session decomposition on the workload `workloads/example.swf` illustrated above, with "Arrival" delimitation approach and a threshold of 60 minutes: To run the session decomposition on the workload `workloads/example.swf` illustrated above, with "Arrival" delimitation approach and a threshold of 60 minutes:
```terminal ```terminal
python3 swf2sessions.py -at 60 workloads/example.swf out/ python3 swf2sessions.py -a 60 workloads/example.swf out/
``` ```
For more documentation, see: `python3 swf2sessions.py -h` For more documentation, see: `python3 swf2sessions.py -h`
......
...@@ -74,35 +74,18 @@ if __name__== "__main__": ...@@ -74,35 +74,18 @@ if __name__== "__main__":
help='The folder that will store the output files') help='The folder that will store the output files')
group = parser.add_mutually_exclusive_group(required=True) group = parser.add_mutually_exclusive_group(required=True)
group.add_argument('-a', group.add_argument('-a', '--arrival', metavar="THRESHOLD", type=float,
'--arrival', help="'Arrival' delimitation approach. A job starts a new session if the inter-arrival time with the last job is above the threshold (in minutes)")
help='Arrival delimitation approach', group.add_argument("-l", "--last", metavar="THRESHOLD", type=float,
action="store_true") help="'Last' delimitation approach: a job starts a new session if the think time after the last job is above the threshold (in minutes)")
group.add_argument('-l', group.add_argument("-m", "--max", metavar="THRESHOLD", type=float,
'--last', help="'Max' delimitation approach: a job starts a new session if the think time after the previous job with the highest finish time is above the threshold (in minutes)")
help='Last delimitation approach',
action="store_true") parser.add_argument('--no_dynamic_reduction', action="store_true",
group.add_argument('-m',
'--max',
help='Max delimitation approach',
action="store_true")
parser.add_argument(
'-t',
'--threshold',
type=int,
help=
'Unit: minutes. The threshold (on think-time or inter-arrival time, depending on the delimiation approach) above which a job will be considered to be in a new session.'
)
parser.add_argument(
'--no_dynamic_reduction',
action="store_true",
help= help=
'Unless this option is specified, during the construction of the graph the algorithm dynamically avoids to add an edge between two nodes if a path already exists.' 'Unless this option is specified, during the construction of the graph the algorithm dynamically avoids to add an edge between two nodes if a path already exists.'
) )
parser.add_argument( parser.add_argument('--graph', action="store_true",
'--graph',
action="store_true",
help= help=
"Build a graphical representation of each session graph and save them in a subfolder as gml files" "Build a graphical representation of each session graph and save them in a subfolder as gml files"
) )
...@@ -111,17 +94,25 @@ if __name__== "__main__": ...@@ -111,17 +94,25 @@ if __name__== "__main__":
args = parser.parse_args() args = parser.parse_args()
if args.last: if args.last is not None:
delim = 'last' delim = 'last'
elif args.max: threshold = args.last
elif args.max is not None:
delim = 'max' delim = 'max'
else: threshold = args.max
elif args.arrival is not None:
delim = 'arrival' delim = 'arrival'
threshold = args.arrival
else: # should never happen
raise argparse.ArgumentError("You should specify a delimitation approach")
if threshold < 0:
raise argparse.ArgumentTypeError("The threshold must be a positive value.")
swf2sessions(input_swf=args.input_swf, swf2sessions(input_swf=args.input_swf,
output_dir=args.output_dir, output_dir=args.output_dir,
delim_approach=delim, delim_approach=delim,
delim_threshold=args.threshold, delim_threshold=threshold,
dynamic_reduction=not (args.no_dynamic_reduction), dynamic_reduction=not (args.no_dynamic_reduction),
build_graph_rep=args.graph, build_graph_rep=args.graph,
quiet=args.quiet) quiet=args.quiet)
\ No newline at end of file
...@@ -29,11 +29,11 @@ def run_script(delim, ...@@ -29,11 +29,11 @@ def run_script(delim,
if not graph: if not graph:
cp = subprocess.run(['python3', 'swf2userSessions.py', cp = subprocess.run(['python3', 'swf2userSessions.py',
'-at', str(threshold), '-q', input_swf, out_dir], '-a', str(threshold), '-q', input_swf, out_dir],
check=True) check=True)
else: else:
cp = subprocess.run(['python3', 'swf2userSessions.py', cp = subprocess.run(['python3', 'swf2userSessions.py',
'-at', str(threshold), '--graph', '-q', input_swf, out_dir], '-a', str(threshold), '--graph', '-q', input_swf, out_dir],
check=True) check=True)
return out_dir, cp return out_dir, cp
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment