From 15a01adbe724c27d3b465169acf50357a59d6ff0 Mon Sep 17 00:00:00 2001 From: Giuseppe Steduto Date: Wed, 9 Aug 2023 11:23:11 +0200 Subject: [PATCH] utils: display warning messages about REANA spec validation Closes #660 --- CHANGES.rst | 1 + reana_client/validation/utils.py | 39 +++++++++++++++++++++++++++----- setup.py | 2 +- 3 files changed, 35 insertions(+), 7 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 3008491e..ca43a6ba 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -4,6 +4,7 @@ Changes Version 0.9.1 (UNRELEASED) -------------------------- +- Changes ``validate`` command to display non-critical validation warnings when checking the REANA specification file. - Adds ``prune`` command to delete all intermediate files of a given workflow. - Fixes ``list`` command to correctly list workflows when sorting them by their run number or by the size of their workspace. - Fixes ``du`` command help message typo. diff --git a/reana_client/validation/utils.py b/reana_client/validation/utils.py index c77fe052..3d9e2ea1 100644 --- a/reana_client/validation/utils.py +++ b/reana_client/validation/utils.py @@ -51,12 +51,39 @@ def validate_reana_spec( f"Verifying REANA specification file... {filepath}", msg_type="info", ) - validate_reana_yaml(reana_yaml) - display_message( - "Valid REANA specification file.", - msg_type="success", - indented=True, - ) + validation_warnings = validate_reana_yaml(reana_yaml) + if validation_warnings: + display_message( + "The REANA specification appears valid, but some warnings were found.", + msg_type="warning", + indented=True, + ) + for warning_key, warning_value in validation_warnings.items(): + if warning_key == "additional_properties": + # warning_values is a list of unexpected properties + message = ( + f"Unexpected properties found in REANA specification file: " + f"{', '.join(warning_value)}" + ) + else: + message = warning_value + display_message( + message, + msg_type="warning", + indented=True, + ) + if validation_warnings: + display_message( + "Please make sure that the REANA specification file is correct.", + msg_type="warning", + indented=True, + ) + else: + display_message( + "Valid REANA specification file.", + msg_type="success", + indented=True, + ) validate_parameters(reana_yaml) diff --git a/setup.py b/setup.py index 60845d6c..b8e8445e 100644 --- a/setup.py +++ b/setup.py @@ -45,7 +45,7 @@ "click>=7", "pathspec==0.9.0", "jsonpointer>=2.0", - "reana-commons[yadage,snakemake,cwl]>=0.9.3a4,<0.10.0", + "reana-commons[yadage,snakemake,cwl]>=0.9.3a5,<0.10.0", "tablib>=0.12.1,<0.13", "werkzeug>=0.14.1 ; python_version<'3.10'", "werkzeug>=0.15.0 ; python_version>='3.10'",