Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
LOFAR
Manage
Activity
Members
Labels
Plan
Issues
Wiki
Jira issues
Open Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Insights
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
RadioObservatory
LOFAR
Commits
7175779d
Commit
7175779d
authored
3 years ago
by
Mario Raciti
Browse files
Options
Downloads
Patches
Plain Diff
TMSS-770
: Update get_subs_and_durations_from_project by adding generic durations; minor fixes
parent
a3c11ae6
No related branches found
No related tags found
3 merge requests
!634
WIP: COBALT commissioning delta
,
!522
Resolve TMSS-770
,
!481
Draft: SW-971 SW-973 SW-975: Various fixes to build LOFAR correctly.
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
SAS/TMSS/backend/src/tmss/tmssapp/adapters/reports.py
+17
-12
17 additions, 12 deletions
SAS/TMSS/backend/src/tmss/tmssapp/adapters/reports.py
SAS/TMSS/backend/test/t_adapter.py
+9
-10
9 additions, 10 deletions
SAS/TMSS/backend/test/t_adapter.py
with
26 additions
and
22 deletions
SAS/TMSS/backend/src/tmss/tmssapp/adapters/reports.py
+
17
−
12
View file @
7175779d
...
...
@@ -326,31 +326,36 @@ def _get_subs_and_durations_from_project(project_pk: int) -> ({}, {}):
"""
from
lofar.sas.tmss.tmss.workflowapp.models.schedulingunitflow
import
SchedulingUnitProcess
durations
=
{
'
total
'
:
0
,
'
total_succeeded
'
:
0
,
'
total_not_cancelled
'
:
0
,
'
total_failed
'
:
0
}
durations
=
{
'
total
'
:
0
,
'
total_not_cancelled
'
:
0
,
'
total_observed
'
:
0
,
'
total_observed_succeeded
'
:
0
,
'
total_observed_failed
'
:
0
}
# Get SUBs related to the project
project_subs
=
models
.
SchedulingUnitBlueprint
.
objects
.
filter
(
draft__scheduling_set__project__pk
=
project_pk
)
subs_succeeded
,
subs_failed
=
[],
[]
for
prio
in
models
.
PriorityQueueType
.
Choices
:
durations
[
f
'
total_succeeded_
{
prio
.
name
}
'
]
=
0
durations
[
f
'
total_
observed_
succeeded_
{
prio
.
name
}
'
]
=
0
subs
=
project_subs
.
filter
(
priority_queue
=
prio
.
value
)
for
sub
in
subs
:
# TODO: Maybe also add generic durations.
# TODO: Does it make any sense to consider generic successful and failed?
durations
[
'
total
'
]
+=
sub
.
duration
.
total_seconds
()
if
sub
.
status
!=
'
cancelled
'
:
# Not cancelled SUBs
durations
[
'
total_not_cancelled
'
]
+=
sub
.
duration
.
total_seconds
()
# Observations
if
sub
.
observed_duration
:
durations
[
'
total
'
]
+=
sub
.
observed_duration
.
total_seconds
()
durations
[
'
total
_observed
'
]
+=
sub
.
observed_duration
.
total_seconds
()
sup
=
SchedulingUnitProcess
.
objects
.
filter
(
su
=
sub
).
first
()
if
sup
and
sup
.
results_accepted
:
# Succeeded SUBs
durations
[
f
'
total_succeeded_
{
prio
.
name
}
'
]
+=
sub
.
observed_duration
.
total_seconds
()
subs_succeeded
.
append
({
'
id
'
:
sub
.
pk
,
'
name
'
:
sub
.
name
,
'
observed_duration
'
:
sub
.
duration
.
total_seconds
()})
durations
[
f
'
total_observed_succeeded_
{
prio
.
name
}
'
]
+=
sub
.
observed_duration
.
total_seconds
()
subs_succeeded
.
append
({
'
id
'
:
sub
.
pk
,
'
name
'
:
sub
.
name
,
'
duration
'
:
sub
.
duration
.
total_seconds
(),
'
observed_duration
'
:
sub
.
observed_duration
.
total_seconds
()})
elif
sup
and
sup
.
results_accepted
is
False
:
# Failed SUBs
durations
[
'
total_duration_failed
'
]
+=
sub
.
observed_duration
.
total_seconds
()
subs_failed
.
append
({
'
id
'
:
sub
.
pk
,
'
name
'
:
sub
.
name
,
'
observed_duration
'
:
sub
.
duration
.
total_seconds
()})
if
sub
.
status
!=
'
cancelled
'
:
# Not cancelled SUBs
durations
[
'
total_not_cancelled
'
]
+=
sub
.
observed_duration
.
total_seconds
()
durations
[
'
total_succeeded
'
]
+=
durations
[
f
'
total_succeeded_
{
prio
.
name
}
'
]
durations
[
'
total_observed_failed
'
]
+=
sub
.
observed_duration
.
total_seconds
()
subs_failed
.
append
({
'
id
'
:
sub
.
pk
,
'
name
'
:
sub
.
name
,
'
duration
'
:
sub
.
duration
.
total_seconds
(),
'
observed_duration
'
:
sub
.
observed_duration
.
total_seconds
()})
durations
[
'
total_observed_succeeded
'
]
+=
durations
[
f
'
total_observed_succeeded_
{
prio
.
name
}
'
]
subs
=
{
'
finished
'
:
subs_succeeded
,
'
failed
'
:
subs_failed
}
subs
=
{
'
successful
'
:
subs_succeeded
,
'
failed
'
:
subs_failed
}
return
subs
,
durations
...
...
This diff is collapsed.
Click to expand it.
SAS/TMSS/backend/test/t_adapter.py
+
9
−
10
View file @
7175779d
...
...
@@ -591,10 +591,10 @@ class ProjectReportTest(unittest.TestCase):
"""
Test create project extra action.
"""
# Create four SUBs and respectively set their states to: 'finished' (so we can create dataproducts
and
compare
# their sizes
)
,
blank (it may be whatever
), 'cancelled' and 'defined' (which means not cancelled).
# Create four SUBs and respectively set their states to: 'finished'
x2
(so we can create dataproducts
,
compare
# their sizes,
and have a successful and a failed SUBs
), 'cancelled' and 'defined' (which means not cancelled).
succeeded_sub
,
_
,
succeeded_subtask
=
self
.
_get_SUB_with_subtask_and_set_status
(
'
finished
'
)
failed_sub
,
_
,
failed_subtask
=
self
.
_get_SUB_with_subtask_and_set_status
()
failed_sub
,
_
,
failed_subtask
=
self
.
_get_SUB_with_subtask_and_set_status
(
'
finished
'
)
cancelled_sub
,
_
,
cancelled_subtask
=
self
.
_get_SUB_with_subtask_and_set_status
(
'
cancelled
'
)
not_cancelled_sub
,
_
,
not_cancelled_subtask
=
self
.
_get_SUB_with_subtask_and_set_status
(
'
defined
'
)
# Set workflow flags so we have a successful and a failed SUBs
...
...
@@ -616,16 +616,15 @@ class ProjectReportTest(unittest.TestCase):
self
.
assertEqual
(
result
[
'
quota
'
][
0
][
'
id
'
],
self
.
project_quota
.
pk
)
# Assert durations are well calculated
# NOTE: The four SUBs (successful, failed, cancelled and not cancelled) have a duration of 600s each.
# TODO: Now the APIs consider the observed_duration. Set up these values properly and asserts them.
# The four SUBs (successful, failed, cancelled and not cancelled) have a duration/observed_duration of 600s each
self
.
assertAlmostEqual
(
result
[
'
durations
'
][
'
total
'
],
2400
,
places
=
4
)
self
.
assertAlmostEqual
(
result
[
'
durations
'
][
'
total_succeeded
'
],
600
,
places
=
4
)
self
.
assertAlmostEqual
(
result
[
'
durations
'
][
'
total_
observed_
succeeded
'
],
600
,
places
=
4
)
self
.
assertAlmostEqual
(
result
[
'
durations
'
][
'
total_not_cancelled
'
],
1800
,
places
=
4
)
self
.
assertAlmostEqual
(
result
[
'
durations
'
][
'
total_failed
'
],
600
,
places
=
4
)
self
.
assertAlmostEqual
(
result
[
'
durations
'
][
'
total_
observed_
failed
'
],
600
,
places
=
4
)
# There is only one
finished
SUB
self
.
assertEqual
(
result
[
'
SUBs
'
][
'
finished
'
][
0
][
'
id
'
],
succeeded_sub
.
pk
)
# There is only one
cancel
led SUB
# There is only one
successful
SUB
self
.
assertEqual
(
result
[
'
SUBs
'
][
'
successful
'
][
0
][
'
id
'
],
succeeded_sub
.
pk
)
# There is only one
fai
led SUB
self
.
assertEqual
(
result
[
'
SUBs
'
][
'
failed
'
][
0
][
'
id
'
],
failed_sub
.
pk
)
# There are just two dataproducts
...
...
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