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
a24eeab0
Commit
a24eeab0
authored
4 years ago
by
Jorrit Schaap
Browse files
Options
Downloads
Patches
Plain Diff
TMSS-190
: added unschedule methods
parent
4fbfdbf9
No related branches found
No related tags found
1 merge request
!252
Resolve TMSS-190
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
SAS/TMSS/src/tmss/tmssapp/subtasks.py
+33
-0
33 additions, 0 deletions
SAS/TMSS/src/tmss/tmssapp/subtasks.py
SAS/TMSS/src/tmss/tmssapp/tasks.py
+14
-2
14 additions, 2 deletions
SAS/TMSS/src/tmss/tmssapp/tasks.py
with
47 additions
and
2 deletions
SAS/TMSS/src/tmss/tmssapp/subtasks.py
+
33
−
0
View file @
a24eeab0
...
@@ -462,6 +462,39 @@ def schedule_subtask(subtask: Subtask) -> Subtask:
...
@@ -462,6 +462,39 @@ def schedule_subtask(subtask: Subtask) -> Subtask:
# ... and re-raise the original exception
# ... and re-raise the original exception
raise
raise
def
unschedule_subtask
(
subtask
:
Subtask
)
->
Subtask
:
'''
unschedule the given subtask, removing all output dataproducts, and setting its state back to
'
defined
'
.
'''
if
subtask
.
state
.
value
!=
SubtaskState
.
Choices
.
SCHEDULED
.
value
:
raise
SubtaskSchedulingException
(
"
Cannot unschedule subtask id=%d because it is not SCHEDULED. Current state=%s
"
%
(
subtask
.
pk
,
subtask
.
state
.
value
))
try
:
subtask
.
state
=
SubtaskState
.
objects
.
get
(
value
=
SubtaskState
.
Choices
.
UNSCHEDULING
.
value
)
subtask
.
save
()
for
output
in
subtask
.
outputs
.
all
():
output
.
dataproducts
.
all
().
delete
()
#TODO: delete dataproduct transforms
subtask
.
state
=
SubtaskState
.
objects
.
get
(
value
=
SubtaskState
.
Choices
.
DEFINED
.
value
)
subtask
.
save
()
except
Exception
as
e
:
try
:
# set the subtask to state 'ERROR'...
subtask
.
state
=
SubtaskState
.
objects
.
get
(
value
=
SubtaskState
.
Choices
.
ERROR
.
value
)
subtask
.
save
()
except
Exception
as
e2
:
logger
.
error
(
e2
)
finally
:
# ... and re-raise the original exception
raise
def
unschedule_subtasks_in_task_blueprint
(
task_blueprint
:
TaskBlueprint
):
'''
Convenience method: Unschedule (and return) all scheduled subtasks in the task_blueprint
'''
scheduled_subtasks
=
list
(
task_blueprint
.
subtasks
.
filter
(
state__value
=
SubtaskState
.
Choices
.
SCHEDULED
.
value
).
all
())
for
subtask
in
scheduled_subtasks
:
unschedule_subtask
(
subtask
)
def
schedule_subtask_and_update_successor_start_times
(
subtask
:
Subtask
)
->
Subtask
:
def
schedule_subtask_and_update_successor_start_times
(
subtask
:
Subtask
)
->
Subtask
:
scheduled_subtask
=
schedule_subtask
(
subtask
)
scheduled_subtask
=
schedule_subtask
(
subtask
)
shift_successors_until_after_stop_time
(
scheduled_subtask
)
shift_successors_until_after_stop_time
(
scheduled_subtask
)
...
...
This diff is collapsed.
Click to expand it.
SAS/TMSS/src/tmss/tmssapp/tasks.py
+
14
−
2
View file @
a24eeab0
from
lofar.sas.tmss.tmss.exceptions
import
*
from
lofar.sas.tmss.tmss.exceptions
import
*
from
lofar.sas.tmss.tmss.tmssapp
import
models
from
lofar.sas.tmss.tmss.tmssapp
import
models
from
lofar.sas.tmss.tmss.tmssapp.models.specification
import
TaskBlueprint
,
SchedulingUnitBlueprint
,
TaskDraft
,
SchedulingRelationPlacement
from
lofar.sas.tmss.tmss.tmssapp.models.specification
import
TaskBlueprint
,
SchedulingUnitBlueprint
,
TaskDraft
,
SchedulingRelationPlacement
from
lofar.sas.tmss.tmss.tmssapp.subtasks
import
create_and_schedule_subtasks_from_task_blueprint
from
lofar.sas.tmss.tmss.tmssapp.subtasks
import
create_and_schedule_subtasks_from_task_blueprint
,
unschedule_subtasks_in_task_blueprint
from
lofar.sas.tmss.tmss.tmssapp.models.specification
import
TaskBlueprint
,
SchedulingUnitBlueprint
from
lofar.sas.tmss.tmss.tmssapp.models.specification
import
TaskBlueprint
,
SchedulingUnitBlueprint
from
lofar.sas.tmss.tmss.tmssapp.subtasks
import
create_and_schedule_subtasks_from_task_blueprint
,
create_subtasks_from_task_blueprint
,
schedule_independent_subtasks_in_task_blueprint
from
lofar.sas.tmss.tmss.tmssapp.subtasks
import
create_and_schedule_subtasks_from_task_blueprint
,
create_subtasks_from_task_blueprint
,
schedule_independent_subtasks_in_task_blueprint
from
lofar.messaging.messagebus
import
ToBus
,
DEFAULT_BROKER
,
DEFAULT_BUSNAME
from
lofar.messaging.messagebus
import
ToBus
,
DEFAULT_BROKER
,
DEFAULT_BUSNAME
...
@@ -286,7 +286,7 @@ def create_task_blueprints_and_subtasks_and_schedule_subtasks_from_scheduling_un
...
@@ -286,7 +286,7 @@ def create_task_blueprints_and_subtasks_and_schedule_subtasks_from_scheduling_un
def
schedule_independent_subtasks_in_scheduling_unit_blueprint
(
scheduling_unit_blueprint
:
SchedulingUnitBlueprint
,
start_time
:
datetime
=
None
)
->
models
.
SchedulingUnitBlueprint
:
def
schedule_independent_subtasks_in_scheduling_unit_blueprint
(
scheduling_unit_blueprint
:
SchedulingUnitBlueprint
,
start_time
:
datetime
=
None
)
->
models
.
SchedulingUnitBlueprint
:
'''
Convenience method: Schedule the subtasks in the
task
_blueprint that are not dependend on predecessors
'''
'''
Convenience method: Schedule the subtasks in the
scheduling_unit
_blueprint that are not dependend on predecessors
'''
task_blueprints
=
list
(
scheduling_unit_blueprint
.
task_blueprints
.
all
())
task_blueprints
=
list
(
scheduling_unit_blueprint
.
task_blueprints
.
all
())
for
task_blueprint
in
task_blueprints
:
for
task_blueprint
in
task_blueprints
:
...
@@ -294,3 +294,15 @@ def schedule_independent_subtasks_in_scheduling_unit_blueprint(scheduling_unit_b
...
@@ -294,3 +294,15 @@ def schedule_independent_subtasks_in_scheduling_unit_blueprint(scheduling_unit_b
scheduling_unit_blueprint
.
refresh_from_db
()
scheduling_unit_blueprint
.
refresh_from_db
()
return
scheduling_unit_blueprint
return
scheduling_unit_blueprint
def
unschedule_subtasks_in_scheduling_unit_blueprint
(
scheduling_unit_blueprint
:
SchedulingUnitBlueprint
)
->
models
.
SchedulingUnitBlueprint
:
'''
Convenience method: Unschedule all scheduled subtasks in the scheduling_unit_blueprint
'''
task_blueprints
=
list
(
scheduling_unit_blueprint
.
task_blueprints
.
all
())
for
task_blueprint
in
task_blueprints
:
unschedule_subtasks_in_task_blueprint
(
task_blueprint
)
scheduling_unit_blueprint
.
refresh_from_db
()
return
scheduling_unit_blueprint
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