From 0c6ecad27393bad72e91d17a9acd04a9c9c7269e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Madon?= <mael.madon@irit.fr> Date: Fri, 28 Oct 2022 14:06:12 +0200 Subject: [PATCH] dev: change < to <= for the threshold and adapt related tests --- graph_viz.ipynb | 2 +- src/user_session_builder.py | 8 ++++---- test/expected_output/many_following.SABjson | 12 ++++++------ test/expected_output/many_preceding.SABjson | 8 ++++---- test/test_output_sanity.py | 4 ++-- test/workload/many_following.swf | 6 +++--- test/workload/many_preceding.swf | 4 ++-- 7 files changed, 22 insertions(+), 22 deletions(-) diff --git a/graph_viz.ipynb b/graph_viz.ipynb index a2f083c..0d14f11 100644 --- a/graph_viz.ipynb +++ b/graph_viz.ipynb @@ -85,7 +85,7 @@ "source": [ "With another value for the threshold:\n", "\n", - "*Note: a threshold of 0 with the Arrival delimitation method will populate only sessions containing jobs submitted at the same time (so most likely only single-job sessions)*" + "*Note: a threshold of 0 with the Arrival delimitation method will populate only single-job sessions*" ] }, { diff --git a/src/user_session_builder.py b/src/user_session_builder.py index f2a1e6c..d2ec6e1 100644 --- a/src/user_session_builder.py +++ b/src/user_session_builder.py @@ -50,15 +50,15 @@ class User: if self.delim_approach == 'arrival': inter_arrival_time = date_now - self.__last_submit_time - return (inter_arrival_time > self.delim_threshold) + return (inter_arrival_time >= self.delim_threshold) elif self.delim_approach == 'last': think_time = date_now - self.__last_finish_time - return (think_time > self.delim_threshold) + return (think_time >= self.delim_threshold) else: # 'max' delimitation approach think_time = date_now - self.__max_finish_time - return (think_time > self.delim_threshold) + return (think_time >= self.delim_threshold) def __sessions_finished_at_time(self, t): """Return the list of session that were finished at time t""" @@ -92,7 +92,7 @@ class User: for s_id in self.__sessions_in_progress.copy(): sess = self.sessions[s_id] - if date_now > sess.max_finish_time: # ie sess is finished + if date_now >= sess.max_finish_time: # ie sess is finished self.__sessions_in_progress.discard(s_id) self.__current_dep = self.__current_dep - set( sess.preceding_sessions) diff --git a/test/expected_output/many_following.SABjson b/test/expected_output/many_following.SABjson index f493068..e54feec 100644 --- a/test/expected_output/many_following.SABjson +++ b/test/expected_output/many_following.SABjson @@ -36,9 +36,9 @@ }, { "id": 3, - "first_submit_time": 2001.0, + "first_submit_time": 2000.0, "preceding_sessions": [1], - "thinking_time_after_preceding_session": [1001], + "thinking_time_after_preceding_session": [1000], "nb_jobs": 1, "jobs": [ { @@ -52,9 +52,9 @@ }, { "id": 4, - "first_submit_time": 2002.0, + "first_submit_time": 2000.0, "preceding_sessions": [1], - "thinking_time_after_preceding_session": [1002], + "thinking_time_after_preceding_session": [1000], "nb_jobs": 1, "jobs": [ { @@ -68,9 +68,9 @@ }, { "id": 5, - "first_submit_time": 2003.0, + "first_submit_time": 2000.0, "preceding_sessions": [1], - "thinking_time_after_preceding_session": [1003], + "thinking_time_after_preceding_session": [1000], "nb_jobs": 1, "jobs": [ { diff --git a/test/expected_output/many_preceding.SABjson b/test/expected_output/many_preceding.SABjson index bb25f65..37f7c3f 100644 --- a/test/expected_output/many_preceding.SABjson +++ b/test/expected_output/many_preceding.SABjson @@ -1,5 +1,5 @@ { - "description": "A session (session 6) depends on five others, with a think time of 1000s. Slightly different than batmen version.", + "description": "A session (session 6) depends on five others, with a think time of 1000s.", "nb_res": 16, "sessions": [ { @@ -20,14 +20,14 @@ }, { "id": 2, - "first_submit_time": 1001.0, + "first_submit_time": 1000.0, "preceding_sessions": [], "thinking_time_after_preceding_session": [], "nb_jobs": 1, "jobs": [ { "id": 2, - "profile": "1500", + "profile": "2000", "res": 16, "subtime": 0.0, "walltime": 2592000.0 @@ -36,7 +36,7 @@ }, { "id": 3, - "first_submit_time": 1002.0, + "first_submit_time": 1000.0, "preceding_sessions": [], "thinking_time_after_preceding_session": [], "nb_jobs": 1, diff --git a/test/test_output_sanity.py b/test/test_output_sanity.py index 1bcff7e..4f08988 100644 --- a/test/test_output_sanity.py +++ b/test/test_output_sanity.py @@ -41,10 +41,10 @@ def SABjson_sanity_check(SABjson_file, arrival_threshold=None): if arrival_threshold is not None and previous_job_subtime != -1: interrarrival = job_sub_time - previous_job_subtime if job == session["jobs"][0]: - assert interrarrival > arrival_threshold * 60, f"Session {s_id} was started but the interrarrival time was not suffisiant" + assert interrarrival >= arrival_threshold * 60, f"Session {s_id} was started but the interrarrival time was not suffisiant" else: job_id = job["id"] - assert interrarrival <= arrival_threshold * 60, f"Job {job_id} in session {s_id} should be in a new session" + assert interrarrival < arrival_threshold * 60, f"Job {job_id} in session {s_id} should be in a new session" s_id += 1 fd.close() diff --git a/test/workload/many_following.swf b/test/workload/many_following.swf index 01ea036..b79994d 100644 --- a/test/workload/many_following.swf +++ b/test/workload/many_following.swf @@ -3,7 +3,7 @@ 1 0 0 1000 16 -1 -1 16 2592000 -1 1 1 1 -1 -1 -1 -1 -1 2 2000 0 2000 16 -1 -1 16 2592000 -1 1 1 1 -1 -1 -1 -1 -1 - 3 2001 0 1000 16 -1 -1 16 2592000 -1 1 1 1 -1 -1 -1 -1 -1 - 4 2002 0 1000 16 -1 -1 16 2592000 -1 1 1 1 -1 -1 -1 -1 -1 - 5 2003 0 1000 16 -1 -1 16 2592000 -1 1 1 1 -1 -1 -1 -1 -1 + 3 2000 50 1000 16 -1 -1 16 2592000 -1 1 1 1 -1 -1 -1 -1 -1 + 4 2000 50 1000 16 -1 -1 16 2592000 -1 1 1 1 -1 -1 -1 -1 -1 + 5 2000 50 1000 16 -1 -1 16 2592000 -1 1 1 1 -1 -1 -1 -1 -1 6 3000 0 1000 16 -1 -1 16 2592000 -1 1 1 1 -1 -1 -1 -1 -1 diff --git a/test/workload/many_preceding.swf b/test/workload/many_preceding.swf index 107c63f..b6dc433 100644 --- a/test/workload/many_preceding.swf +++ b/test/workload/many_preceding.swf @@ -2,8 +2,8 @@ ; Expected to produce many_preceding.SABjson with arrival_t0 1 1000 1000 1000 16 -1 -1 16 2592000 -1 1 1 1 -1 -1 -1 -1 -1 - 2 1001 499 1500 16 -1 -1 16 2592000 -1 1 1 1 -1 -1 -1 -1 -1 - 3 1002 998 1000 16 -1 -1 16 2592000 -1 1 1 1 -1 -1 -1 -1 -1 + 2 1000 0 2000 16 -1 -1 16 2592000 -1 1 1 1 -1 -1 -1 -1 -1 + 3 1000 1000 1000 16 -1 -1 16 2592000 -1 1 1 1 -1 -1 -1 -1 -1 4 1500 500 1000 16 -1 -1 16 2592000 -1 1 1 1 -1 -1 -1 -1 -1 5 2000 0 1000 16 -1 -1 16 2592000 -1 1 1 1 -1 -1 -1 -1 -1 6 4000 0 1000 16 -1 -1 16 2592000 -1 1 1 1 -1 -1 -1 -1 -1 -- GitLab