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
a3c35eb5
Commit
a3c35eb5
authored
3 years ago
by
Mario Raciti
Browse files
Options
Downloads
Patches
Plain Diff
TMSS-610
: Add comments waiting for the workflow status design
parent
d4e63aeb
No related branches found
Branches containing commit
No related tags found
Tags containing commit
3 merge requests
!634
WIP: COBALT commissioning delta
,
!492
Resolve TMSS-610
,
!481
Draft: SW-971 SW-973 SW-975: Various fixes to build LOFAR correctly.
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
SAS/TMSS/backend/src/tmss/tmssapp/adapters/reports.py
+29
-18
29 additions, 18 deletions
SAS/TMSS/backend/src/tmss/tmssapp/adapters/reports.py
with
29 additions
and
18 deletions
SAS/TMSS/backend/src/tmss/tmssapp/adapters/reports.py
+
29
−
18
View file @
a3c35eb5
...
...
@@ -39,13 +39,15 @@ def _get_telescope_time_distribution(cycle: models.Cycle):
projects
=
models
.
Project
.
objects
.
filter
(
cycles
=
cycle
,
project_category
=
c
.
value
)
if
(
c
!=
'
UNASSIGNED
'
and
c
!=
'
FILLER
'
)
\
else
models
.
Project
.
objects
.
filter
(
cycles
=
cycle
,
filler
=
True
)
if
c
==
'
FILLER
'
\
else
models
.
Project
.
objects
.
filter
(
cycles
=
cycle
,
project_category__isnull
=
True
)
for
p
in
projects
:
# Get durations for single project and aggregate to get the totals
# TODO: Filter observations only.
_
,
durations
=
_get_subs_and_durations_from_project
(
p
)
total
+=
durations
[
'
total
'
]
succeeded
+=
durations
[
'
total_succeeded
'
]
failed
+=
durations
[
'
total_failed
'
]
# TODO: Use QA workflow flag to get successful or failed SUBs, instead of SUBs' states.
# At the moment just return some 0 placeholder values.
# for p in projects:
# # Get durations for single project and aggregate to get the totals
# # Note: We can filter observations by considering observed_end_time in the SUB, for now. See TMSS-610.
# _, durations = _get_subs_and_durations_from_project(p)
# total += durations['total']
# succeeded += durations['total_succeeded']
# failed += durations['total_failed']
idle
=
total
-
succeeded
-
failed
result
[
c
if
c
==
'
UNASSIGNED
'
or
c
==
'
FILLER
'
else
c
.
name
]
=
{
'
durations
'
:
{
'
total
'
:
total
,
'
succeeded
'
:
succeeded
,
'
failed
'
:
failed
,
'
idle
'
:
idle
}}
...
...
@@ -84,7 +86,9 @@ def _get_average_efficiency(cycle: models.Cycle):
total_succeeded_per_day
=
0
for
s
in
subtasks
:
# TODO: Handle the multiple days situations.
total_per_day
+=
s
.
duration
.
total_seconds
()
if
s
.
start_time
.
date
()
in
days
and
s
.
stop_time
.
date
()
in
days
else
0
total_succeeded_per_day
+=
s
.
duration
.
total_seconds
()
if
s
.
start_time
.
date
()
in
days
and
s
.
stop_time
.
date
()
in
days
and
s
.
state
==
'
finished
'
else
0
# TODO: Use QA workflow flag to get successful or failed SUBs, instead of SUBs' states.
# At the moment just return some 0 placeholder values.
# total_succeeded_per_day += s.duration.total_seconds() if s.start_time.date() in days and s.stop_time.date() in days and s.state == 'finished' else 0
result
[
'
days
'
].
append
({
str
(
d
):
{
'
total
'
:
total_per_day
,
'
succeeded
'
:
total_succeeded_per_day
}})
return
result
...
...
@@ -108,7 +112,9 @@ def _get_completion_level(cycle: models.Cycle):
total_succeeded
=
0
for
s
in
subtasks
:
total
+=
s
.
duration
.
total_seconds
()
total_succeeded
+=
s
.
duration
.
total_seconds
()
if
s
.
state
==
'
finished
'
else
0
# TODO: Use QA workflow flag to get successful SUBs, instead of SUBs' states.
# At the moment just return some 0 placeholder values.
# total_succeeded += s.duration.total_seconds() if s.state == 'finished' else 0
result
[
'
total
'
],
result
[
'
succeeded
'
]
=
total
,
total_succeeded
return
result
...
...
@@ -126,10 +132,12 @@ def _get_observation_hours_per_category(cycle: models.Cycle):
subs
=
models
.
SchedulingUnitBlueprint
.
objects
.
filter
(
draft__scheduling_set__project__cycles
=
cycle
.
pk
).
filter
(
priority_queue
=
prio
.
value
)
for
sub
in
subs
:
result
[
'
total_duration_idle
'
]
+=
sub
.
duration
.
total_seconds
()
if
sub
.
status
==
'
finished
'
:
# TODO: Use QA workflow flag instead of the finished status
result
[
f
'
total_duration_
{
prio
.
name
}
'
]
+=
sub
.
duration
.
total_seconds
()
if
sub
.
status
==
'
cancelled
'
:
result
[
'
total_duration_failed
'
]
+=
sub
.
duration
.
total_seconds
()
# TODO: Use QA workflow flag to get successful or failed SUBs, instead of SUBs' states.
# At the moment just return some 0 placeholder values.
# if sub.status == 'finished':
# result[f'total_duration_{prio.name}'] += sub.duration.total_seconds()
# if sub.status == 'error':
# result['total_duration_failed'] += sub.duration.total_seconds()
# Subtract prio states from total to get partial idle
result
[
'
total_duration_idle
'
]
-=
result
[
f
'
total_duration_
{
prio
.
name
}
'
]
# Subtract total failed to get total idle eventually
...
...
@@ -199,20 +207,23 @@ def _get_subs_and_durations_from_project(project_pk: int) -> ({}, {}):
"""
# Get SUBs related to the project
scheduling_unit_blueprints
=
models
.
SchedulingUnitBlueprint
.
objects
.
filter
(
draft__scheduling_set__project__pk
=
project_pk
)
# TODO: Split into total, prio A, prio B
?
See TMSS-592.
# TODO: Split into total, prio A, prio B
.
See TMSS-592.
total_duration
,
total_succeeded_duration
,
total_failed_duration
=
timedelta
(),
timedelta
(),
timedelta
()
subs_succeeded
,
subs_failed
=
[],
[]
# NOTE: This might be optimised later with the use of Django's ORM as done for LTA dataproducts.
for
sub
in
scheduling_unit_blueprints
:
# Distinguish between succeeded and failed observations
# TODO: Use QA workflow flag instead of the finished status? See TMSS-592.
if
sub
.
status
==
'
finished
'
:
# Succeeded observations
# TODO: Use QA workflow flag to get successful or failed SUBs, instead of SUBs' states.
# Cancelled SUBs are not failed SUBs. We need to adjust this once the QA workflow flag will be defined.
# Also clarify if this info should be related only to obs or all SUBs in general. The latter are considered for now.
# We can filter observations by considering observed_end_time in the SUB, for now. See TMSS-610 comments.
if
sub
.
status
==
'
finished
'
:
# Succeeded SUBs
total_succeeded_duration
+=
sub
.
duration
subs_succeeded
.
append
({
'
id
'
:
sub
.
pk
,
'
name
'
:
sub
.
name
,
'
duration
'
:
sub
.
duration
.
total_seconds
()})
elif
sub
.
status
==
'
cancelled
'
:
# Failed
observation
s
elif
sub
.
status
==
'
cancelled
'
:
# Failed
SUB
s
total_failed_duration
+=
sub
.
duration
subs_failed
.
append
({
'
id
'
:
sub
.
pk
,
'
name
'
:
sub
.
name
,
'
duration
'
:
sub
.
duration
.
total_seconds
()})
total_duration
+=
sub
.
duration
# Total duration without considering the status of the
ob
s.
total_duration
+=
sub
.
duration
# Total duration without considering the status of the
SUB
s.
total_not_cancelled
=
total_duration
-
total_failed_duration
# Calculate not_cancelled duration
durations
=
{
'
total
'
:
total_duration
.
total_seconds
(),
'
total_succeeded
'
:
total_succeeded_duration
.
total_seconds
(),
...
...
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