Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
batmen
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
mael
batmen
Commits
8cda9263
Commit
8cda9263
authored
2 years ago
by
Maël Madon
Browse files
Options
Downloads
Patches
Plain Diff
dev: improved errors for SABjson parsing
parent
56b5b261
No related branches found
No related tags found
1 merge request
!2
Feature "replay with feedback" ready and tested
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/json_workload.cpp
+49
-25
49 additions, 25 deletions
src/json_workload.cpp
with
49 additions
and
25 deletions
src/json_workload.cpp
+
49
−
25
View file @
8cda9263
...
...
@@ -453,51 +453,67 @@ static void check_format_errors_session_json(const Value &object)
"Invalid SABjson file: a session has no 'id' member"
);
PPK_ASSERT_ERROR
(
object
[
"id"
].
IsInt
(),
"Invalid SABjson file: session 'id' member should be an int"
);
unsigned
int
id
=
object
[
"id"
].
GetInt
();
PPK_ASSERT_ERROR
(
object
.
HasMember
(
"first_submit_time"
),
"Invalid SABjson file: a session has no 'first_submit_time' member"
);
"Invalid SABjson file: session %d has no 'first_submit_time' member"
,
id
);
PPK_ASSERT_ERROR
(
object
[
"first_submit_time"
].
IsNumber
(),
"Invalid SABjson file: session 'first_submit_time' member should be a "
"number"
);
"Invalid SABjson file: session %d 'first_submit_time' member should be "
"a number"
,
id
);
/* arrays preceding_sessions and thinking_time_after_preceding_session */
PPK_ASSERT_ERROR
(
object
.
HasMember
(
"preceding_sessions"
),
"Invalid SABjson file: a session has no 'preceding_sessions' member"
);
"Invalid SABjson file: session %d has no 'preceding_sessions' member"
,
id
);
PPK_ASSERT_ERROR
(
object
.
HasMember
(
"thinking_time_after_preceding_session"
),
"Invalid SABjson file: a session has no "
"'thinking_time_after_preceding_session' member"
);
"Invalid SABjson file: session %d has no "
"'thinking_time_after_preceding_session' member"
,
id
);
const
Value
&
prec_sess
=
object
[
"preceding_sessions"
];
const
Value
&
tt_after
=
object
[
"thinking_time_after_preceding_session"
];
PPK_ASSERT_ERROR
(
prec_sess
.
IsArray
(),
"Invalid SABjson file: session 'preceding_sessions' member should be "
"an array"
);
"Invalid SABjson file: session %d 'preceding_sessions' member should "
"be an array"
,
id
);
PPK_ASSERT_ERROR
(
tt_after
.
IsArray
(),
"Invalid SABjson file: session 'thinking_time_after_preceding_session' "
"member should be an array"
);
"Invalid SABjson file: session %d "
"'thinking_time_after_preceding_session' member should be an array"
,
id
);
PPK_ASSERT_ERROR
(
prec_sess
.
Size
()
==
tt_after
.
Size
(),
"Invalid SABjson file: session arrays 'preceding_sessions' and "
"'thinking_time_after_preceding_session' should have the same size"
);
"Invalid SABjson file: session %d arrays 'preceding_sessions' and "
"'thinking_time_after_preceding_session' should have the same size"
,
id
);
for
(
SizeType
i
=
0
;
i
<
prec_sess
.
Size
();
i
++
)
{
PPK_ASSERT_ERROR
(
prec_sess
[
i
].
IsInt
(),
"Invalid SABjson file: preceding sessions should be int"
);
"Invalid SABjson file: preceding sessions in session %d should be "
"integers"
,
id
);
PPK_ASSERT_ERROR
(
tt_after
[
i
].
IsNumber
(),
"Invalid SABjson file: thinking_time_after_preceding_session "
"should be numbers"
);
"Invalid SABjson file: thinking_time_after_preceding_session in "
"session %d should be numbers"
,
id
);
}
/* jobs */
PPK_ASSERT_ERROR
(
object
.
HasMember
(
"nb_jobs"
),
"Invalid SABjson file:
a
session has no 'nb_jobs' member"
);
"Invalid SABjson file: session
%d
has no 'nb_jobs' member"
,
id
);
PPK_ASSERT_ERROR
(
object
[
"nb_jobs"
].
IsInt
(),
"Invalid SABjson file: session 'nb_jobs' member should be an int"
);
"Invalid SABjson file: session %d 'nb_jobs' member should be an int"
,
id
);
PPK_ASSERT_ERROR
(
object
.
HasMember
(
"jobs"
),
"Invalid SABjson file:
a
session has no 'jobs' member"
);
"Invalid SABjson file: session
%d
has no 'jobs' member"
,
id
);
const
Value
&
jobs
=
object
[
"jobs"
];
PPK_ASSERT_ERROR
(
jobs
.
IsArray
(),
"Invalid SABjson file: session 'jobs' member should be an array"
);
"Invalid SABjson file: session %d 'jobs' member should be an array"
,
id
);
PPK_ASSERT_ERROR
(
object
[
"nb_jobs"
].
GetInt
()
>
0
,
"Invalid SABjson file: session %d should have at least one job"
,
id
);
PPK_ASSERT_ERROR
((
int
)
jobs
.
Size
()
==
object
[
"nb_jobs"
].
GetInt
(),
"Invalid SABjson file: session field 'nb_jobs' should match the size "
"of the jobs array"
);
"Invalid SABjson file: session %d field 'nb_jobs' should match the "
"size of the jobs array"
,
id
);
}
Session
*
Parser
::
session_from_json_object
(
string
user_name
,
const
Value
&
object
,
...
...
@@ -520,14 +536,22 @@ Session *Parser::session_from_json_object(string user_name, const Value &object,
tt_after_prec_sessions
->
push_back
(
tt_after
[
i
].
GetDouble
());
}
double
sub_time
=
0
;
Job
*
j
=
Parser
::
job_from_json_object
(
user_name
,
jobs
[
0
]);
double
sub_time
=
j
->
submission_time
;
PPK_ASSERT_ERROR
(
sub_time
==
0
,
"Invalid SABjson file in session %d: the first job should have a "
"submission time of 0"
,
s
->
id
);
for
(
SizeType
i
=
0
;
i
<
jobs
.
Size
();
i
++
)
{
const
Value
&
job_json_description
=
jobs
[
i
];
Job
*
j
=
Parser
::
job_from_json_object
(
user_name
,
job_json_description
);
j
=
Parser
::
job_from_json_object
(
user_name
,
jobs
[
i
]);
PPK_ASSERT_ERROR
(
j
->
submission_time
>=
sub_time
,
"Invalid SABjson file: 'jobs' should be ordered inside a session"
);
"Invalid SABjson file in session %d: 'jobs' should be ordered "
"inside a session"
,
s
->
id
);
sub_time
=
j
->
submission_time
;
/* Add the session id as a suffix of the job id, for log readability */
j
->
id
=
j
->
id
+
":s"
+
to_string
(
s
->
id
);
j
->
session
=
s
;
s
->
jobs
.
push_back
(
j
);
...
...
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