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
e780b49e
Commit
e780b49e
authored
7 years ago
by
Jorrit Schaap
Browse files
Options
Downloads
Patches
Plain Diff
Task #10902: do applySaneStartEndTime for all tasks with incorrect start/end times
parent
38d1d72a
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
SAS/ResourceAssignment/ResourceAssigner/lib/assignment.py
+22
-19
22 additions, 19 deletions
SAS/ResourceAssignment/ResourceAssigner/lib/assignment.py
with
22 additions
and
19 deletions
SAS/ResourceAssignment/ResourceAssigner/lib/assignment.py
+
22
−
19
View file @
e780b49e
...
...
@@ -134,7 +134,7 @@ class ResourceAssigner():
@property
@cache
def
resource_group_relations
(
self
):
"""
Returns a dict of resource groups and their relations. Does not include resources.
"""
Returns a dict of resource groups and their relations. Does not include resources.
Each dict element has the resource group id as key, and the following value:
...
...
@@ -152,7 +152,7 @@ class ResourceAssigner():
return
{
rt
[
'
name
'
]:
rt
[
'
id
'
]
for
rt
in
self
.
radbrpc
.
getResourceTypes
()}
@property
@cache
def
resource_claim_property_types
(
self
):
...
...
@@ -231,36 +231,39 @@ class ResourceAssigner():
# task has no output
clusterName
=
''
def
applySaneStartEndTime
(
origStartTime
,
origEndTime
):
def
applySaneStartEndTime
():
startTime
=
datetime
.
utcnow
()
+
timedelta
(
minutes
=
3
)
maxPredecessorEndTime
=
self
.
getMaxPredecessorEndTime
(
specification_tree
)
if
maxPredecessorEndTime
and
maxPredecessorEndTime
>
startTime
:
startTime
=
maxPredecessorEndTime
+
timedelta
(
minutes
=
3
)
taskDuration
=
timedelta
(
seconds
=
totalSeconds
(
origEndTime
-
origStartTime
))
if
origEndTime
>
origStartTime
else
timedelta
(
hours
=
1
)
taskDuration
=
mainParset
.
getInt
(
'
Observation.Scheduler.taskDuration
'
,
-
1
)
taskDuration
=
timedelta
(
seconds
=
taskDuration
)
if
taskDuration
>
0
else
timedelta
(
hours
=
1
)
endTime
=
startTime
+
taskDuration
logger
.
warning
(
'
Applying sane defaults (%s, %s) for start/end time from specification for otdb_id=%s
'
,
startTime
,
endTime
,
otdb_id
)
startTime
,
endTime
,
otdb_id
)
logger
.
info
(
'
uploading auto-generated start/end time (%s, %s) to otdb for otdb_id=%s
'
,
startTime
,
endTime
,
otdb_id
)
self
.
otdbrpc
.
taskSetSpecification
(
otdb_id
,
{
'
LOFAR.ObsSW.Observation.startTime
'
:
startTime
.
strftime
(
'
%Y-%m-%d %H:%M:%S
'
),
'
LOFAR.ObsSW.Observation.stopTime
'
:
endTime
.
strftime
(
'
%Y-%m-%d %H:%M:%S
'
)})
return
startTime
,
endTime
try
:
logger
.
info
(
'
uploading auto-generated start/end time (%s, %s) to otdb for otdb_id=%s
'
,
startTime
,
endTime
,
otdb_id
)
self
.
otdbrpc
.
taskSetSpecification
(
otdb_id
,
{
'
LOFAR.ObsSW.Observation.startTime
'
:
startTime
.
strftime
(
'
%Y-%m-%d %H:%M:%S
'
),
'
LOFAR.ObsSW.Observation.stopTime
'
:
endTime
.
strftime
(
'
%Y-%m-%d %H:%M:%S
'
)})
except
Exception
as
e
:
logger
.
error
(
e
)
return
startTime
,
endTime
# TODO: don't fix this crap here. Bad start/stop time has to go to error, like any other bad spec part. Fix the cause! Idem for MoM fix up below.
try
:
startTime
=
parseDatetime
(
mainParset
.
getString
(
'
Observation.startTime
'
))
endTime
=
parseDatetime
(
mainParset
.
getString
(
'
Observation.stopTime
'
))
if
startTime
<
datetime
.
utcnow
():
startTime
,
endTime
=
applySaneStartEndTime
(
startTime
,
endTime
)
except
Exception
as
e
:
logger
.
err
or
(
st
r
(
e
)
)
return
startTime
,
endTime
=
applySaneStartEndTime
()
except
Exception
:
logger
.
warning
(
'
cannot parse f
or
st
art/end time from specification for otdb_id=%s. searching for sane defaults...
'
,
otdb_id
)
startTime
,
endTime
=
applySaneStartEndTime
()
logger
.
info
(
'
doAssignment: Accepted specification
'
)
...
...
@@ -544,10 +547,10 @@ class ResourceAssigner():
def
findClaims
(
self
,
needed_resources_list
,
db_resource_list
):
"""
Compute claims that satisfy needed_resources_list within db_resource_list.
:param needed_resources_list: a list of resources to be claimed
:param db_resource_list: all resources in RADB with availability information
:returns all_fit: a boolean indicating whether all requested resources could be claimed
:returns claims: all claims that succeeded (partial if all_fit is False)
:returns unclaimable_resources: all resources from needed_resources_list that could not be claimed ([] if all_fit is True)
...
...
@@ -748,12 +751,12 @@ class ResourceAssigner():
def
is_claimable_capacity_wise
(
self
,
needed_resources
,
claimable_resources
,
ignore_type_ids
=
None
):
"""
Returns whether all needed_resources can be claimed from claimable_resources.
:param needed_resources: {resource_type_id: size, ...}
:param claimable_resources: {resource_type_id: {<resource_dict>}, ...}
:param ignore_type_ids: IDs of types that should not be considered
"""
types_to_ignore
=
ignore_type_ids
if
ignore_type_ids
is
not
None
else
[]
...
...
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