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
1ebda268
Commit
1ebda268
authored
5 years ago
by
Jorrit Schaap
Browse files
Options
Downloads
Patches
Plain Diff
TMSS-142
: initial implementation of validation of subtask specification against its schema
parent
d98fa10e
No related branches found
No related tags found
2 merge requests
!98
Resolve TMSS-142 and TMSS-141
,
!97
Resolve TMSS-138
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
SAS/TMSS/src/tmss/tmssapp/models/scheduling.py
+22
-1
22 additions, 1 deletion
SAS/TMSS/src/tmss/tmssapp/models/scheduling.py
with
22 additions
and
1 deletion
SAS/TMSS/src/tmss/tmssapp/models/scheduling.py
+
22
−
1
View file @
1ebda268
...
@@ -8,6 +8,13 @@ from django.contrib.postgres.fields import ArrayField, JSONField
...
@@ -8,6 +8,13 @@ from django.contrib.postgres.fields import ArrayField, JSONField
from
.specification
import
AbstractChoice
,
BasicCommon
,
Template
,
NamedCommon
# , <TaskBlueprint
from
.specification
import
AbstractChoice
,
BasicCommon
,
Template
,
NamedCommon
# , <TaskBlueprint
from
enum
import
Enum
from
enum
import
Enum
from
rest_framework.serializers
import
HyperlinkedRelatedField
from
rest_framework.serializers
import
HyperlinkedRelatedField
from
lofar.sas.tmss.tmss.exceptions
import
*
import
json
import
fastjsonschema
import
jsonschema
#
#
# I/O
# I/O
#
#
...
@@ -127,7 +134,6 @@ class DataproductFeedbackTemplate(Template):
...
@@ -127,7 +134,6 @@ class DataproductFeedbackTemplate(Template):
#
#
# Instance Objects
# Instance Objects
#
#
class
Subtask
(
BasicCommon
):
class
Subtask
(
BasicCommon
):
"""
"""
Represents a low-level task, which is an atomic unit of execution, such as running an observation, running
Represents a low-level task, which is an atomic unit of execution, such as running an observation, running
...
@@ -147,6 +153,21 @@ class Subtask(BasicCommon):
...
@@ -147,6 +153,21 @@ class Subtask(BasicCommon):
scheduler_input_doc
=
JSONField
(
help_text
=
'
Partial specifications, as input for the scheduler.
'
)
scheduler_input_doc
=
JSONField
(
help_text
=
'
Partial specifications, as input for the scheduler.
'
)
# resource_claim = ForeignKey("ResourceClaim", null=False, on_delete=PROTECT) # todo <-- how is this external reference supposed to work?
# resource_claim = ForeignKey("ResourceClaim", null=False, on_delete=PROTECT) # todo <-- how is this external reference supposed to work?
def
validate_specification_against_schema
(
self
):
try
:
# ensure the specification and schema are both valid json in the first place
spec
=
json
.
loads
(
self
.
specifications_doc
)
if
type
(
self
.
specifications_doc
)
==
str
else
self
.
specifications_doc
schema
=
json
.
loads
(
self
.
specifications_template
.
schema
)
if
type
(
self
.
specifications_template
.
schema
)
==
str
else
self
.
specifications_template
.
schema
jsonschema
.
validate
(
spec
,
schema
)
except
Exception
as
e
:
raise
SpecificationException
(
str
(
e
))
def
save
(
self
,
force_insert
=
False
,
force_update
=
False
,
using
=
None
,
update_fields
=
None
):
'''
override of normal save method, doing a validation of the specification against the schema first
:raises SpecificationException in case the specification does not validate against the schema
'''
self
.
validate_specification_against_schema
()
super
().
save
(
force_insert
,
force_update
,
using
,
update_fields
)
class
SubtaskInput
(
BasicCommon
):
class
SubtaskInput
(
BasicCommon
):
subtask
=
ForeignKey
(
'
Subtask
'
,
null
=
False
,
on_delete
=
CASCADE
,
help_text
=
'
Subtask to which this input specification refers.
'
)
subtask
=
ForeignKey
(
'
Subtask
'
,
null
=
False
,
on_delete
=
CASCADE
,
help_text
=
'
Subtask to which this input specification refers.
'
)
...
...
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