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
4468f5ad
Commit
4468f5ad
authored
4 years ago
by
Jörn Künsemöller
Browse files
Options
Downloads
Patches
Plain Diff
TMSS-221
: add start/stop/duration properties to drafts and blueprints of task/scheduling_unit.
parent
7446acc7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!186
Resolve TMSS-221
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
SAS/TMSS/src/tmss/tmssapp/models/specification.py
+133
-0
133 additions, 0 deletions
SAS/TMSS/src/tmss/tmssapp/models/specification.py
SAS/TMSS/src/tmss/tmssapp/serializers/specification.py
+4
-4
4 additions, 4 deletions
SAS/TMSS/src/tmss/tmssapp/serializers/specification.py
with
137 additions
and
4 deletions
SAS/TMSS/src/tmss/tmssapp/models/specification.py
+
133
−
0
View file @
4468f5ad
...
@@ -12,6 +12,7 @@ from django.db.models.deletion import ProtectedError
...
@@ -12,6 +12,7 @@ from django.db.models.deletion import ProtectedError
from
lofar.sas.tmss.tmss.tmssapp.validation
import
validate_json_against_schema
from
lofar.sas.tmss.tmss.tmssapp.validation
import
validate_json_against_schema
from
django.core.exceptions
import
ValidationError
from
django.core.exceptions
import
ValidationError
from
rest_framework
import
status
from
rest_framework
import
status
import
datetime
#
#
# Common
# Common
...
@@ -303,6 +304,38 @@ class SchedulingUnitDraft(NamedCommon):
...
@@ -303,6 +304,38 @@ class SchedulingUnitDraft(NamedCommon):
super
().
save
(
force_insert
,
force_update
,
using
,
update_fields
)
super
().
save
(
force_insert
,
force_update
,
using
,
update_fields
)
@property
def
duration
(
self
)
->
float
or
None
:
'''
return the overall duration in seconds of all tasks of this scheduling unit
'''
if
self
.
start_time
is
None
or
self
.
stop_time
is
None
:
# todo: calculate?
return
None
else
:
return
(
self
.
stop_time
-
self
.
start_time
).
total_seconds
()
@property
def
start_time
(
self
)
->
datetime
or
None
:
'''
return the earliest start time of all tasks of this scheduling unit
'''
tasks_with_start_time
=
list
(
filter
(
lambda
x
:
x
.
start_time
is
not
None
,
self
.
task_drafts
.
all
()))
if
tasks_with_start_time
:
return
min
(
tasks_with_start_time
,
key
=
lambda
x
:
x
.
start_time
).
start_time
else
:
# todo: calculate?
return
None
@property
def
stop_time
(
self
)
->
datetime
or
None
:
'''
return the latest end time of all tasks of this scheduling unit
'''
tasks_with_stop_time
=
list
(
filter
(
lambda
x
:
x
.
stop_time
is
not
None
,
self
.
task_drafts
.
all
()))
if
tasks_with_stop_time
:
return
max
(
tasks_with_stop_time
,
key
=
lambda
x
:
x
.
stop_time
).
stop_time
else
:
# todo: calculate?
return
None
class
SchedulingUnitBlueprint
(
NamedCommon
):
class
SchedulingUnitBlueprint
(
NamedCommon
):
requirements_doc
=
JSONField
(
help_text
=
'
Scheduling and/or quality requirements for this scheduling unit (IMMUTABLE).
'
)
requirements_doc
=
JSONField
(
help_text
=
'
Scheduling and/or quality requirements for this scheduling unit (IMMUTABLE).
'
)
...
@@ -316,6 +349,38 @@ class SchedulingUnitBlueprint(NamedCommon):
...
@@ -316,6 +349,38 @@ class SchedulingUnitBlueprint(NamedCommon):
super
().
save
(
force_insert
,
force_update
,
using
,
update_fields
)
super
().
save
(
force_insert
,
force_update
,
using
,
update_fields
)
@property
def
duration
(
self
)
->
float
or
None
:
'''
return the overall duration in seconds of all tasks of this scheduling unit
'''
if
self
.
start_time
is
None
or
self
.
stop_time
is
None
:
# todo: calculate?
return
None
else
:
return
(
self
.
stop_time
-
self
.
start_time
).
total_seconds
()
@property
def
start_time
(
self
)
->
datetime
or
None
:
'''
return the earliest start time of all tasks of this scheduling unit
'''
tasks_with_start_time
=
list
(
filter
(
lambda
x
:
x
.
start_time
is
not
None
,
self
.
task_blueprints
.
all
()))
if
tasks_with_start_time
:
return
min
(
tasks_with_start_time
,
key
=
lambda
x
:
x
.
start_time
).
start_time
else
:
# todo: calculate?
return
None
@property
def
stop_time
(
self
)
->
datetime
or
None
:
'''
return the latest end time of all tasks of this scheduling unit
'''
tasks_with_stop_time
=
list
(
filter
(
lambda
x
:
x
.
stop_time
is
not
None
,
self
.
task_blueprints
.
all
()))
if
tasks_with_stop_time
:
return
max
(
tasks_with_stop_time
,
key
=
lambda
x
:
x
.
stop_time
).
stop_time
else
:
# todo: calculate?
return
None
class
TaskDraft
(
NamedCommon
):
class
TaskDraft
(
NamedCommon
):
specifications_doc
=
JSONField
(
help_text
=
'
Specifications for this task.
'
)
specifications_doc
=
JSONField
(
help_text
=
'
Specifications for this task.
'
)
...
@@ -350,6 +415,41 @@ class TaskDraft(NamedCommon):
...
@@ -350,6 +415,41 @@ class TaskDraft(NamedCommon):
"
INNER JOIN tmssapp_taskrelationdraft as task_rel on task_rel.producer_id = successor_task.id
\n
"
"
INNER JOIN tmssapp_taskrelationdraft as task_rel on task_rel.producer_id = successor_task.id
\n
"
"
WHERE task_rel.consumer_id = %s
"
,
params
=
[
self
.
id
]))
"
WHERE task_rel.consumer_id = %s
"
,
params
=
[
self
.
id
]))
@property
def
duration
(
self
)
->
float
or
None
:
'''
returns the overall duration in seconds of all blueprints of this draft
# todo: is this the wanted behavior? Do you want to consider all the blueprints created from your draft or do you want to preview a new blueprint?
'''
if
self
.
start_time
is
None
or
self
.
stop_time
is
None
:
# todo: calculate?
return
None
else
:
return
(
self
.
stop_time
-
self
.
start_time
).
total_seconds
()
@property
def
start_time
(
self
)
->
datetime
or
None
:
'''
return the earliest start time of all blueprints of this draft
# todo: is this the wanted behavior? Do you want to consider all the blueprints created from your draft or do you want to preview a new blueprint?
'''
blueprints_with_start_time
=
list
(
filter
(
lambda
x
:
x
.
start_time
is
not
None
,
self
.
task_blueprints
.
all
()))
if
blueprints_with_start_time
:
return
min
(
blueprints_with_start_time
,
key
=
lambda
x
:
x
.
start_time
).
start_time
else
:
# todo: calculate?
return
None
@property
def
stop_time
(
self
)
->
datetime
or
None
:
'''
return the latest end time of all blueprints of this draft
# todo: is this the wanted behavior? Do you want to consider all the blueprints created from your draft or do you want to preview a new blueprint?
'''
blueprints_with_stop_time
=
list
(
filter
(
lambda
x
:
x
.
stop_time
is
not
None
,
self
.
task_blueprints
.
all
()))
if
blueprints_with_stop_time
:
return
max
(
blueprints_with_stop_time
,
key
=
lambda
x
:
x
.
stop_time
).
stop_time
else
:
# todo: calculate?
return
None
class
TaskBlueprint
(
NamedCommon
):
class
TaskBlueprint
(
NamedCommon
):
specifications_doc
=
JSONField
(
help_text
=
'
Schedulings for this task (IMMUTABLE).
'
)
specifications_doc
=
JSONField
(
help_text
=
'
Schedulings for this task (IMMUTABLE).
'
)
...
@@ -384,6 +484,39 @@ class TaskBlueprint(NamedCommon):
...
@@ -384,6 +484,39 @@ class TaskBlueprint(NamedCommon):
"
INNER JOIN tmssapp_taskrelationblueprint as task_rel on task_rel.producer_id = predecessor_task.id
\n
"
"
INNER JOIN tmssapp_taskrelationblueprint as task_rel on task_rel.producer_id = predecessor_task.id
\n
"
"
WHERE task_rel.consumer_id = %s
"
,
params
=
[
self
.
id
]))
"
WHERE task_rel.consumer_id = %s
"
,
params
=
[
self
.
id
]))
@property
def
duration
(
self
)
->
float
or
None
:
'''
return the overall duration in seconds of all subtasks of this task
'''
if
self
.
start_time
is
None
or
self
.
stop_time
is
None
:
# todo: calculate?
return
None
else
:
return
(
self
.
stop_time
-
self
.
start_time
).
total_seconds
()
@property
def
start_time
(
self
)
->
datetime
or
None
:
'''
return the earliest start time of all subtasks of this draft
'''
subtasks_with_start_time
=
list
(
filter
(
lambda
x
:
x
.
start_time
is
not
None
,
self
.
subtasks
.
all
()))
if
subtasks_with_start_time
:
return
min
(
subtasks_with_start_time
,
key
=
lambda
x
:
x
.
start_time
).
start_time
else
:
# todo: calculate?
return
None
@property
def
stop_time
(
self
)
->
datetime
or
None
:
'''
return the latest end time of all subtasks of this draft
'''
subtasks_with_stop_time
=
list
(
filter
(
lambda
x
:
x
.
stop_time
is
not
None
,
self
.
subtasks
.
all
()))
if
subtasks_with_stop_time
:
return
max
(
subtasks_with_stop_time
,
key
=
lambda
x
:
x
.
stop_time
).
stop_time
else
:
# todo: calculate?
return
None
class
TaskRelationDraft
(
BasicCommon
):
class
TaskRelationDraft
(
BasicCommon
):
selection_doc
=
JSONField
(
help_text
=
'
Filter for selecting dataproducts from the output role.
'
)
selection_doc
=
JSONField
(
help_text
=
'
Filter for selecting dataproducts from the output role.
'
)
...
...
This diff is collapsed.
Click to expand it.
SAS/TMSS/src/tmss/tmssapp/serializers/specification.py
+
4
−
4
View file @
4468f5ad
...
@@ -243,7 +243,7 @@ class SchedulingUnitDraftSerializer(RelationalHyperlinkedModelSerializer):
...
@@ -243,7 +243,7 @@ class SchedulingUnitDraftSerializer(RelationalHyperlinkedModelSerializer):
class
Meta
:
class
Meta
:
model
=
models
.
SchedulingUnitDraft
model
=
models
.
SchedulingUnitDraft
fields
=
'
__all__
'
fields
=
'
__all__
'
extra_fields
=
[
'
scheduling_unit_blueprints
'
,
'
task_drafts
'
]
extra_fields
=
[
'
scheduling_unit_blueprints
'
,
'
task_drafts
'
,
'
duration
'
,
'
start_time
'
,
'
stop_time
'
]
class
SchedulingUnitBlueprintSerializer
(
RelationalHyperlinkedModelSerializer
):
class
SchedulingUnitBlueprintSerializer
(
RelationalHyperlinkedModelSerializer
):
...
@@ -260,7 +260,7 @@ class SchedulingUnitBlueprintSerializer(RelationalHyperlinkedModelSerializer):
...
@@ -260,7 +260,7 @@ class SchedulingUnitBlueprintSerializer(RelationalHyperlinkedModelSerializer):
class
Meta
:
class
Meta
:
model
=
models
.
SchedulingUnitBlueprint
model
=
models
.
SchedulingUnitBlueprint
fields
=
'
__all__
'
fields
=
'
__all__
'
extra_fields
=
[
'
task_blueprints
'
]
extra_fields
=
[
'
task_blueprints
'
,
'
duration
'
,
'
start_time
'
,
'
stop_time
'
]
class
TaskDraftSerializer
(
RelationalHyperlinkedModelSerializer
):
class
TaskDraftSerializer
(
RelationalHyperlinkedModelSerializer
):
...
@@ -277,7 +277,7 @@ class TaskDraftSerializer(RelationalHyperlinkedModelSerializer):
...
@@ -277,7 +277,7 @@ class TaskDraftSerializer(RelationalHyperlinkedModelSerializer):
class
Meta
:
class
Meta
:
model
=
models
.
TaskDraft
model
=
models
.
TaskDraft
fields
=
'
__all__
'
fields
=
'
__all__
'
extra_fields
=
[
'
task_blueprints
'
,
'
produced_by
'
,
'
consumed_by
'
,
'
first_to_connect
'
,
'
second_to_connect
'
]
extra_fields
=
[
'
task_blueprints
'
,
'
produced_by
'
,
'
consumed_by
'
,
'
first_to_connect
'
,
'
second_to_connect
'
,
'
duration
'
,
'
start_time
'
,
'
stop_time
'
]
class
TaskBlueprintSerializer
(
RelationalHyperlinkedModelSerializer
):
class
TaskBlueprintSerializer
(
RelationalHyperlinkedModelSerializer
):
...
@@ -294,7 +294,7 @@ class TaskBlueprintSerializer(RelationalHyperlinkedModelSerializer):
...
@@ -294,7 +294,7 @@ class TaskBlueprintSerializer(RelationalHyperlinkedModelSerializer):
class
Meta
:
class
Meta
:
model
=
models
.
TaskBlueprint
model
=
models
.
TaskBlueprint
fields
=
'
__all__
'
fields
=
'
__all__
'
extra_fields
=
[
'
subtasks
'
,
'
produced_by
'
,
'
consumed_by
'
,
'
first_to_connect
'
,
'
second_to_connect
'
]
extra_fields
=
[
'
subtasks
'
,
'
produced_by
'
,
'
consumed_by
'
,
'
first_to_connect
'
,
'
second_to_connect
'
,
'
duration
'
,
'
start_time
'
,
'
stop_time
'
]
class
TaskRelationDraftSerializer
(
RelationalHyperlinkedModelSerializer
):
class
TaskRelationDraftSerializer
(
RelationalHyperlinkedModelSerializer
):
...
...
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