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
adc38bac
Commit
adc38bac
authored
4 years ago
by
Jorrit Schaap
Browse files
Options
Downloads
Patches
Plain Diff
TMSS-244
: crude first implementation of the before and after time constraint
parent
4c86b414
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!252
Resolve TMSS-190
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
SAS/TMSS/services/scheduling/lib/constraints/template_constraints_v1.py
+17
-1
17 additions, 1 deletion
...ces/scheduling/lib/constraints/template_constraints_v1.py
with
17 additions
and
1 deletion
SAS/TMSS/services/scheduling/lib/constraints/template_constraints_v1.py
+
17
−
1
View file @
adc38bac
...
@@ -28,6 +28,7 @@
...
@@ -28,6 +28,7 @@
import
logging
import
logging
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
from
datetime
import
datetime
,
timedelta
from
datetime
import
datetime
,
timedelta
from
lofar.common.datetimeutils
import
parseDatetime
from
lofar.sas.tmss.tmss.tmssapp
import
models
from
lofar.sas.tmss.tmss.tmssapp
import
models
from
lofar.sas.tmss.tmss.tmssapp.conversions
import
create_astroplan_observer_for_station
,
Time
,
timestamps_and_stations_to_sun_rise_and_set
from
lofar.sas.tmss.tmss.tmssapp.conversions
import
create_astroplan_observer_for_station
,
Time
,
timestamps_and_stations_to_sun_rise_and_set
...
@@ -87,6 +88,18 @@ def can_run_within_timewindow_with_time_constraints(scheduling_unit: models.Sche
...
@@ -87,6 +88,18 @@ def can_run_within_timewindow_with_time_constraints(scheduling_unit: models.Sche
'''
evaluate the time contraint(s)
'''
'''
evaluate the time contraint(s)
'''
constraints
=
scheduling_unit
.
draft
.
scheduling_constraints_doc
constraints
=
scheduling_unit
.
draft
.
scheduling_constraints_doc
# TODO: TMSS-244 (and more?), evaluate the constraints in constraints['time']
# TODO: TMSS-244 (and more?), evaluate the constraints in constraints['time']
if
'
before
'
in
constraints
[
'
time
'
]:
before
=
parseDatetime
(
constraints
[
'
time
'
][
'
before
'
].
replace
(
'
T
'
,
'
'
).
replace
(
'
Z
'
,
''
))
return
upper_bound
<=
before
if
'
after
'
in
constraints
[
'
time
'
]:
after
=
parseDatetime
(
constraints
[
'
time
'
][
'
after
'
].
replace
(
'
T
'
,
'
'
).
replace
(
'
Z
'
,
''
))
return
lower_bound
>=
after
# if 'between' in constraints['time']:
# betweens = [ dateutil.parser.parse(constraints['time']['between'])
# return lower_bound >= after
return
True
# for now, ignore time contraints.
return
True
# for now, ignore time contraints.
...
@@ -102,6 +115,9 @@ def get_earliest_possible_start_time(scheduling_unit: models.SchedulingUnitBluep
...
@@ -102,6 +115,9 @@ def get_earliest_possible_start_time(scheduling_unit: models.SchedulingUnitBluep
constraints
=
scheduling_unit
.
draft
.
scheduling_constraints_doc
constraints
=
scheduling_unit
.
draft
.
scheduling_constraints_doc
try
:
try
:
if
'
after
'
in
constraints
[
'
time
'
]:
return
parseDatetime
(
constraints
[
'
time
'
][
'
after
'
].
replace
(
'
T
'
,
'
'
).
replace
(
'
Z
'
,
''
))
if
constraints
[
'
daily
'
][
'
require_day
'
]
or
constraints
[
'
daily
'
][
'
require_night
'
]:
if
constraints
[
'
daily
'
][
'
require_day
'
]
or
constraints
[
'
daily
'
][
'
require_night
'
]:
# TODO: TMSS-254 and TMSS-255
# TODO: TMSS-254 and TMSS-255
...
@@ -162,5 +178,5 @@ def compute_scores(scheduling_unit: models.SchedulingUnitBlueprint, lower_bound:
...
@@ -162,5 +178,5 @@ def compute_scores(scheduling_unit: models.SchedulingUnitBlueprint, lower_bound:
return
ScoredSchedulingUnit
(
scheduling_unit
=
scheduling_unit
,
return
ScoredSchedulingUnit
(
scheduling_unit
=
scheduling_unit
,
scores
=
scores
,
scores
=
scores
,
weighted_score
=
weighted_score
,
weighted_score
=
weighted_score
,
start_time
=
lower_bound
)
start_time
=
get_earliest_possible_start_time
(
scheduling_unit
,
lower_bound
)
)
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