Spaces:
Runtime error
Runtime error
import json | |
import jsonschema | |
import streamlit as st | |
def get_schema(): | |
"""This function loads the given schema available""" | |
with open("schema.json", "r", encoding="utf8") as file: | |
schema = json.load(file) | |
return schema | |
def validate_json(json_data): | |
execute_api_schema = get_schema() | |
try: | |
jsonschema.validate(instance=json_data, schema=execute_api_schema) | |
except jsonschema.exceptions.ValidationError as err: | |
err = "Submission does not match GEM schema!" | |
return False, err | |
message = "Submission matches GEM schema!" | |
return True, message | |
def validate_submission(submission_data): | |
is_valid, message = validate_json(submission_data) | |
if is_valid: | |
st.write("All submission files validated! β¨ π β¨") | |
st.write("Now you can make a submission π€") | |
else: | |
st.write(message) | |
st.write("Please fix the submission files π") | |