Skip to content

Commit

Permalink
launch: include validation warnings in returned message
Browse files Browse the repository at this point in the history
In case some warnings are issued when launching a workflow, the `launch`
endpoint will now include them in the returned `message`.
Closes reanahub/reana-client#660.
  • Loading branch information
giuseppe-steduto committed Aug 9, 2023
1 parent b848c11 commit 9215f28
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
12 changes: 10 additions & 2 deletions reana_server/rest/launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def launch(user, url, name="", parameters="{}", specification=None):
with load_reana_spec_lock:
reana_yaml = load_reana_spec(spec_path, workspace_path=tmpdir)
input_parameters = json.loads(parameters)
validate_workflow(reana_yaml, input_parameters)
validation_warnings = validate_workflow(reana_yaml, input_parameters)

Check warning on line 183 in reana_server/rest/launch.py

View check run for this annotation

Codecov / codecov/patch

reana_server/rest/launch.py#L183

Added line #L183 was not covered by tests

# Keep only files and directories listed as workflow's inputs
filter_input_files(tmpdir, reana_yaml)
Expand Down Expand Up @@ -218,10 +218,18 @@ def launch(user, url, name="", parameters="{}", specification=None):
# Start the workflow
parameters = {"input_parameters": input_parameters}
publish_workflow_submission(workflow, user.id_, parameters)
if validation_warnings:
message = (

Check warning on line 222 in reana_server/rest/launch.py

View check run for this annotation

Codecov / codecov/patch

reana_server/rest/launch.py#L221-L222

Added lines #L221 - L222 were not covered by tests
"The workflow has been successfully submitted, but some "
"warnings were found during validation. "
f"{' '.join([x.message for x in validation_warnings])}"
)
else:
message = "The workflow has been successfully submitted."

Check warning on line 228 in reana_server/rest/launch.py

View check run for this annotation

Codecov / codecov/patch

reana_server/rest/launch.py#L228

Added line #L228 was not covered by tests
response_data = {
"workflow_id": workflow.id_,
"workflow_name": workflow.name,
"message": "The workflow has been successfully submitted.",
"message": message,
}
return LaunchSchema().dump(response_data)
except HTTPError as e:
Expand Down
7 changes: 4 additions & 3 deletions reana_server/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import itertools
import pathlib
from typing import Dict
from typing import Dict, List

from reana_commons.config import WORKSPACE_PATHS
from reana_commons.errors import REANAValidationError
Expand Down Expand Up @@ -107,7 +107,7 @@ def validate_inputs(reana_yaml: Dict) -> None:
)


def validate_workflow(reana_yaml: Dict, input_parameters: Dict) -> None:
def validate_workflow(reana_yaml: Dict, input_parameters: Dict) -> List[Exception]:
"""Validate REANA workflow specification by calling all the validation utilities.
:param reana_yaml: dictionary which represents REANA specification file.
Expand All @@ -119,12 +119,13 @@ def validate_workflow(reana_yaml: Dict, input_parameters: Dict) -> None:
operational_options = reana_yaml.get("inputs", {}).get("options", {})
original_parameters = reana_yaml.get("inputs", {}).get("parameters", {})

validate_reana_yaml(reana_yaml)
reana_yaml_warnings = validate_reana_yaml(reana_yaml)
validate_operational_options(workflow_type, operational_options)
validate_input_parameters(input_parameters, original_parameters)
validate_compute_backends(reana_yaml)
validate_workspace_path(reana_yaml)
validate_inputs(reana_yaml)
return reana_yaml_warnings

Check warning on line 128 in reana_server/validation.py

View check run for this annotation

Codecov / codecov/patch

reana_server/validation.py#L128

Added line #L128 was not covered by tests


def validate_retention_rule(rule: str, days: int) -> None:
Expand Down

0 comments on commit 9215f28

Please sign in to comment.