From 5750fceff6dccfd3e13cb8c7d96905e5bad84719 Mon Sep 17 00:00:00 2001 From: Giuseppe Steduto Date: Thu, 26 Oct 2023 16:17:06 +0200 Subject: [PATCH] validation: make environment property mandatory in serial steps Closes reanahub/reana-client#679. --- CHANGES.rst | 5 +++ .../schemas/reana_analysis_schema.json | 42 ++++++++++++++++++- reana_commons/validation/utils.py | 4 +- 3 files changed, 49 insertions(+), 2 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 03ef09f5..66ce387f 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,6 +1,11 @@ Changes ======= +Version 0.9.4 (UNRELEASED) +-------------------------- + +- Changes the validation schema of the REANA specification to make the ``environment`` property mandatory for the steps of serial workflows. + Version 0.9.3 (2023-09-26) -------------------------- diff --git a/reana_commons/validation/schemas/reana_analysis_schema.json b/reana_commons/validation/schemas/reana_analysis_schema.json index c6263cf6..ab6600f1 100644 --- a/reana_commons/validation/schemas/reana_analysis_schema.json +++ b/reana_commons/validation/schemas/reana_analysis_schema.json @@ -68,7 +68,47 @@ "specification": { "id": "/properties/workflow/properties/specification", "type": "object", - "title": "Workflow specification in yaml format." + "title": "Workflow specification in yaml format.", + "properties": { + "steps": { + "id": "/properties/workflow/properties/specification/properties/steps", + "type": "array", + "title": "Serial workflow steps.", + "description": "List of steps which represent the workflow.", + "items": { + "properties": { + "name": { + "id": "/properties/workflow/properties/specification/properties/steps/properties/name", + "type": "string", + "title": "Step name." + }, + "environment": { + "id": "/properties/workflow/properties/specification/properties/steps/properties/environment", + "type": "string", + "title": "Image to be used by the container in which the step should be run." + }, + "kubernetes_memory_limit": { + "id": "/properties/workflow/properties/specification/properties/steps/properties/kubernetes_memory_limit", + "type": "string", + "title": "Memory limit for the step container (e.g. 256Mi)." + }, + "commands": { + "id": "/properties/workflow/properties/specification/properties/steps/properties/commands", + "type": "array", + "title": "Step commands.", + "description": "List of commands to be run in the step.", + "items": { + "type": "string", + "title": "Command to be run." + } + } + }, + "required": [ + "environment" + ] + } + } + } }, "file": { "id": "/properties/workflow/properties/file", diff --git a/reana_commons/validation/utils.py b/reana_commons/validation/utils.py index 6038e635..ae7f5fc5 100644 --- a/reana_commons/validation/utils.py +++ b/reana_commons/validation/utils.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # # This file is part of REANA. -# Copyright (C) 2022 CERN. +# Copyright (C) 2022, 2023 CERN. # # REANA is free software; you can redistribute it and/or modify it # under the terms of the MIT License; see LICENSE file for more details. @@ -77,6 +77,8 @@ def validate_reana_yaml(reana_yaml: Dict) -> Dict: """Validate REANA specification file according to jsonschema. :param reana_yaml: Dictionary which represents REANA specification file. + :returns: Dictionary of non-critical warnings, in the form of + {warning_key: [warning_value1, warning_value2, ...]}. :raises ValidationError: Given REANA spec file does not validate against REANA specification schema. """