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
51a298fc
Commit
51a298fc
authored
8 years ago
by
Jan David Mol
Browse files
Options
Downloads
Patches
Plain Diff
Task #10557: Fixed parset parsing errors and work-around for missing mom misc field
parent
7444ce69
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
SAS/ResourceAssignment/TaskPrescheduler/prescheduler.py
+27
-22
27 additions, 22 deletions
SAS/ResourceAssignment/TaskPrescheduler/prescheduler.py
with
27 additions
and
22 deletions
SAS/ResourceAssignment/TaskPrescheduler/prescheduler.py
+
27
−
22
View file @
51a298fc
...
@@ -7,6 +7,7 @@ This means adding/updating some Cobal keys, selecting available stations,
...
@@ -7,6 +7,7 @@ This means adding/updating some Cobal keys, selecting available stations,
selecting the right timeslot and updating start/end time.
selecting the right timeslot and updating start/end time.
'''
'''
from
datetime
import
datetime
,
timedelta
from
datetime
import
datetime
,
timedelta
import
pprint
from
lofar.parameterset
import
PyParameterValue
from
lofar.parameterset
import
PyParameterValue
from
lofar.sas.otdb.OTDBBusListener
import
OTDBBusListener
from
lofar.sas.otdb.OTDBBusListener
import
OTDBBusListener
from
lofar.sas.otdb.otdbrpc
import
OTDBRPC
from
lofar.sas.otdb.otdbrpc
import
OTDBRPC
...
@@ -28,27 +29,35 @@ COBALT = "Observation.ObservationControl.OnlineControl.Cobalt."
...
@@ -28,27 +29,35 @@ COBALT = "Observation.ObservationControl.OnlineControl.Cobalt."
def
calculateCobaltSettings
(
parset
):
def
calculateCobaltSettings
(
parset
):
"""
uses parset keys to calculate Cobalt block size and integration time
"""
"""
uses parset keys to calculate Cobalt block size and integration time
"""
if
parset
(
DATAPRODUCTS
+
"
Output_Correlated.enabled
"
):
def
bool
(
value
):
return
PyParameterValue
(
str
(
value
),
True
).
getBool
()
if
bool
(
parset
[
DATAPRODUCTS
+
"
Output_Correlated.enabled
"
]):
corr
=
CorrelatorSettings
()
corr
=
CorrelatorSettings
()
corr
.
nrChannelsPerSubband
=
parset
(
COBALT
+
"
Correlator.nrChannelsPerSubband
"
)
corr
.
nrChannelsPerSubband
=
int
(
parset
[
COBALT
+
"
Correlator.nrChannelsPerSubband
"
]
)
corr
.
integrationTime
=
parset
(
COBALT
+
"
Correlator.integrationTime
"
)
corr
.
integrationTime
=
float
(
parset
[
COBALT
+
"
Correlator.integrationTime
"
]
)
else
:
else
:
corr
=
None
corr
=
None
if
parset
(
DATAPRODUCTS
+
"
Output_CoherentStokes.enabled
"
):
if
bool
(
parset
[
DATAPRODUCTS
+
"
Output_CoherentStokes.enabled
"
]):
coherent
=
StokesSettings
()
coherent
=
StokesSettings
()
coherent
.
nrChannelsPerSubband
=
parset
(
COBALT
+
"
BeamFormer.CoherentStokes.nrChannelsPerSubband
"
)
coherent
.
nrChannelsPerSubband
=
int
(
parset
[
COBALT
+
"
BeamFormer.CoherentStokes.nrChannelsPerSubband
"
]
)
coherent
.
timeIntegrationFactor
=
parset
(
COBALT
+
"
BeamFormer.CoherentStokes.timeIntegrationFactor
"
)
coherent
.
timeIntegrationFactor
=
int
(
parset
[
COBALT
+
"
BeamFormer.CoherentStokes.timeIntegrationFactor
"
]
)
else
:
else
:
coherent
=
None
coherent
=
None
if
parset
(
DATAPRODUCTS
+
"
Output_IncoherentStokes.enabled
"
):
if
bool
(
parset
[
DATAPRODUCTS
+
"
Output_IncoherentStokes.enabled
"
]):
incoherent
=
StokesSettings
()
incoherent
=
StokesSettings
()
incoherent
.
nrChannelsPerSubband
=
parset
(
COBALT
+
"
BeamFormer.IncoherentStokes.nrChannelsPerSubband
"
)
incoherent
.
nrChannelsPerSubband
=
int
(
parset
[
COBALT
+
"
BeamFormer.IncoherentStokes.nrChannelsPerSubband
"
]
)
incoherent
.
timeIntegrationFactor
=
parset
(
COBALT
+
"
BeamFormer.IncoherentStokes.timeIntegrationFactor
"
)
incoherent
.
timeIntegrationFactor
=
int
(
parset
[
COBALT
+
"
BeamFormer.IncoherentStokes.timeIntegrationFactor
"
]
)
else
:
else
:
incoherent
=
None
incoherent
=
None
clock
=
parset
(
"
Observation.sampleClock
"
)
clock
=
int
(
parset
[
"
Observation.sampleClock
"
])
constraints
=
BlockConstraints
(
corr
,
coherent
,
incoherent
,
clock
)
constraints
=
BlockConstraints
(
corr
,
coherent
,
incoherent
,
clock
)
calculator
=
BlockSize
(
constraints
)
calculator
=
BlockSize
(
constraints
)
return
{
'
nrSubblocks
'
:
calculator
.
nrSubblocks
,
'
blockSize
'
:
calculator
.
blockSize
,
return
{
'
nrSubblocks
'
:
calculator
.
nrSubblocks
,
'
blockSize
'
:
calculator
.
blockSize
,
'
nrBlocks
'
:
calculator
.
nrBlocks
,
'
integrationTime
'
:
calculator
.
integrationTime
}
'
nrBlocks
'
:
calculator
.
nrBlocks
,
'
integrationTime
'
:
calculator
.
integrationTime
}
...
@@ -77,9 +86,6 @@ def resourceIndicatorsFromParset( parsetDict ):
...
@@ -77,9 +86,6 @@ def resourceIndicatorsFromParset( parsetDict ):
#def intvector(value):
#def intvector(value):
# return PyParameterValue(str(value), True)._expand().getIntVector()
# return PyParameterValue(str(value), True)._expand().getIntVector()
def
bool
(
value
):
return
PyParameterValue
(
str
(
value
),
True
).
getBool
()
# =====================================
# =====================================
# Parset meta info
# Parset meta info
# =====================================
# =====================================
...
@@ -97,10 +103,6 @@ def resourceIndicatorsFromParset( parsetDict ):
...
@@ -97,10 +103,6 @@ def resourceIndicatorsFromParset( parsetDict ):
add
(
"
Observation.DataProducts.Output_Correlated.enabled
"
,
bool
)
add
(
"
Observation.DataProducts.Output_Correlated.enabled
"
,
bool
)
add
(
"
Observation.ObservationControl.OnlineControl.Cobalt.Correlator.integrationTime
"
)
add
(
"
Observation.ObservationControl.OnlineControl.Cobalt.Correlator.integrationTime
"
)
add
(
"
Observation.ObservationControl.OnlineControl.Cobalt.Correlator.nrChannelsPerSubband
"
)
add
(
"
Observation.ObservationControl.OnlineControl.Cobalt.Correlator.nrChannelsPerSubband
"
)
# This service should compute these 3 values, do we need to read them?
add
(
"
Cobalt.Correlator.nrBlocksPerIntegration
"
)
add
(
"
Cobalt.Correlator.nrIntegrationsPerBlock
"
)
add
(
"
Cobalt.blockSize
"
)
add
(
"
Observation.DataProducts.Output_IncoherentStokes.enabled
"
,
bool
)
add
(
"
Observation.DataProducts.Output_IncoherentStokes.enabled
"
,
bool
)
add
(
"
Observation.DataProducts.Output_CoherentStokes.enabled
"
,
bool
)
add
(
"
Observation.DataProducts.Output_CoherentStokes.enabled
"
,
bool
)
...
@@ -141,6 +143,7 @@ class TaskPrescheduler(OTDBBusListener):
...
@@ -141,6 +143,7 @@ class TaskPrescheduler(OTDBBusListener):
def
onObservationApproved
(
self
,
treeId
,
modificationTime
):
def
onObservationApproved
(
self
,
treeId
,
modificationTime
):
"""
Updates task specification and puts task on prescheduled if it was generated by a trigger
"""
Updates task specification and puts task on prescheduled if it was generated by a trigger
"""
#TODO might work for all tasks in the future
"""
#TODO might work for all tasks in the future
# TODO: only process observations and pipelines
try
:
try
:
otdb_id
=
treeId
otdb_id
=
treeId
#Race condition when asking MoM as the mom-otdb-adapter might not have heard that the
#Race condition when asking MoM as the mom-otdb-adapter might not have heard that the
...
@@ -157,18 +160,20 @@ class TaskPrescheduler(OTDBBusListener):
...
@@ -157,18 +160,20 @@ class TaskPrescheduler(OTDBBusListener):
mom_id
=
None
mom_id
=
None
if
mom_id
:
if
mom_id
:
response
=
self
.
momquery
.
get_trigger_id
(
mom_id
)
response
=
self
.
momquery
.
get_trigger_id
(
mom_id
)
response
=
{
"
status
"
:
"
OK
"
,
"
trigger_id
"
:
1
}
# TODO: mom does not fill in misc field
if
response
[
'
status
'
]
==
'
OK
'
:
if
response
[
'
status
'
]
==
'
OK
'
:
logger
.
info
(
'
Found a task mom_id=%s with a trigger_id=%s
'
,
mom_id
,
response
[
'
trigger_id
'
])
logger
.
info
(
'
Found a task mom_id=%s with a trigger_id=%s
'
,
mom_id
,
response
[
'
trigger_id
'
])
#TODO, check for stations and other resources, start/endtime, target position, then update specification
#TODO, check for stations and other resources, start/endtime, target position, then update specification
# TODO: set cobalt values only for observations
cobalt_values
=
calculateCobaltSettings
(
specification
)
cobalt_values
=
calculateCobaltSettings
(
specification
)
logger
.
info
(
'
prescheduling otdb_id=%s because it was generated by trigger_id=%s
'
,
otdb_id
,
response
[
'
trigger_id
'
])
logger
.
info
(
'
prescheduling otdb_id=%s because it was generated by trigger_id=%s
'
,
otdb_id
,
response
[
'
trigger_id
'
])
otdb_info
=
{}
otdb_info
=
{}
otdb_info
[
OUTPUT_PREFIX
+
"
Cobalt.
Correlator.nrBlocksPerIntegration
"
]
=
cobalt_values
[
"
nrBlocks
"
]
otdb_info
[
OUTPUT_PREFIX
+
COBALT
+
"
Correlator.nrBlocksPerIntegration
"
]
=
cobalt_values
[
"
nrBlocks
"
]
otdb_info
[
OUTPUT_PREFIX
+
"
Cobalt.
Correlator.nrIntegrationsPerBlock
"
]
=
cobalt_values
[
"
nrSubblocks
"
]
otdb_info
[
OUTPUT_PREFIX
+
COBALT
+
"
Correlator.nrIntegrationsPerBlock
"
]
=
cobalt_values
[
"
nrSubblocks
"
]
otdb_info
[
OUTPUT_PREFIX
+
"
Cobalt.
blockSize
"
]
=
cobalt_values
[
"
blockSize
"
]
otdb_info
[
OUTPUT_PREFIX
+
COBALT
+
"
blockSize
"
]
=
cobalt_values
[
"
blockSize
"
]
otdb_info
[
OUTPUT_PREFIX
+
"
Cobalt.
Correlator.integrationTime
"
]
=
cobalt_values
[
"
integrationTime
"
]
otdb_info
[
OUTPUT_PREFIX
+
COBALT
+
"
Correlator.integrationTime
"
]
=
cobalt_values
[
"
integrationTime
"
]
self
.
setOTDBinfo
(
otdb_id
,
otdb_info
,
'
prescheduled
'
)
self
.
setOTDBinfo
(
otdb_id
,
otdb_info
,
'
prescheduled
'
)
else
:
else
:
logger
.
info
(
'
Did not find a trigger for task mom_id=%s, because %s
'
,
mom_id
,
response
[
'
errors
'
])
logger
.
info
(
'
Did not find a trigger for task mom_id=%s, because %s
'
,
mom_id
,
response
[
'
errors
'
])
...
@@ -190,7 +195,7 @@ class TaskPrescheduler(OTDBBusListener):
...
@@ -190,7 +195,7 @@ class TaskPrescheduler(OTDBBusListener):
self
.
otdbrpc
.
taskSetStatus
(
otdb_id
,
otdb_status
)
self
.
otdbrpc
.
taskSetStatus
(
otdb_id
,
otdb_status
)
except
Exception
as
e
:
except
Exception
as
e
:
logger
.
error
(
e
)
logger
.
error
(
e
)
self
.
doTaskError
(
otdb_id
)
#FIXME should be to the RADB also or instead?
#
self.doTaskError(otdb_id) #FIXME should be to the RADB also or instead?
def
main
():
def
main
():
from
optparse
import
OptionParser
from
optparse
import
OptionParser
...
...
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