-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
validation: make environment property mandatory in serial steps #415
validation: make environment property mandatory in serial steps #415
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #415 +/- ##
==========================================
+ Coverage 37.50% 37.66% +0.16%
==========================================
Files 26 26
Lines 1557 1561 +4
==========================================
+ Hits 584 588 +4
Misses 973 973
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to break some non-serial workflows, such as the Snakemake version of helloworld. Can you reproduce this?
$ reana-client run -f reana-snakemake.yaml
==> Creating a workflow...
Job stats:
job count min threads max threads
---------- ------- ------------- -------------
all 1 1 1
helloworld 1 1 1
total 2 1 1
[WARNING] Job stats:
job count min threads max threads
---------- ------- ------------- -------------
all 1 1 1
helloworld 1 1 1
total 2 1 1
==> Verifying REANA specification file... .../reana-demo-helloworld/reana-snakemake.yaml
[ERROR] Invalid REANA specification: None is not of type 'string'
==> ERROR: Cannot create workflow :
None is not of type 'string'
Failed validating 'type' in schema['properties']['workflow']['properties']['specification']['properties']['steps']['items']['properties']['kubernetes_memory_limit']:
{'id': '/properties/workflow/properties/specification/properties/steps/properties/kubernetes_memory_limit',
'title': 'Memory limit for the step container (e.g. 256Mi).',
'type': 'string'}
On instance['workflow']['specification']['steps'][0]['kubernetes_memory_limit']:
None
Also note that the CWL version has a very different workflow.specification
(even though it still works fine):
"workflow": {
"file": "workflow/cwl/helloworld.cwl",
"specification": {
"$graph": [
{
"class": "Workflow",
"id": "#main",
"inputs": [
{
"id": "#main/helloworld",
"type": "File"
...
Maybe it's possible to check the schema of workflow.specification
only if workflow.type
is serial?
Apparently this happens because the Snakemake specification is loaded using
AFAIK in JSON Schema draft-04 (the one we are using), one can't express conditional requirements directly. JSON Schema draft-07 introduced the {
...
"workflow": {
...
"properties": {
"type": {
"type": "string",
"enum": [
"cwl",
"serial",
"yadage",
"snakemake"
]
}
},
"if": {
"properties": {
"type": {
"const": "serial"
}
}
},
"then": {
"properties": {
"specification": {
"properties": {
"steps": {
"items": {
"required": ["environment"]
}
}
}
}
}
},
"else": {
"properties": {
"specification": {
"id": ...
}
}
}
}
} But upgrading to draft-07 might not be worth it, especially if it's only for this reason (draft-06 introduced a few big backwards-incompatible changes). Another valid option at this point would be to add only the
In this way, also, all the specifications covered by Yet another alternative, mentioned in the JSONSchema documentation, could be to use a small boolean algebra trick to rewrite the Finally, the last option I see is enforcing different JSON schemas for different workflow types at the To recap: What do you think? |
5750fce
to
3d5b5a6
Compare
Thanks for the nice analysis. IMO the soluttion 3 will do for the problem at hand, but we should be ready to improve the behaviour during sandboxing sprint. For example, I've heard a wish from Snakemake users who typically use the same container for all the steps that they did not really expect having to specify the Ideally, it would be nice to have different schemas for different workflow engines, or at least conditionals, so that we can express truly all the constraints, and cover other fields, not only environments. But this would be a bigger change that could probably go together with the sandboxing sprint... |
269a6c5
to
4ea3b69
Compare
d804bcd
to
827d309
Compare
CHANGES.rst
Outdated
@@ -4,7 +4,10 @@ Changes | |||
Version 0.9.4 (UNRELEASED) | |||
-------------------------- | |||
|
|||
- Changes the REANA specification schema to use the ``draft 2020-12`` version of the JSON schema specification. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Changes the REANA specification schema to use the ``draft 2020-12`` version of the JSON schema specification. | |
- Changes the REANA specification schema to use the ``draft-07`` version of the JSON schema specification. |
"type": "object", | ||
"type": [ | ||
"object", | ||
"null" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In which cases resources
can be null?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Never - restored it to just allowing objects
"kubernetes", | ||
"htcondor", | ||
"htcondorcern", | ||
"slurm", | ||
"slurmcern" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not think slurm
and htcondor
are allowed here. Did you find any places where they are used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I put them there to be less restrictive towards other REANA deployments that might want to integrate HTCondor or Slurm, but I don't know how the integration with those computational backends would work if external to CERN. Do you think it is better to remove them (and also avoid that CERN users mistakenly write "htcondor"
instead of "htcondorcern"
)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and also avoid that CERN users mistakenly write "htcondor" instead of "htcondorcern"
Yes, exactly, I think we should avoid this so let's remove them as currently we only support kubernetes
, htcondorcern
and slurmcern
. When we will add support for other Slurm/HTCondor instances we will update the schema accordingly!
tests/test_validation.py
Outdated
for warning_value in value: | ||
assert warning_value in warnings[key] | ||
else: | ||
assert operator.eq(value, warnings[key]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just as a curiosity, why we call operator.eq
here and not ==
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Relic of a previous version of the test in which I used map
and passed operator.eq
as a function. I've changed it to ==
to be more pythonic 😉
827d309
to
bbb85a3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
The only thing that needs to be changed is the new alpha version.
reana_commons/version.py
Outdated
@@ -14,4 +14,4 @@ | |||
|
|||
from __future__ import absolute_import, print_function | |||
|
|||
__version__ = "0.9.4a2" | |||
__version__ = "0.9.4a4" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's regenerate the release commit so that the new version is 0.9.4a3 and not 0.9.4a4
bbb85a3
to
120559a
Compare
Closes reanahub/reana-client#679.