Skip to content
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

Update sds schema validation #1538

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

Conversation

VirajP1002
Copy link
Contributor

@VirajP1002 VirajP1002 commented Oct 17, 2024

What is the context of this PR?

To align with SDS & Author we need to update the validation rules for supplementary data schema versions within Runner in order to support future automation of the releases of new SDS schema versions.

supplementary_data_parser previously used a list of known versions but this will become unmanageable with several versions. Instead, we compare the sds_schema_version set in a questionnaire schema to the schema_version found in the supplementary data payload. We pass sds_schema_version from session.py to supplementary_data_parser for it to be validated. The old logic has been removed and tests have been updated/added to show this change.

A new schema has been added called test_supplementary_data_with_sds_schema_version.json to include this new field.

How to review

  • Ensure changes make sense
  • Check unit & functional tests pass
  • Ensure schema validation passes (using the validator PR)

Checklist

  • New static content marked up for translation
  • Newly defined schema content included in eq-translations repo

@VirajP1002 VirajP1002 marked this pull request as ready for review October 18, 2024 18:15
@@ -80,12 +71,19 @@ def validate_dataset_and_survey_id( # pylint: disable=unused-argument
"Supplementary data did not return the specified Survey ID"
)

if self.context["sds_schema_version"]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can merge the nested if here. Also data["data"] is a bit weird but not sure there is a way around it

"survey_id": "123",
"title": "Test Supplementary Data",
"theme": "default",
"description": "A questionnaire to demo using Supplementary data for placeholders, validation and routing in both repeating and non repeating sections.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would update the description here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new schema is not actually being used anywhere?

@@ -177,6 +177,7 @@ def _set_questionnaire_supplementary_data(
dataset_id=new_sds_dataset_id,
identifier=identifier, # type: ignore
survey_id=metadata["survey_id"], # type: ignore
sds_schema_version=schema.json.get("sds_schema_version", None),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As .get() implicitly returns None if the key isn't found, might not need to override the output here?

if self.context["sds_schema_version"]:
if data["data"]["schema_version"] != self.context["sds_schema_version"]:
raise ValidationError(
"The Supplementary Dataset version does not match the version set in the questionnaire schema"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

V minor - To fit with the wording in the other exceptions, could maybe tweak this to match the wording for sds_schema_version, so like The Supplementary Dataset Schema version does not match the questionnaire schema version? Or something similar just to add a bit more description?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants