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
becaba8b
Commit
becaba8b
authored
3 years ago
by
Mario Raciti
Browse files
Options
Downloads
Patches
Plain Diff
TMSS-770
: Add fraction percentages in remaining functions
parent
679adc5b
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
+23
-2
23 additions, 2 deletions
SAS/TMSS/backend/src/tmss/tmssapp/adapters/reports.py
with
23 additions
and
2 deletions
SAS/TMSS/backend/src/tmss/tmssapp/adapters/reports.py
+
23
−
2
View file @
becaba8b
...
@@ -134,7 +134,7 @@ def _get_observation_hours_per_category(cycle: models.Cycle, start: datetime, st
...
@@ -134,7 +134,7 @@ def _get_observation_hours_per_category(cycle: models.Cycle, start: datetime, st
"""
"""
from
lofar.sas.tmss.tmss.workflowapp.models.schedulingunitflow
import
SchedulingUnitProcess
from
lofar.sas.tmss.tmss.workflowapp.models.schedulingunitflow
import
SchedulingUnitProcess
result
=
{
'
total_duration_failed
'
:
0
,
'
total_duration_idle
'
:
0
,
'
DDT Com Rep
'
:
0
}
result
=
{
'
total_duration
'
:
0
,
'
total_duration_successful
'
:
0
,
'
total_duration_failed
'
:
0
,
'
total_duration_idle
'
:
0
,
'
DDT Com Rep
'
:
0
}
# Filter System Unavailability
# Filter System Unavailability
# TODO: Maybe add some other case scenarios where the system is not up and running?
# TODO: Maybe add some other case scenarios where the system is not up and running?
...
@@ -153,16 +153,29 @@ def _get_observation_hours_per_category(cycle: models.Cycle, start: datetime, st
...
@@ -153,16 +153,29 @@ def _get_observation_hours_per_category(cycle: models.Cycle, start: datetime, st
project_categoy
=
sub
.
project
.
project_category
project_categoy
=
sub
.
project
.
project_category
if
project_categoy
==
'
ddt
'
or
project_categoy
==
'
commissioning
'
:
# TODO: Rep as repetition.
if
project_categoy
==
'
ddt
'
or
project_categoy
==
'
commissioning
'
:
# TODO: Rep as repetition.
result
[
'
DDT Com Rep
'
]
+=
sub
.
observed_duration
.
total_seconds
()
result
[
'
DDT Com Rep
'
]
+=
sub
.
observed_duration
.
total_seconds
()
# Distinguish successful and failed
# Aggregate total and idle
result
[
'
total_duration
'
]
+=
sub
.
observed_duration
.
total_seconds
()
result
[
'
total_duration_idle
'
]
+=
sub
.
observed_duration
.
total_seconds
()
result
[
'
total_duration_idle
'
]
+=
sub
.
observed_duration
.
total_seconds
()
# Distinguish successful and failed
sup
=
SchedulingUnitProcess
.
objects
.
filter
(
su
=
sub
).
first
()
sup
=
SchedulingUnitProcess
.
objects
.
filter
(
su
=
sub
).
first
()
result
[
f
'
total_duration_successful_
{
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
result
[
'
total_duration_failed
'
]
+=
sub
.
observed_duration
.
total_seconds
()
if
sup
and
sup
.
results_accepted
is
False
else
0
# Calculate prio percentages
result
[
f
'
successful_
{
prio
.
name
}
_perc
'
]
=
result
[
f
'
total_duration_successful_
{
prio
.
name
}
'
]
*
100.0
/
result
[
'
total_duration
'
]
if
result
[
'
total_duration
'
]
>
0
else
None
# Aggregate prio durations to general successful
result
[
'
total_duration_successful
'
]
+=
result
[
f
'
total_duration_successful_
{
prio
.
name
}
'
]
# Subtract prio states from total to get partial idle
# Subtract prio states from total to get partial idle
result
[
'
total_duration_idle
'
]
-=
result
[
f
'
total_duration_successful_
{
prio
.
name
}
'
]
result
[
'
total_duration_idle
'
]
-=
result
[
f
'
total_duration_successful_
{
prio
.
name
}
'
]
# Subtract total failed to get total idle eventually
# Subtract total failed to get total idle eventually
result
[
'
total_duration_idle
'
]
-=
result
[
'
total_duration_failed
'
]
result
[
'
total_duration_idle
'
]
-=
result
[
'
total_duration_failed
'
]
# Calculate percentages
result
[
'
successful_perc
'
]
=
result
[
'
total_duration_successful
'
]
*
100.0
/
result
[
'
total_duration
'
]
if
result
[
'
total_duration
'
]
>
0
else
None
result
[
'
idle_perc
'
]
=
result
[
'
total_duration_idle
'
]
*
100.0
/
result
[
'
total_duration
'
]
if
result
[
'
total_duration
'
]
>
0
else
None
result
[
'
failed_perc
'
]
=
result
[
'
total_duration_failed
'
]
*
100.0
/
result
[
'
total_duration
'
]
if
result
[
'
total_duration
'
]
>
0
else
None
result
[
'
ddt_com_rep_perc
'
]
=
result
[
'
DDT Com Rep
'
]
*
100.0
/
result
[
'
total_duration
'
]
if
result
[
'
total_duration
'
]
>
0
else
None
result
[
'
system_unavailability_perc
'
]
=
result
[
'
System Unavailability
'
]
*
100.0
/
result
[
'
total_duration
'
]
if
result
[
'
System Unavailability
'
]
and
result
[
'
total_duration
'
]
>
0
else
None
return
result
return
result
...
@@ -397,6 +410,14 @@ def _get_subs_and_durations_from_project(project_pk: int, start: datetime, stop:
...
@@ -397,6 +410,14 @@ def _get_subs_and_durations_from_project(project_pk: int, start: datetime, stop:
subs
=
{
'
successful
'
:
subs_succeeded
,
'
failed
'
:
subs_failed
}
subs
=
{
'
successful
'
:
subs_succeeded
,
'
failed
'
:
subs_failed
}
# Calculate percentages
durations
[
'
not_cancelled_perc
'
]
=
durations
[
'
total_not_cancelled
'
]
*
100.0
/
durations
[
'
total
'
]
if
durations
[
'
total
'
]
>
0
else
None
durations
[
'
succeeded_perc
'
]
=
durations
[
'
total_succeeded
'
]
*
100.0
/
durations
[
'
total
'
]
if
durations
[
'
total
'
]
>
0
else
None
durations
[
'
failed_perc
'
]
=
durations
[
'
total_failed
'
]
*
100.0
/
durations
[
'
total
'
]
if
durations
[
'
total
'
]
>
0
else
None
durations
[
'
observed_perc
'
]
=
durations
[
'
total_observed
'
]
*
100.0
/
durations
[
'
total
'
]
if
durations
[
'
total
'
]
>
0
else
None
durations
[
'
observed_succeeded_perc
'
]
=
durations
[
'
total_observed_succeeded
'
]
*
100.0
/
durations
[
'
total
'
]
if
durations
[
'
total
'
]
>
0
else
None
durations
[
'
observed_failed_perc
'
]
=
durations
[
'
total_observed_failed
'
]
*
100.0
/
durations
[
'
total
'
]
if
durations
[
'
total
'
]
>
0
else
None
return
subs
,
durations
return
subs
,
durations
...
...
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