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
cc762991
Commit
cc762991
authored
3 years ago
by
Mario Raciti
Browse files
Options
Downloads
Patches
Plain Diff
TMSS-770
: Update minor changes and cleanup
parent
408597ec
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
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
SAS/TMSS/backend/src/tmss/tmssapp/adapters/reports.py
+19
-19
19 additions, 19 deletions
SAS/TMSS/backend/src/tmss/tmssapp/adapters/reports.py
with
19 additions
and
19 deletions
SAS/TMSS/backend/src/tmss/tmssapp/adapters/reports.py
+
19
−
19
View file @
cc762991
...
...
@@ -47,11 +47,12 @@ def _get_telescope_time_distribution(cycle: models.Cycle) -> {}:
# Get durations for single project
subs
=
models
.
SchedulingUnitBlueprint
.
objects
.
filter
(
draft__scheduling_set__project
=
p
.
pk
)
for
sub
in
subs
:
sup
=
SchedulingUnitProcess
.
objects
.
filter
(
su
=
sub
).
first
()
# Aggregate total, successful and failed durations
total
+=
sub
.
observed_duration
.
total_seconds
()
succeeded
+=
sub
.
observed_duration
.
total_seconds
()
if
sup
and
sup
.
results_accepted
else
0
failed
+=
sub
.
observed_duration
.
total_seconds
()
if
sup
and
sup
.
results_accepted
is
False
else
0
if
sub
.
observed_duration
:
sup
=
SchedulingUnitProcess
.
objects
.
filter
(
su
=
sub
).
first
()
# Aggregate total, successful and failed durations
total
+=
sub
.
observed_duration
.
total_seconds
()
succeeded
+=
sub
.
observed_duration
.
total_seconds
()
if
sup
and
sup
.
results_accepted
else
0
failed
+=
sub
.
observed_duration
.
total_seconds
()
if
sup
and
sup
.
results_accepted
is
False
else
0
idle
=
total
-
succeeded
-
failed
result
[
c
if
c
==
'
UNASSIGNED
'
or
c
==
'
FILLER
'
else
c
.
name
]
=
{
'
durations
'
:
{
'
total
'
:
total
,
'
succeeded
'
:
succeeded
,
'
failed
'
:
failed
,
'
idle
'
:
idle
}}
...
...
@@ -132,16 +133,16 @@ def _get_observation_hours_per_category(cycle: models.Cycle) -> {}:
# TODO: Filter also according to "DDT Com Rep", and "System Unavailability".
# Filter durations for each prio basing on SUBs states
for
prio
in
models
.
PriorityQueueType
.
Choices
:
result
[
f
'
total_duration_
{
prio
.
name
}
'
]
=
0
result
[
f
'
total_duration_
successful_
{
prio
.
name
}
'
]
=
0
subs
=
cycle_subs
.
filter
(
priority_queue
=
prio
.
value
)
for
sub
in
subs
:
result
[
'
total_duration_idle
'
]
+=
sub
.
observed_duration
.
total_seconds
()
if
sub
.
observed_duration
else
0
if
sub
.
observed_duration
:
result
[
'
total_duration_idle
'
]
+=
sub
.
observed_duration
.
total_seconds
()
sup
=
SchedulingUnitProcess
.
objects
.
filter
(
su
=
sub
).
first
()
result
[
f
'
total_duration_
{
prio
.
name
}
'
]
+=
sub
.
observed_duration
.
total_seconds
()
if
sup
and
sup
.
results_accepted
else
0
result
[
f
'
total_duration_
successful_
{
prio
.
name
}
'
]
+=
sub
.
observed_duration
.
total_seconds
()
if
sup
and
sup
.
results_accepted
else
0
result
[
'
total_duration_failed
'
]
+=
sub
.
observed_duration
.
total_seconds
()
if
sup
and
sup
.
results_accepted
is
False
else
0
# Subtract prio states from total to get partial idle
result
[
'
total_duration_idle
'
]
-=
result
[
f
'
total_duration_
{
prio
.
name
}
'
]
result
[
'
total_duration_idle
'
]
-=
result
[
f
'
total_duration_
successful_
{
prio
.
name
}
'
]
# Subtract total failed to get total idle eventually
result
[
'
total_duration_idle
'
]
-=
result
[
'
total_duration_failed
'
]
...
...
@@ -337,27 +338,26 @@ def _get_subs_and_durations_from_project(project_pk: int) -> ({}, {}):
durations
[
f
'
total_succeeded_
{
prio
.
name
}
'
],
durations
[
f
'
total_observed_succeeded_
{
prio
.
name
}
'
]
=
0
,
0
subs
=
project_subs
.
filter
(
priority_queue
=
prio
.
value
)
for
sub
in
subs
:
# Main SUB information to be returned
sub_duration
=
sub
.
duration
.
total_seconds
()
sub_observed_duration
=
sub
.
observed_duration
.
total_seconds
()
if
sub
.
observed_duration
else
0
sub_info
=
{
'
id
'
:
sub
.
pk
,
'
name
'
:
sub
.
name
,
'
status
'
:
sub
.
status
,
'
start
'
:
sub
.
start_time
.
isoformat
(),
'
stop
'
:
sub
.
stop_time
.
isoformat
(),
'
duration
'
:
sub_duration
,
'
observed_duration
'
:
sub_observed_duration
}
# Gather durations
durations
[
'
total
'
]
+=
sub_duration
# Total
if
sub
.
status
!=
'
cancelled
'
:
# Not cancelled SUBs
durations
[
'
total_not_cancelled
'
]
+=
sub_duration
durations
[
'
total_observed
'
]
+=
sub_observed_duration
# Total observed
# Distinguish successful and failed SUBs
sup
=
SchedulingUnitProcess
.
objects
.
filter
(
su
=
sub
).
first
()
# Succeeded SUBs
if
sup
and
sup
.
results_accepted
:
if
sup
and
sup
.
results_accepted
:
# Succeeded SUBs
durations
[
f
'
total_succeeded_
{
prio
.
name
}
'
]
+=
sub_duration
durations
[
f
'
total_observed_succeeded_
{
prio
.
name
}
'
]
+=
sub_observed_duration
subs_succeeded
.
append
({
'
id
'
:
sub
.
pk
,
'
name
'
:
sub
.
name
,
'
duration
'
:
sub_duration
,
'
observed_duration
'
:
sub_observed_duration
})
# Failed SUBs
elif
sup
and
sup
.
results_accepted
is
False
:
subs_succeeded
.
append
(
sub_info
)
elif
sup
and
sup
.
results_accepted
is
False
:
# Failed SUBs
durations
[
'
total_failed
'
]
+=
sub_duration
durations
[
'
total_observed_failed
'
]
+=
sub_observed_duration
subs_failed
.
append
({
'
id
'
:
sub
.
pk
,
'
name
'
:
sub
.
name
,
'
duration
'
:
sub_duration
,
'
observed_duration
'
:
sub_observed_duration
})
subs_failed
.
append
(
sub_info
)
# Gather prios durations as well
durations
[
'
total_succeeded
'
]
+=
durations
[
f
'
total_succeeded_
{
prio
.
name
}
'
]
durations
[
'
total_observed_succeeded
'
]
+=
durations
[
f
'
total_observed_succeeded_
{
prio
.
name
}
'
]
...
...
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